diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0722c756e37..14eb241b670 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,12 +2,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' @@ -22,7 +24,7 @@ jobs: timeout-minutes: 10 name: lint 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 + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -41,7 +43,7 @@ jobs: run: ./scripts/lint build: - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') timeout-minutes: 10 name: build permissions: @@ -66,14 +68,18 @@ jobs: run: rye build - name: Get GitHub OIDC Token - if: github.repository == 'stainless-sdks/cloudflare-python' + if: |- + github.repository == 'stainless-sdks/cloudflare-python' && + !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v6 + uses: actions/github-script@v8 with: script: core.setOutput('github_token', await core.getIDToken()); - name: Upload tarball - if: github.repository == 'stainless-sdks/cloudflare-python' + if: |- + github.repository == 'stainless-sdks/cloudflare-python' && + !startsWith(github.ref, 'refs/heads/stl/') env: URL: https://pkg.stainless.com/s AUTH: ${{ steps.github-oidc.outputs.github_token }} @@ -106,7 +112,7 @@ jobs: timeout-minutes: 10 name: examples 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) + if: github.repository == 'cloudflare/cloudflare-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 diff --git a/.gitignore b/.gitignore index 95ceb189aa4..3824f4c485f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log _dev __pycache__ diff --git a/.stats.yml b/.stats.yml index ee5aba40e84..b491db02992 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 2126 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c51406afe7e9e2e80becb9d86c4d0b67cfe23a0d04fbfba973c2133da11be47f.yml -openapi_spec_hash: ebe782c4592c06e7e22eb0a725cc326e -config_hash: fab306f9c013d1ed01ed9c35c79f428b +configured_endpoints: 2184 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3d7d43f051a510c54ae71adb4b85cbb422565a40942cde4de0c3f8eb6ba8023b.yml +openapi_spec_hash: e85824f16c3ba923a34e514c06dac7cd +config_hash: 02fbdebd82a78d34dd6d005f1d2ad28c diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f6d738cea14..320cdedd0ff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,8 +88,7 @@ $ pip install ./path-to-wheel-file.whl Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. ```sh -# you will need npm installed -$ npx prism mock path/to/your/openapi.yml +$ ./scripts/mock ``` ```sh diff --git a/README.md b/README.md index 9f9d4b169a7..c9b0fb08c36 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ It is generated with [Stainless](https://www.stainless.com/). 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) +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=cloudflare-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNsb3VkZmxhcmUtbWNwIl0sImVudiI6eyJDTE9VREZMQVJFX0FQSV9UT0tFTiI6IlNuM2xaSlRCWDZra2c3T2RjQlVBeE9POTYzR0VJeUdRcW5GVE9GWVkiLCJDTE9VREZMQVJFX0FQSV9LRVkiOiIxNDRjOWRlZmFjMDQ5NjljN2JmYWQ4ZWZhYThlYTE5NCIsIkNMT1VERkxBUkVfRU1BSUwiOiJ1c2VyQGV4YW1wbGUuY29tIiwiQ0xPVURGTEFSRV9BUElfVVNFUl9TRVJWSUNFX0tFWSI6InYxLjAtMTQ0YzlkZWZhYzA0OTY5YzdiZmFkOGVmLTYzMWE0MWQwMDNhMzJkMjVmZTg3ODA4MWVmMzY1YzQ5NTAzZjdmYWRhNjAwZGE5MzVlMjg1MWExYzczMjYwODRiODVjYmY2NDI5YzRiODU5ZGU4NDc1NzMxZGM5MmE5YzMyOTYzMWU2ZDU5ZTZjNzNkYTdiMTk4NDk3MTcyYjRjZWZlMDcxZDkwZDBmNWQyNzE5IiwiQ0xPVURGTEFSRV9BQ0NPVU5UX0lEIjoiZjAzN2U1NmU4OTI5M2EwNTc3NDBkZTY4MWFjOWFjY3AiLCJDTE9VREZMQVJFX1pPTkVfSUQiOiJmMDM3ZTU2ZTg5MjkzYTA1Nzc0MGRlNjgxYWM5YWNjcCJ9fQ) +[![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%2C%22env%22%3A%7B%22CLOUDFLARE_API_TOKEN%22%3A%22Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY%22%2C%22CLOUDFLARE_API_KEY%22%3A%22144c9defac04969c7bfad8efaa8ea194%22%2C%22CLOUDFLARE_EMAIL%22%3A%22user%40example.com%22%2C%22CLOUDFLARE_API_USER_SERVICE_KEY%22%3A%22v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719%22%2C%22CLOUDFLARE_ACCOUNT_ID%22%3A%22f037e56e89293a057740de681ac9accp%22%2C%22CLOUDFLARE_ZONE_ID%22%3A%22f037e56e89293a057740de681ac9accp%22%7D%7D) > Note: You may need to set environment variables in your MCP client. diff --git a/api.md b/api.md index b3c7cdb0d46..a7c08bd17f3 100644 --- a/api.md +++ b/api.md @@ -29,11639 +29,214 @@ from cloudflare.types import ( ) ``` -# Accounts +# [Accounts](src/cloudflare/resources/accounts/api.md) -Types: +# [Organizations](src/cloudflare/resources/organizations/api.md) -```python -from cloudflare.types.accounts import Account, AccountDeleteResponse -``` - -Methods: - -- 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, MemberDeleteResponse -``` - -Methods: - -- 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.organizations import OrganizationProfile -``` - -Methods: - -- client.organizations.organization_profile.update(organization_id, \*\*params) -> None -- client.organizations.organization_profile.get(organization_id) -> Result - -# OriginCACertificates - -Types: - -```python -from cloudflare.types.origin_ca_certificates import ( - OriginCACertificate, - OriginCACertificateDeleteResponse, -) -``` - -Methods: - -- 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, IPListResponse -``` - -Methods: - -- client.ips.list(\*\*params) -> Optional[IPListResponse] - -# Memberships - -Types: - -```python -from cloudflare.types.memberships import ( - Membership, - MembershipUpdateResponse, - MembershipDeleteResponse, - MembershipGetResponse, -) -``` - -Methods: - -- client.memberships.update(membership_id, \*\*params) -> Optional[MembershipUpdateResponse] -- client.memberships.list(\*\*params) -> SyncV4PagePaginationArray[Membership] -- client.memberships.delete(membership_id) -> Optional[MembershipDeleteResponse] -- client.memberships.get(membership_id) -> Optional[MembershipGetResponse] - -# User - -Types: - -```python -from cloudflare.types.user import UserEditResponse, UserGetResponse -``` - -Methods: - -- client.user.edit(\*\*params) -> Optional[UserEditResponse] -- client.user.get() -> Optional[UserGetResponse] - -## AuditLogs - -Methods: - -- client.user.audit_logs.list(\*\*params) -> SyncV4PagePaginationArray[AuditLog] - -## Billing - -### History - -Types: - -```python -from cloudflare.types.user.billing import BillingHistory -``` - -Methods: - -- client.user.billing.history.list(\*\*params) -> SyncV4PagePaginationArray[BillingHistory] - -### Profile - -Types: - -```python -from cloudflare.types.user.billing import ProfileGetResponse -``` - -Methods: - -- client.user.billing.profile.get() -> ProfileGetResponse - -## Invites - -Types: - -```python -from cloudflare.types.user import Invite -``` - -Methods: - -- client.user.invites.list() -> SyncSinglePage[Invite] -- 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 -``` - -Methods: - -- client.user.organizations.list(\*\*params) -> SyncV4PagePaginationArray[Organization] -- client.user.organizations.delete(organization_id) -> OrganizationDeleteResponse -- client.user.organizations.get(organization_id) -> object - -## Subscriptions - -Types: - -```python -from cloudflare.types.user import SubscriptionUpdateResponse, SubscriptionDeleteResponse -``` - -Methods: - -- client.user.subscriptions.update(identifier, \*\*params) -> SubscriptionUpdateResponse -- client.user.subscriptions.delete(identifier) -> SubscriptionDeleteResponse -- client.user.subscriptions.get() -> SyncSinglePage[Subscription] - -## Tokens - -Types: - -```python -from cloudflare.types.user import TokenCreateResponse, TokenDeleteResponse, TokenVerifyResponse -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.user.tokens import PermissionGroupListResponse -``` - -Methods: - -- client.user.tokens.permission_groups.list(\*\*params) -> SyncSinglePage[PermissionGroupListResponse] - -### Value - -Methods: - -- client.user.tokens.value.update(token_id, \*\*params) -> str - -# Zones - -Types: - -```python -from cloudflare.types.zones import Type, Zone, ZoneDeleteResponse -``` - -Methods: - -- client.zones.create(\*\*params) -> Optional[Zone] -- client.zones.list(\*\*params) -> SyncV4PagePaginationArray[Zone] -- client.zones.delete(\*, zone_id) -> Optional[ZoneDeleteResponse] -- client.zones.edit(\*, zone_id, \*\*params) -> Optional[Zone] -- client.zones.get(\*, zone_id) -> Optional[Zone] - -## ActivationCheck - -Types: - -```python -from cloudflare.types.zones import ActivationCheckTriggerResponse -``` - -Methods: - -- client.zones.activation_check.trigger(\*, zone_id) -> Optional[ActivationCheckTriggerResponse] - -## Settings - -Types: - -```python -from cloudflare.types.zones import ( - AdvancedDDoS, - Aegis, - AlwaysOnline, - AlwaysUseHTTPS, - AutomaticHTTPSRewrites, - AutomaticPlatformOptimization, - Brotli, - BrowserCacheTTL, - BrowserCheck, - CacheLevel, - ChallengeTTL, - Ciphers, - DevelopmentMode, - EarlyHints, - EmailObfuscation, - FontSettings, - H2Prioritization, - HotlinkProtection, - HTTP2, - HTTP3, - ImageResizing, - IPGeolocation, - IPV6, - MinTLSVersion, - Mirage, - NEL, - OpportunisticEncryption, - OpportunisticOnion, - OrangeToOrange, - OriginErrorPagePassThru, - OriginMaxHTTPVersion, - Polish, - PrefetchPreload, - ProxyReadTimeout, - PseudoIPV4, - ResponseBuffering, - RocketLoader, - SecurityHeaders, - SecurityLevel, - ServerSideExcludes, - SortQueryStringForCache, - SSL, - SSLRecommender, - TLS1_3, - TLSClientAuth, - TrueClientIPHeader, - WAF, - WebP, - Websocket, - ZeroRTT, - SettingEditResponse, - SettingGetResponse, -) -``` - -Methods: - -- client.zones.settings.edit(setting_id, \*, zone_id, \*\*params) -> Optional[SettingEditResponse] -- client.zones.settings.get(setting_id, \*, zone_id) -> Optional[SettingGetResponse] - -## Environments - -Types: - -```python -from cloudflare.types.zones import ( - EnvironmentCreateResponse, - EnvironmentUpdateResponse, - EnvironmentListResponse, - EnvironmentDeleteResponse, - EnvironmentEditResponse, - EnvironmentRollbackResponse, -) -``` - -Methods: - -- client.zones.environments.create(\*, zone_id, \*\*params) -> EnvironmentCreateResponse -- client.zones.environments.update(\*, zone_id, \*\*params) -> EnvironmentUpdateResponse -- client.zones.environments.list(\*, zone_id) -> EnvironmentListResponse -- client.zones.environments.delete(environment_id, \*, zone_id) -> EnvironmentDeleteResponse -- client.zones.environments.edit(\*, zone_id, \*\*params) -> EnvironmentEditResponse -- client.zones.environments.rollback(environment_id, \*, zone_id) -> EnvironmentRollbackResponse - -## CustomNameservers - -Types: - -```python -from cloudflare.types.zones import CustomNameserverUpdateResponse, CustomNameserverGetResponse -``` - -Methods: - -- client.zones.custom_nameservers.update(\*, zone_id, \*\*params) -> SyncSinglePage[CustomNameserverUpdateResponse] -- client.zones.custom_nameservers.get(\*, zone_id) -> CustomNameserverGetResponse - -## Holds - -Types: - -```python -from cloudflare.types.zones import ZoneHold -``` - -Methods: - -- client.zones.holds.create(\*, zone_id, \*\*params) -> ZoneHold -- client.zones.holds.delete(\*, zone_id, \*\*params) -> ZoneHold -- client.zones.holds.edit(\*, zone_id, \*\*params) -> ZoneHold -- client.zones.holds.get(\*, zone_id) -> ZoneHold - -## Subscriptions - -Types: - -```python -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.rate_plans.get(\*, zone_id) -> SyncSinglePage[RatePlanGetResponse] - -# LoadBalancers - -Types: - -```python -from cloudflare.types.load_balancers import ( - AdaptiveRouting, - CheckRegion, - DefaultPools, - FilterOptions, - Header, - Host, - LoadBalancer, - LoadShedding, - LocationStrategy, - NotificationFilter, - Origin, - OriginSteering, - RandomSteering, - Rules, - SessionAffinity, - SessionAffinityAttributes, - SteeringPolicy, - LoadBalancerDeleteResponse, -) -``` - -Methods: - -- client.load_balancers.create(\*, zone_id, \*\*params) -> LoadBalancer -- client.load_balancers.update(load_balancer_id, \*, zone_id, \*\*params) -> LoadBalancer -- client.load_balancers.list(\*, zone_id) -> SyncSinglePage[LoadBalancer] -- client.load_balancers.delete(load_balancer_id, \*, zone_id) -> LoadBalancerDeleteResponse -- client.load_balancers.edit(load_balancer_id, \*, zone_id, \*\*params) -> LoadBalancer -- client.load_balancers.get(load_balancer_id, \*, zone_id) -> LoadBalancer - -## Monitors - -Types: - -```python -from cloudflare.types.load_balancers import Monitor, MonitorDeleteResponse -``` - -Methods: - -- client.load_balancers.monitors.create(\*, account_id, \*\*params) -> Monitor -- client.load_balancers.monitors.update(monitor_id, \*, account_id, \*\*params) -> Monitor -- client.load_balancers.monitors.list(\*, account_id) -> SyncSinglePage[Monitor] -- client.load_balancers.monitors.delete(monitor_id, \*, account_id) -> MonitorDeleteResponse -- client.load_balancers.monitors.edit(monitor_id, \*, account_id, \*\*params) -> Monitor -- client.load_balancers.monitors.get(monitor_id, \*, account_id) -> Monitor - -### Previews - -Types: - -```python -from cloudflare.types.load_balancers.monitors import PreviewCreateResponse -``` - -Methods: - -- client.load_balancers.monitors.previews.create(monitor_id, \*, account_id, \*\*params) -> PreviewCreateResponse - -### References - -Types: - -```python -from cloudflare.types.load_balancers.monitors import ReferenceGetResponse -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.load_balancers import Pool, PoolDeleteResponse -``` - -Methods: - -- client.load_balancers.pools.create(\*, account_id, \*\*params) -> Pool -- 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 - -### Health - -Types: - -```python -from cloudflare.types.load_balancers.pools import HealthCreateResponse, HealthGetResponse -``` - -Methods: - -- client.load_balancers.pools.health.create(pool_id, \*, account_id, \*\*params) -> HealthCreateResponse -- client.load_balancers.pools.health.get(pool_id, \*, account_id) -> HealthGetResponse - -### References - -Types: - -```python -from cloudflare.types.load_balancers.pools import ReferenceGetResponse -``` - -Methods: - -- client.load_balancers.pools.references.get(pool_id, \*, account_id) -> SyncSinglePage[ReferenceGetResponse] - -## Previews - -Types: - -```python -from cloudflare.types.load_balancers import PreviewGetResponse -``` - -Methods: - -- client.load_balancers.previews.get(preview_id, \*, account_id) -> PreviewGetResponse - -## Regions - -Types: - -```python -from cloudflare.types.load_balancers import RegionListResponse, RegionGetResponse -``` - -Methods: - -- client.load_balancers.regions.list(\*, account_id, \*\*params) -> RegionListResponse -- client.load_balancers.regions.get(region_id, \*, account_id) -> RegionGetResponse - -## Searches - -Types: - -```python -from cloudflare.types.load_balancers import SearchListResponse -``` - -Methods: - -- client.load_balancers.searches.list(\*, account_id, \*\*params) -> SyncV4PagePagination[SearchListResponse] - -# Cache - -Types: - -```python -from cloudflare.types.cache import CachePurgeResponse -``` - -Methods: - -- client.cache.purge(\*, zone_id, \*\*params) -> Optional[CachePurgeResponse] - -## CacheReserve - -Types: - -```python -from cloudflare.types.cache import ( - CacheReserve, - CacheReserveClear, - State, - CacheReserveClearResponse, - CacheReserveEditResponse, - CacheReserveGetResponse, - CacheReserveStatusResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.cache import ( - SmartTieredCacheDeleteResponse, - SmartTieredCacheEditResponse, - SmartTieredCacheGetResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.cache import ( - CacheVariant, - VariantDeleteResponse, - VariantEditResponse, - VariantGetResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.cache import ( - RegionalTieredCache, - RegionalTieredCacheEditResponse, - RegionalTieredCacheGetResponse, -) -``` - -Methods: - -- client.cache.regional_tiered_cache.edit(\*, zone_id, \*\*params) -> Optional[RegionalTieredCacheEditResponse] -- client.cache.regional_tiered_cache.get(\*, zone_id) -> Optional[RegionalTieredCacheGetResponse] - -# SSL - -## Analyze - -Methods: - -- client.ssl.analyze.create(\*, zone_id, \*\*params) -> object - -## CertificatePacks - -Types: - -```python -from cloudflare.types.ssl import ( - Host, - RequestValidity, - Status, - ValidationMethod, - CertificatePackCreateResponse, - CertificatePackListResponse, - CertificatePackDeleteResponse, - CertificatePackEditResponse, - CertificatePackGetResponse, -) -``` - -Methods: - -- client.ssl.certificate_packs.create(\*, zone_id, \*\*params) -> Optional[CertificatePackCreateResponse] -- client.ssl.certificate_packs.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[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 - -Types: - -```python -from cloudflare.types.ssl.certificate_packs import QuotaGetResponse -``` - -Methods: - -- client.ssl.certificate_packs.quota.get(\*, zone_id) -> Optional[QuotaGetResponse] - -## Recommendations - -Types: - -```python -from cloudflare.types.ssl import RecommendationGetResponse -``` - -Methods: - -- client.ssl.recommendations.get(\*, zone_id) -> RecommendationGetResponse - -## Universal - -### Settings - -Types: - -```python -from cloudflare.types.ssl.universal import UniversalSSLSettings -``` - -Methods: - -- client.ssl.universal.settings.edit(\*, zone_id, \*\*params) -> Optional[UniversalSSLSettings] -- client.ssl.universal.settings.get(\*, zone_id) -> Optional[UniversalSSLSettings] - -## Verification - -Types: - -```python -from cloudflare.types.ssl import Verification, VerificationEditResponse, VerificationGetResponse -``` - -Methods: - -- client.ssl.verification.edit(certificate_pack_id, \*, zone_id, \*\*params) -> Optional[VerificationEditResponse] -- client.ssl.verification.get(\*, zone_id, \*\*params) -> Optional[VerificationGetResponse] - -# ACM - -## TotalTLS - -Types: - -```python -from cloudflare.types.acm import ( - CertificateAuthority, - TotalTLSUpdateResponse, - TotalTLSEditResponse, - TotalTLSGetResponse, -) -``` - -Methods: - -- 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] - -## CustomTrustStore - -Types: - -```python -from cloudflare.types.acm import CustomTrustStore, CustomTrustStoreDeleteResponse -``` - -Methods: - -- client.acm.custom_trust_store.create(\*, zone_id, \*\*params) -> Optional[CustomTrustStore] -- client.acm.custom_trust_store.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[CustomTrustStore] -- client.acm.custom_trust_store.delete(custom_origin_trust_store_id, \*, zone_id) -> Optional[CustomTrustStoreDeleteResponse] -- client.acm.custom_trust_store.get(custom_origin_trust_store_id, \*, zone_id) -> Optional[CustomTrustStore] - -# Argo - -## SmartRouting - -Types: - -```python -from cloudflare.types.argo import SmartRoutingEditResponse, SmartRoutingGetResponse -``` - -Methods: - -- client.argo.smart_routing.edit(\*, zone_id, \*\*params) -> SmartRoutingEditResponse -- client.argo.smart_routing.get(\*, zone_id) -> SmartRoutingGetResponse - -## TieredCaching - -Types: - -```python -from cloudflare.types.argo import TieredCachingEditResponse, TieredCachingGetResponse -``` - -Methods: - -- client.argo.tiered_caching.edit(\*, zone_id, \*\*params) -> Optional[TieredCachingEditResponse] -- client.argo.tiered_caching.get(\*, zone_id) -> Optional[TieredCachingGetResponse] - -# CertificateAuthorities - -## HostnameAssociations - -Types: - -```python -from cloudflare.types.certificate_authorities import ( - HostnameAssociation, - TLSHostnameAssociation, - HostnameAssociationUpdateResponse, - HostnameAssociationGetResponse, -) -``` - -Methods: - -- client.certificate_authorities.hostname_associations.update(\*, zone_id, \*\*params) -> Optional[HostnameAssociationUpdateResponse] -- client.certificate_authorities.hostname_associations.get(\*, zone_id, \*\*params) -> Optional[HostnameAssociationGetResponse] - -# ClientCertificates - -Types: - -```python -from cloudflare.types.client_certificates import ClientCertificate -``` - -Methods: - -- 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[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 - -Types: - -```python -from cloudflare.types.custom_certificates import ( - CustomCertificate, - GeoRestrictions, - Status, - CustomCertificateDeleteResponse, -) -``` - -Methods: - -- 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[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 - -Methods: - -- client.custom_certificates.prioritize.update(\*, zone_id, \*\*params) -> SyncSinglePage[CustomCertificate] - -# CustomHostnames - -Types: - -```python -from cloudflare.types.custom_hostnames import ( - BundleMethod, - CustomHostname, - DCVMethod, - DomainValidationType, - CustomHostnameCreateResponse, - CustomHostnameListResponse, - CustomHostnameDeleteResponse, - CustomHostnameEditResponse, - CustomHostnameGetResponse, -) -``` - -Methods: - -- 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[CustomHostnameEditResponse] -- client.custom_hostnames.get(custom_hostname_id, \*, zone_id) -> Optional[CustomHostnameGetResponse] - -## FallbackOrigin - -Types: - -```python -from cloudflare.types.custom_hostnames import ( - FallbackOriginUpdateResponse, - FallbackOriginDeleteResponse, - FallbackOriginGetResponse, -) -``` - -Methods: - -- 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 -``` - -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.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 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: - -```python -from cloudflare.types.dns import ( - ARecord, - AAAARecord, - BatchPatch, - BatchPut, - CAARecord, - CERTRecord, - CNAMERecord, - DNSKEYRecord, - DSRecord, - HTTPSRecord, - LOCRecord, - MXRecord, - NAPTRRecord, - NSRecord, - PTRRecord, - Record, - RecordResponse, - RecordTags, - SMIMEARecord, - SRVRecord, - SSHFPRecord, - SVCBRecord, - TLSARecord, - TTL, - TXTRecord, - URIRecord, - RecordDeleteResponse, - RecordBatchResponse, - RecordExportResponse, - RecordImportResponse, - RecordScanResponse, - RecordScanReviewResponse, - RecordScanTriggerResponse, -) -``` - -Methods: - -- 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[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.settings import ZoneEditResponse, ZoneGetResponse -``` - -Methods: - -- client.dns.settings.zone.edit(\*, zone_id, \*\*params) -> Optional[ZoneEditResponse] -- client.dns.settings.zone.get(\*, zone_id) -> Optional[ZoneGetResponse] - -### Account - -Types: - -```python -from cloudflare.types.dns.settings import AccountEditResponse, AccountGetResponse -``` - -Methods: - -- client.dns.settings.account.edit(\*, account_id, \*\*params) -> Optional[AccountEditResponse] -- client.dns.settings.account.get(\*, account_id) -> Optional[AccountGetResponse] - -#### Views - -Types: - -```python -from cloudflare.types.dns.settings.account import ( - ViewCreateResponse, - ViewListResponse, - ViewDeleteResponse, - ViewEditResponse, - ViewGetResponse, -) -``` - -Methods: - -- 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 - -### Reports - -Types: - -```python -from cloudflare.types.dns.analytics import Report -``` - -Methods: - -- client.dns.analytics.reports.get(\*, zone_id, \*\*params) -> Optional[Report] - -#### Bytimes - -Types: - -```python -from cloudflare.types.dns.analytics.reports import ByTime -``` - -Methods: - -- client.dns.analytics.reports.bytimes.get(\*, zone_id, \*\*params) -> Optional[ByTime] - -## ZoneTransfers - -### ForceAXFR - -Types: - -```python -from cloudflare.types.dns.zone_transfers import ForceAXFR -``` - -Methods: - -- client.dns.zone_transfers.force_axfr.create(\*, zone_id, \*\*params) -> str - -### Incoming - -Types: - -```python -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, \*\*params) -> 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, \*\*params) -> 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) -> 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] - -## Phishguard - -### Reports - -Types: - -```python -from cloudflare.types.email_security.phishguard import ReportListResponse -``` - -Methods: - -- client.email_security.phishguard.reports.list(\*, account_id, \*\*params) -> SyncSinglePage[ReportListResponse] - -## 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: - -```python -from cloudflare.types.email_routing import DNSRecord, DNSGetResponse -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.email_routing import Action, EmailRoutingRule, Matcher -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.email_routing.rules import ( - CatchAllAction, - CatchAllMatcher, - CatchAllUpdateResponse, - CatchAllGetResponse, -) -``` - -Methods: - -- client.email_routing.rules.catch_alls.update(\*, zone_id, \*\*params) -> Optional[CatchAllUpdateResponse] -- client.email_routing.rules.catch_alls.get(\*, zone_id) -> Optional[CatchAllGetResponse] - -## Addresses - -Types: - -```python -from cloudflare.types.email_routing import Address -``` - -Methods: - -- 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] - -# EmailSending - -Types: - -```python -from cloudflare.types.email_sending import EmailSendingSendResponse, EmailSendingSendRawResponse -``` - -Methods: - -- client.email_sending.send(\*, account_id, \*\*params) -> EmailSendingSendResponse -- client.email_sending.send_raw(\*, account_id, \*\*params) -> EmailSendingSendRawResponse - -## Subdomains - -Types: - -```python -from cloudflare.types.email_sending import ( - SubdomainCreateResponse, - SubdomainListResponse, - SubdomainDeleteResponse, - SubdomainGetResponse, -) -``` - -Methods: - -- client.email_sending.subdomains.create(\*, zone_id, \*\*params) -> Optional[SubdomainCreateResponse] -- client.email_sending.subdomains.list(\*, zone_id) -> SyncSinglePage[SubdomainListResponse] -- client.email_sending.subdomains.delete(subdomain_id, \*, zone_id) -> SubdomainDeleteResponse -- client.email_sending.subdomains.get(subdomain_id, \*, zone_id) -> Optional[SubdomainGetResponse] - -### DNS - -Methods: - -- client.email_sending.subdomains.dns.get(subdomain_id, \*, zone_id) -> SyncSinglePage[DNSRecord] - -# Filters - -Types: - -```python -from cloudflare.types.filters import FirewallFilter, FilterDeleteResponse, FilterBulkDeleteResponse -``` - -Methods: - -- 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 - -## Lockdowns - -Types: - -```python -from cloudflare.types.firewall import ( - Configuration, - Lockdown, - LockdownCIDRConfiguration, - LockdownIPConfiguration, - LockdownURL, - LockdownDeleteResponse, -) -``` - -Methods: - -- 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 DeletedFilter, FirewallRule, Product -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.firewall import ( - AccessRuleCIDRConfiguration, - AccessRuleIPConfiguration, - ASNConfiguration, - CountryConfiguration, - IPV6Configuration, - AccessRuleCreateResponse, - AccessRuleListResponse, - AccessRuleDeleteResponse, - AccessRuleEditResponse, - AccessRuleGetResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.firewall import ( - UARuleCreateResponse, - UARuleUpdateResponse, - UARuleListResponse, - UARuleDeleteResponse, - UARuleGetResponse, -) -``` - -Methods: - -- 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 - -### Overrides - -Types: - -```python -from cloudflare.types.firewall.waf import ( - Override, - OverrideURL, - RewriteAction, - WAFRule, - OverrideDeleteResponse, -) -``` - -Methods: - -- 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 PackageGetResponse -``` - -Methods: - -- client.firewall.waf.packages.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[object] -- client.firewall.waf.packages.get(package_id, \*, zone_id) -> PackageGetResponse - -#### Groups - -Types: - -```python -from cloudflare.types.firewall.waf.packages import Group, GroupEditResponse, GroupGetResponse -``` - -Methods: - -- client.firewall.waf.packages.groups.list(package_id, \*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Group] -- client.firewall.waf.packages.groups.edit(group_id, \*, zone_id, package_id, \*\*params) -> GroupEditResponse -- client.firewall.waf.packages.groups.get(group_id, \*, zone_id, package_id) -> GroupGetResponse - -#### Rules - -Types: - -```python -from cloudflare.types.firewall.waf.packages import ( - AllowedModesAnomaly, - WAFRuleGroup, - RuleListResponse, - RuleEditResponse, - RuleGetResponse, -) -``` - -Methods: - -- client.firewall.waf.packages.rules.list(package_id, \*, zone_id, \*\*params) -> SyncV4PagePaginationArray[RuleListResponse] -- client.firewall.waf.packages.rules.edit(rule_id, \*, zone_id, package_id, \*\*params) -> RuleEditResponse -- client.firewall.waf.packages.rules.get(rule_id, \*, zone_id, package_id) -> RuleGetResponse - -# Healthchecks - -Types: - -```python -from cloudflare.types.healthchecks import ( - CheckRegion, - Healthcheck, - HTTPConfiguration, - QueryHealthcheck, - TCPConfiguration, - HealthcheckDeleteResponse, -) -``` - -Methods: - -- client.healthchecks.create(\*, zone_id, \*\*params) -> Healthcheck -- client.healthchecks.update(healthcheck_id, \*, zone_id, \*\*params) -> 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 - -## Previews - -Types: - -```python -from cloudflare.types.healthchecks import PreviewDeleteResponse -``` - -Methods: - -- client.healthchecks.previews.create(\*, zone_id, \*\*params) -> Healthcheck -- client.healthchecks.previews.delete(healthcheck_id, \*, zone_id) -> PreviewDeleteResponse -- client.healthchecks.previews.get(healthcheck_id, \*, zone_id) -> Healthcheck - -# KeylessCertificates - -Types: - -```python -from cloudflare.types.keyless_certificates import ( - KeylessCertificate, - Tunnel, - KeylessCertificateDeleteResponse, -) -``` - -Methods: - -- 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[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 - -## Datasets - -### Fields - -Methods: - -- client.logpush.datasets.fields.get(dataset_id, \*, account_id, zone_id) -> object - -### Jobs - -Methods: - -- client.logpush.datasets.jobs.get(dataset_id, \*, account_id, zone_id) -> SyncSinglePage[Optional[LogpushJob]] - -## Edge - -Types: - -```python -from cloudflare.types.logpush import InstantLogpushJob -``` - -Methods: - -- client.logpush.edge.create(\*, zone_id, \*\*params) -> Optional[InstantLogpushJob] -- client.logpush.edge.get(\*, zone_id) -> SyncSinglePage[Optional[InstantLogpushJob]] - -## Jobs - -Types: - -```python -from cloudflare.types.logpush import LogpushJob, OutputOptions, JobDeleteResponse -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.logpush import OwnershipValidation, OwnershipCreateResponse -``` - -Methods: - -- 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, - ValidateDestinationExistsResponse, - ValidateOriginResponse, -) -``` - -Methods: - -- 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 - -## Control - -### Retention - -Types: - -```python -from cloudflare.types.logs.control import RetentionCreateResponse, RetentionGetResponse -``` - -Methods: - -- client.logs.control.retention.create(\*, zone_id, \*\*params) -> Optional[RetentionCreateResponse] -- client.logs.control.retention.get(\*, zone_id) -> Optional[RetentionGetResponse] - -### Cmb - -#### Config - -Types: - -```python -from cloudflare.types.logs.control.cmb import CmbConfig -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.logs import RayIDGetResponse -``` - -Methods: - -- client.logs.rayid.get(rayid, \*, zone_id, \*\*params) -> RayIDGetResponse - -## Received - -Types: - -```python -from cloudflare.types.logs import ReceivedGetResponse -``` - -Methods: - -- client.logs.received.get(\*, zone_id, \*\*params) -> ReceivedGetResponse - -### Fields - -Types: - -```python -from cloudflare.types.logs.received import FieldGetResponse -``` - -Methods: - -- client.logs.received.fields.get(\*, zone_id) -> FieldGetResponse - -# OriginTLSClientAuth - -Types: - -```python -from cloudflare.types.origin_tls_client_auth import ( - OriginTLSClientAuthCreateResponse, - OriginTLSClientAuthListResponse, - OriginTLSClientAuthDeleteResponse, - OriginTLSClientAuthGetResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.origin_tls_client_auth import AuthenticatedOriginPull, HostnameUpdateResponse -``` - -Methods: - -- client.origin_tls_client_auth.hostnames.update(\*, zone_id, \*\*params) -> SyncSinglePage[HostnameUpdateResponse] -- client.origin_tls_client_auth.hostnames.get(hostname, \*, zone_id) -> Optional[AuthenticatedOriginPull] - -## HostnameCertificates - -Types: - -```python -from cloudflare.types.origin_tls_client_auth import ( - Certificate, - HostnameCertificateCreateResponse, - HostnameCertificateListResponse, - HostnameCertificateDeleteResponse, - HostnameCertificateGetResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.origin_tls_client_auth import SettingUpdateResponse, SettingGetResponse -``` - -Methods: - -- client.origin_tls_client_auth.settings.update(\*, zone_id, \*\*params) -> Optional[SettingUpdateResponse] -- client.origin_tls_client_auth.settings.get(\*, zone_id) -> Optional[SettingGetResponse] - -# PageRules - -Types: - -```python -from cloudflare.types.page_rules import ( - PageRule, - Target, - PageRuleListResponse, - PageRuleDeleteResponse, -) -``` - -Methods: - -- 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] - -# RateLimits - -Types: - -```python -from cloudflare.types.rate_limits import Action, RateLimit, RateLimitDeleteResponse -``` - -Methods: - -- 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 - -# 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.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 - -Types: - -```python -from cloudflare.types.waiting_rooms import PagePreviewResponse -``` - -Methods: - -- client.waiting_rooms.page.preview(\*, zone_id, \*\*params) -> PagePreviewResponse - -## Events - -Types: - -```python -from cloudflare.types.waiting_rooms import Event, EventDeleteResponse -``` - -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) -> 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 - -### Details - -Types: - -```python -from cloudflare.types.waiting_rooms.events import EventQuery, DetailGetResponse -``` - -Methods: - -- client.waiting_rooms.events.details.get(event_id, \*, zone_id, waiting_room_id) -> DetailGetResponse - -## Rules - -Types: - -```python -from cloudflare.types.waiting_rooms import WaitingRoomRule -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.waiting_rooms import StatusGetResponse -``` - -Methods: - -- client.waiting_rooms.statuses.get(waiting_room_id, \*, zone_id) -> StatusGetResponse - -## Settings - -Types: - -```python -from cloudflare.types.waiting_rooms import ( - Setting, - SettingUpdateResponse, - SettingEditResponse, - SettingGetResponse, -) -``` - -Methods: - -- client.waiting_rooms.settings.update(\*, zone_id, \*\*params) -> SettingUpdateResponse -- client.waiting_rooms.settings.edit(\*, zone_id, \*\*params) -> SettingEditResponse -- client.waiting_rooms.settings.get(\*, zone_id) -> SettingGetResponse - -# Web3 - -## Hostnames - -Types: - -```python -from cloudflare.types.web3 import Hostname, HostnameDeleteResponse -``` - -Methods: - -- 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 - -#### ContentLists - -Types: - -```python -from cloudflare.types.web3.hostnames.ipfs_universal_paths import ContentList -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.web3.hostnames.ipfs_universal_paths.content_lists import ( - EntryCreateResponse, - EntryUpdateResponse, - EntryListResponse, - EntryDeleteResponse, - EntryGetResponse, -) -``` - -Methods: - -- 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 ( - RouteCreateResponse, - RouteUpdateResponse, - RouteListResponse, - RouteDeleteResponse, - RouteGetResponse, -) -``` - -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 ( - Script, - ScriptSetting, - ScriptUpdateResponse, - ScriptListResponse, - ScriptGetResponse, - ScriptSearchResponse, -) -``` - -Methods: - -- 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 - -### Assets - -#### Upload - -Types: - -```python -from cloudflare.types.workers.scripts.assets import UploadCreateResponse -``` - -Methods: - -- client.workers.scripts.assets.upload.create(script_name, \*, account_id, \*\*params) -> Optional[UploadCreateResponse] - -### Subdomain - -Types: - -```python -from cloudflare.types.workers.scripts import ( - SubdomainCreateResponse, - SubdomainDeleteResponse, - SubdomainGetResponse, -) -``` - -Methods: - -- 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 ScheduleUpdateResponse, ScheduleGetResponse -``` - -Methods: - -- client.workers.scripts.schedules.update(script_name, \*, account_id, \*\*params) -> ScheduleUpdateResponse -- client.workers.scripts.schedules.get(script_name, \*, account_id) -> ScheduleGetResponse - -### Tail - -Types: - -```python -from cloudflare.types.workers.scripts import ( - ConsumerScript, - TailCreateResponse, - TailDeleteResponse, - TailGetResponse, -) -``` - -Methods: - -- 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) -> TailGetResponse - -### Content - -Methods: - -- 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) -> ScriptSetting -- client.workers.scripts.settings.get(script_name, \*, account_id) -> ScriptSetting - -### Deployments - -Types: - -```python -from cloudflare.types.workers.scripts import ( - Deployment, - DeploymentListResponse, - DeploymentDeleteResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.workers.scripts import ( - VersionCreateResponse, - VersionListResponse, - VersionGetResponse, -) -``` - -Methods: - -- 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) -> 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 - -Types: - -```python -from cloudflare.types.workers import AccountSettingUpdateResponse, AccountSettingGetResponse -``` - -Methods: - -- client.workers.account_settings.update(\*, account_id, \*\*params) -> AccountSettingUpdateResponse -- client.workers.account_settings.get(\*, account_id) -> AccountSettingGetResponse - -## Domains - -Types: - -```python -from cloudflare.types.workers import ( - DomainUpdateResponse, - DomainListResponse, - DomainDeleteResponse, - DomainGetResponse, -) -``` - -Methods: - -- client.workers.domains.update(\*, account_id, \*\*params) -> DomainUpdateResponse -- client.workers.domains.list(\*, account_id, \*\*params) -> SyncSinglePage[DomainListResponse] -- client.workers.domains.delete(domain_id, \*, account_id) -> DomainDeleteResponse -- client.workers.domains.get(domain_id, \*, account_id) -> DomainGetResponse - -## Subdomains - -Types: - -```python -from cloudflare.types.workers import SubdomainUpdateResponse, SubdomainGetResponse -``` - -Methods: - -- client.workers.subdomains.update(\*, account_id, \*\*params) -> SubdomainUpdateResponse -- client.workers.subdomains.delete(\*, account_id) -> None -- client.workers.subdomains.get(\*, account_id) -> SubdomainGetResponse - -## Observability - -### Telemetry - -Types: - -```python -from cloudflare.types.workers.observability import ( - TelemetryKeysResponse, - TelemetryQueryResponse, - TelemetryValuesResponse, -) -``` - -Methods: - -- 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] - -### Destinations - -Types: - -```python -from cloudflare.types.workers.observability import ( - DestinationCreateResponse, - DestinationUpdateResponse, - DestinationListResponse, - DestinationDeleteResponse, -) -``` - -Methods: - -- client.workers.observability.destinations.create(\*, account_id, \*\*params) -> DestinationCreateResponse -- client.workers.observability.destinations.update(slug, \*, account_id, \*\*params) -> DestinationUpdateResponse -- client.workers.observability.destinations.list(\*, account_id, \*\*params) -> SyncSinglePage[DestinationListResponse] -- client.workers.observability.destinations.delete(slug, \*, account_id) -> Optional[DestinationDeleteResponse] - -# KV - -## Namespaces - -Types: - -```python -from cloudflare.types.kv import ( - Namespace, - NamespaceDeleteResponse, - NamespaceBulkDeleteResponse, - NamespaceBulkGetResponse, - NamespaceBulkUpdateResponse, -) -``` - -Methods: - -- 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, - 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 - -Methods: - -- client.kv.namespaces.metadata.get(key_name, \*, account_id, namespace_id) -> object - -### Values - -Types: - -```python -from cloudflare.types.kv.namespaces import ValueUpdateResponse, ValueDeleteResponse -``` - -Methods: - -- 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 - -## Namespaces - -Types: - -```python -from cloudflare.types.durable_objects import Namespace -``` - -Methods: - -- client.durable_objects.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Namespace] - -### Objects - -Types: - -```python -from cloudflare.types.durable_objects.namespaces import DurableObject -``` - -Methods: - -- client.durable_objects.namespaces.objects.list(id, \*, account_id, \*\*params) -> SyncCursorPaginationAfter[DurableObject] - -# Queues - -Types: - -```python -from cloudflare.types.queues import Queue, QueueDeleteResponse -``` - -Methods: - -- 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) -> QueueDeleteResponse -- client.queues.edit(queue_id, \*, account_id, \*\*params) -> Optional[Queue] -- client.queues.get(queue_id, \*, account_id) -> Optional[Queue] - -## Messages - -Types: - -```python -from cloudflare.types.queues import ( - MessageAckResponse, - MessageBulkPushResponse, - MessagePullResponse, - MessagePushResponse, -) -``` - -Methods: - -- 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 - -## 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 ( - SubscriptionCreateResponse, - SubscriptionUpdateResponse, - SubscriptionListResponse, - SubscriptionDeleteResponse, - SubscriptionGetResponse, -) -``` - -Methods: - -- 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 - -## Configurations - -Types: - -```python -from cloudflare.types.api_gateway import Configuration -``` - -Methods: - -- client.api_gateway.configurations.update(\*, zone_id, \*\*params) -> Configuration -- client.api_gateway.configurations.get(\*, zone_id, \*\*params) -> Configuration - -## Discovery - -Types: - -```python -from cloudflare.types.api_gateway import DiscoveryOperation, DiscoveryGetResponse -``` - -Methods: - -- client.api_gateway.discovery.get(\*, zone_id) -> DiscoveryGetResponse - -### Operations - -Types: - -```python -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 - -## Labels - -Types: - -```python -from cloudflare.types.api_gateway import LabelListResponse -``` - -Methods: - -- client.api_gateway.labels.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[LabelListResponse] - -### User - -Types: - -```python -from cloudflare.types.api_gateway.labels import ( - UserUpdateResponse, - UserDeleteResponse, - UserBulkCreateResponse, - UserBulkDeleteResponse, - UserEditResponse, - UserGetResponse, -) -``` - -Methods: - -- client.api_gateway.labels.user.update(name, \*, zone_id, \*\*params) -> UserUpdateResponse -- client.api_gateway.labels.user.delete(name, \*, zone_id) -> UserDeleteResponse -- client.api_gateway.labels.user.bulk_create(\*, zone_id, \*\*params) -> SyncSinglePage[UserBulkCreateResponse] -- client.api_gateway.labels.user.bulk_delete(\*, zone_id) -> SyncSinglePage[UserBulkDeleteResponse] -- client.api_gateway.labels.user.edit(name, \*, zone_id, \*\*params) -> UserEditResponse -- client.api_gateway.labels.user.get(name, \*, zone_id, \*\*params) -> UserGetResponse - -#### Resources - -##### Operation - -Types: - -```python -from cloudflare.types.api_gateway.labels.user.resources import OperationUpdateResponse -``` - -Methods: - -- client.api_gateway.labels.user.resources.operation.update(name, \*, zone_id, \*\*params) -> OperationUpdateResponse - -### Managed - -Types: - -```python -from cloudflare.types.api_gateway.labels import ManagedGetResponse -``` - -Methods: - -- client.api_gateway.labels.managed.get(name, \*, zone_id, \*\*params) -> ManagedGetResponse - -#### Resources - -##### Operation - -Types: - -```python -from cloudflare.types.api_gateway.labels.managed.resources import OperationUpdateResponse -``` - -Methods: - -- client.api_gateway.labels.managed.resources.operation.update(name, \*, zone_id, \*\*params) -> OperationUpdateResponse - -## Operations - -Types: - -```python -from cloudflare.types.api_gateway import ( - APIShield, - OperationCreateResponse, - OperationListResponse, - OperationDeleteResponse, - OperationBulkCreateResponse, - OperationBulkDeleteResponse, - OperationGetResponse, -) -``` - -Methods: - -- 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 - -### Labels - -Types: - -```python -from cloudflare.types.api_gateway.operations import ( - LabelCreateResponse, - LabelUpdateResponse, - LabelDeleteResponse, - LabelBulkCreateResponse, - LabelBulkDeleteResponse, - LabelBulkUpdateResponse, -) -``` - -Methods: - -- client.api_gateway.operations.labels.create(operation_id, \*, zone_id, \*\*params) -> LabelCreateResponse -- client.api_gateway.operations.labels.update(operation_id, \*, zone_id, \*\*params) -> LabelUpdateResponse -- client.api_gateway.operations.labels.delete(operation_id, \*, zone_id) -> LabelDeleteResponse -- client.api_gateway.operations.labels.bulk_create(\*, zone_id, \*\*params) -> SyncSinglePage[LabelBulkCreateResponse] -- client.api_gateway.operations.labels.bulk_delete(\*, zone_id) -> SyncSinglePage[LabelBulkDeleteResponse] -- client.api_gateway.operations.labels.bulk_update(\*, zone_id, \*\*params) -> SyncSinglePage[LabelBulkUpdateResponse] - -### SchemaValidation - -Types: - -```python -from cloudflare.types.api_gateway.operations import ( - SettingsMultipleRequest, - SchemaValidationUpdateResponse, - SchemaValidationGetResponse, -) -``` - -Methods: - -- client.api_gateway.operations.schema_validation.update(operation_id, \*, zone_id, \*\*params) -> SchemaValidationUpdateResponse -- client.api_gateway.operations.schema_validation.edit(\*, zone_id, \*\*params) -> SettingsMultipleRequest -- client.api_gateway.operations.schema_validation.get(operation_id, \*, zone_id) -> SchemaValidationGetResponse - -## Schemas - -Types: - -```python -from cloudflare.types.api_gateway import SchemaListResponse -``` - -Methods: - -- client.api_gateway.schemas.list(\*, zone_id, \*\*params) -> SchemaListResponse - -## Settings - -Types: - -```python -from cloudflare.types.api_gateway import Settings -``` - -### SchemaValidation - -Methods: - -- client.api_gateway.settings.schema_validation.update(\*, zone_id, \*\*params) -> Settings -- client.api_gateway.settings.schema_validation.edit(\*, zone_id, \*\*params) -> Settings -- client.api_gateway.settings.schema_validation.get(\*, zone_id) -> Settings - -## UserSchemas - -Types: - -```python -from cloudflare.types.api_gateway import ( - Message, - OldPublicSchema, - UserSchemaCreateResponse, - UserSchemaDeleteResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.api_gateway.user_schemas import OperationListResponse -``` - -Methods: - -- client.api_gateway.user_schemas.operations.list(schema_id, \*, zone_id, \*\*params) -> SyncV4PagePaginationArray[OperationListResponse] - -### 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_transforms import ( - ManagedTransformListResponse, - ManagedTransformEditResponse, -) -``` - -Methods: - -- client.managed_transforms.list(\*, zone_id) -> ManagedTransformListResponse -- client.managed_transforms.delete(\*, zone_id) -> None -- client.managed_transforms.edit(\*, zone_id, \*\*params) -> ManagedTransformEditResponse - -# PageShield - -Types: - -```python -from cloudflare.types.page_shield import Setting, PageShieldUpdateResponse -``` - -Methods: - -- client.page_shield.update(\*, zone_id, \*\*params) -> Optional[PageShieldUpdateResponse] -- client.page_shield.get(\*, zone_id) -> Optional[Setting] - -## Policies - -Types: - -```python -from cloudflare.types.page_shield import ( - Policy, - PolicyCreateResponse, - PolicyUpdateResponse, - PolicyListResponse, - PolicyGetResponse, -) -``` - -Methods: - -- 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[PolicyGetResponse] - -## Connections - -Types: - -```python -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[Connection] - -## Scripts - -Types: - -```python -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[ScriptGetResponse] - -## Cookies - -Types: - -```python -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[CookieGetResponse] - -# Rulesets - -Types: - -```python -from cloudflare.types.rulesets import Kind, Phase, Ruleset -``` - -## Rules - -Types: - -```python -from cloudflare.types.rulesets import ( - BlockRule, - CompressResponseRule, - DDoSDynamicRule, - ExecuteRule, - ForceConnectionCloseRule, - LogCustomFieldRule, - LogRule, - Logging, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - RulesetRule, - ScoreRule, - ServeErrorRule, - SetCacheSettingsRule, - SetConfigRule, - SkipRule, -) -``` - -# URLNormalization - -Types: - -```python -from cloudflare.types.url_normalization import ( - URLNormalizationUpdateResponse, - URLNormalizationGetResponse, -) -``` - -Methods: - -- client.url_normalization.update(\*, zone_id, \*\*params) -> URLNormalizationUpdateResponse -- client.url_normalization.delete(\*, zone_id) -> None -- client.url_normalization.get(\*, zone_id) -> URLNormalizationGetResponse - -# Spectrum - -Types: - -```python -from cloudflare.types.spectrum import DNS, EdgeIPs, OriginDNS, OriginPort -``` - -## Analytics - -### Aggregates - -#### Currents - -Types: - -```python -from cloudflare.types.spectrum.analytics.aggregates import CurrentGetResponse -``` - -Methods: - -- client.spectrum.analytics.aggregates.currents.get(\*, zone_id, \*\*params) -> Optional[CurrentGetResponse] - -### Events - -Types: - -```python -from cloudflare.types.spectrum.analytics import Dimension -``` - -#### Bytimes - -Types: - -```python -from cloudflare.types.spectrum.analytics.events import BytimeGetResponse -``` - -Methods: - -- client.spectrum.analytics.events.bytimes.get(\*, zone_id, \*\*params) -> Optional[BytimeGetResponse] - -#### Summaries - -Types: - -```python -from cloudflare.types.spectrum.analytics.events import SummaryGetResponse -``` - -Methods: - -- client.spectrum.analytics.events.summaries.get(\*, zone_id, \*\*params) -> Optional[SummaryGetResponse] - -## Apps - -Types: - -```python -from cloudflare.types.spectrum import ( - AppCreateResponse, - AppUpdateResponse, - AppListResponse, - AppDeleteResponse, - AppGetResponse, -) -``` - -Methods: - -- 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 - -## RegionalHostnames - -Types: - -```python -from cloudflare.types.addressing import ( - RegionalHostnameCreateResponse, - RegionalHostnameListResponse, - RegionalHostnameDeleteResponse, - RegionalHostnameEditResponse, - RegionalHostnameGetResponse, -) -``` - -Methods: - -- 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[RegionalHostnameEditResponse] -- client.addressing.regional_hostnames.get(hostname, \*, zone_id) -> Optional[RegionalHostnameGetResponse] - -### Regions - -Types: - -```python -from cloudflare.types.addressing.regional_hostnames import RegionListResponse -``` - -Methods: - -- client.addressing.regional_hostnames.regions.list(\*, account_id) -> SyncSinglePage[RegionListResponse] - -## Services - -Types: - -```python -from cloudflare.types.addressing import ServiceListResponse -``` - -Methods: - -- client.addressing.services.list(\*, account_id) -> SyncSinglePage[ServiceListResponse] - -## AddressMaps - -Types: - -```python -from cloudflare.types.addressing import ( - AddressMap, - Kind, - AddressMapCreateResponse, - AddressMapDeleteResponse, - AddressMapGetResponse, -) -``` - -Methods: - -- 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) -> 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 - -Types: - -```python -from cloudflare.types.addressing.address_maps import AccountUpdateResponse, AccountDeleteResponse -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.addressing.address_maps import IPUpdateResponse, IPDeleteResponse -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.addressing.address_maps import ZoneUpdateResponse, ZoneDeleteResponse -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.addressing import LOADocumentCreateResponse -``` - -Methods: - -- client.addressing.loa_documents.create(\*, account_id, \*\*params) -> Optional[LOADocumentCreateResponse] -- client.addressing.loa_documents.get(loa_document_id, \*, account_id) -> BinaryAPIResponse - -## Prefixes - -Types: - -```python -from cloudflare.types.addressing import Prefix, PrefixDeleteResponse -``` - -Methods: - -- 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) -> PrefixDeleteResponse -- client.addressing.prefixes.edit(prefix_id, \*, account_id, \*\*params) -> Optional[Prefix] -- client.addressing.prefixes.get(prefix_id, \*, account_id) -> Optional[Prefix] - -### ServiceBindings - -Types: - -```python -from cloudflare.types.addressing.prefixes import ServiceBinding, ServiceBindingDeleteResponse -``` - -Methods: - -- 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] - -### BGPPrefixes - -Types: - -```python -from cloudflare.types.addressing.prefixes import BGPPrefix -``` - -Methods: - -- 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] - -### AdvertisementStatus - -Types: - -```python -from cloudflare.types.addressing.prefixes import ( - AdvertisementStatusEditResponse, - AdvertisementStatusGetResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.addressing.prefixes import Delegations, DelegationDeleteResponse -``` - -Methods: - -- 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[DelegationDeleteResponse] - -# AuditLogs - -Methods: - -- client.audit_logs.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[AuditLog] - -# Billing - -## Profiles - -Types: - -```python -from cloudflare.types.billing import ProfileGetResponse -``` - -Methods: - -- client.billing.profiles.get(\*, account_id) -> ProfileGetResponse - -## Usage - -Types: - -```python -from cloudflare.types.billing import UsagePaygoResponse -``` - -Methods: - -- client.billing.usage.paygo(\*, account_id, \*\*params) -> UsagePaygoResponse - -# BrandProtection - -Types: - -```python -from cloudflare.types.brand_protection import ( - Info, - Submit, - BrandProtectionSubmitResponse, - BrandProtectionURLInfoResponse, -) -``` - -Methods: - -- 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 - -## V2 - -### Queries - -Types: - -```python -from cloudflare.types.brand_protection.v2 import QueryGetResponse -``` - -Methods: - -- client.brand_protection.v2.queries.get(\*, account_id, \*\*params) -> QueryGetResponse - -### Matches - -Types: - -```python -from cloudflare.types.brand_protection.v2 import MatchGetResponse -``` - -Methods: - -- client.brand_protection.v2.matches.get(\*, account_id, \*\*params) -> MatchGetResponse - -### Logos - -Types: - -```python -from cloudflare.types.brand_protection.v2 import ( - LogoCreateResponse, - LogoDeleteResponse, - LogoGetResponse, -) -``` - -Methods: - -- client.brand_protection.v2.logos.create(\*, account_id, \*\*params) -> LogoCreateResponse -- client.brand_protection.v2.logos.delete(query_id, \*, account_id) -> LogoDeleteResponse -- client.brand_protection.v2.logos.get(\*, account_id, \*\*params) -> LogoGetResponse - -### LogoMatches - -Types: - -```python -from cloudflare.types.brand_protection.v2 import LogoMatchGetResponse -``` - -Methods: - -- client.brand_protection.v2.logo_matches.get(\*, account_id, \*\*params) -> LogoMatchGetResponse - -# Diagnostics - -## Traceroutes - -Types: - -```python -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.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 - -## V1 - -Types: - -```python -from cloudflare.types.images import Image, V1ListResponse, V1DeleteResponse -``` - -Methods: - -- client.images.v1.create(\*, account_id, \*\*params) -> Image -- client.images.v1.list(\*, account_id, \*\*params) -> SyncV4PagePagination[V1ListResponse] -- client.images.v1.delete(image_id, \*, account_id) -> V1DeleteResponse -- client.images.v1.edit(image_id, \*, account_id, \*\*params) -> Image -- client.images.v1.get(image_id, \*, account_id) -> Image - -### Keys - -Types: - -```python -from cloudflare.types.images.v1 import Key, KeyUpdateResponse, KeyListResponse, KeyDeleteResponse -``` - -Methods: - -- client.images.v1.keys.update(signing_key_name, \*, account_id) -> KeyUpdateResponse -- client.images.v1.keys.list(\*, account_id) -> KeyListResponse -- client.images.v1.keys.delete(signing_key_name, \*, account_id) -> KeyDeleteResponse - -### Stats - -Types: - -```python -from cloudflare.types.images.v1 import Stat -``` - -Methods: - -- client.images.v1.stats.get(\*, account_id) -> Stat - -### Variants - -Types: - -```python -from cloudflare.types.images.v1 import ( - Variant, - VariantCreateResponse, - VariantDeleteResponse, - VariantEditResponse, - VariantGetResponse, -) -``` - -Methods: - -- client.images.v1.variants.create(\*, account_id, \*\*params) -> VariantCreateResponse -- client.images.v1.variants.list(\*, account_id) -> Variant -- client.images.v1.variants.delete(variant_id, \*, account_id) -> VariantDeleteResponse -- client.images.v1.variants.edit(variant_id, \*, account_id, \*\*params) -> VariantEditResponse -- client.images.v1.variants.get(variant_id, \*, account_id) -> VariantGetResponse - -### Blobs - -Methods: - -- client.images.v1.blobs.get(image_id, \*, account_id) -> BinaryAPIResponse - -## V2 - -Types: - -```python -from cloudflare.types.images import V2ListResponse -``` - -Methods: - -- client.images.v2.list(\*, account_id, \*\*params) -> V2ListResponse - -### DirectUploads - -Types: - -```python -from cloudflare.types.images.v2 import DirectUploadCreateResponse -``` - -Methods: - -- client.images.v2.direct_uploads.create(\*, account_id, \*\*params) -> DirectUploadCreateResponse - -# Intel - -## ASN - -Methods: - -- client.intel.asn.get(asn, \*, account_id) -> Optional[ASN] - -### Subnets - -Types: - -```python -from cloudflare.types.intel.asn import SubnetGetResponse -``` - -Methods: - -- client.intel.asn.subnets.get(asn, \*, account_id) -> SubnetGetResponse - -## DNS - -Types: - -```python -from cloudflare.types.intel import DNS -``` - -Methods: - -- client.intel.dns.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[DNS]] - -## Domains - -Types: - -```python -from cloudflare.types.intel import Domain -``` - -Methods: - -- client.intel.domains.get(\*, account_id, \*\*params) -> Optional[Domain] - -### Bulks - -Types: - -```python -from cloudflare.types.intel.domains import BulkGetResponse -``` - -Methods: - -- client.intel.domains.bulks.get(\*, account_id, \*\*params) -> Optional[BulkGetResponse] - -## DomainHistory - -Types: - -```python -from cloudflare.types.intel import DomainHistory, DomainHistoryGetResponse -``` - -Methods: - -- client.intel.domain_history.get(\*, account_id, \*\*params) -> Optional[DomainHistoryGetResponse] - -## IPs - -Types: - -```python -from cloudflare.types.intel import IP, IPGetResponse -``` - -Methods: - -- client.intel.ips.get(\*, account_id, \*\*params) -> Optional[IPGetResponse] - -## IPLists - -Types: - -```python -from cloudflare.types.intel import IPList -``` - -## Miscategorizations - -Types: - -```python -from cloudflare.types.intel import MiscategorizationCreateResponse -``` - -Methods: - -- client.intel.miscategorizations.create(\*, account_id, \*\*params) -> MiscategorizationCreateResponse - -## Whois - -Types: - -```python -from cloudflare.types.intel import Whois, WhoisGetResponse -``` - -Methods: - -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional[WhoisGetResponse] - -## IndicatorFeeds - -Types: - -```python -from cloudflare.types.intel import ( - IndicatorFeedCreateResponse, - IndicatorFeedUpdateResponse, - IndicatorFeedListResponse, - IndicatorFeedDataResponse, - IndicatorFeedGetResponse, -) -``` - -Methods: - -- 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[IndicatorFeedGetResponse] - -### Snapshots - -Types: - -```python -from cloudflare.types.intel.indicator_feeds import SnapshotUpdateResponse -``` - -Methods: - -- client.intel.indicator_feeds.snapshots.update(feed_id, \*, account_id, \*\*params) -> Optional[SnapshotUpdateResponse] - -### Permissions - -Types: - -```python -from cloudflare.types.intel.indicator_feeds import ( - PermissionCreateResponse, - PermissionListResponse, - PermissionDeleteResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.intel import Sinkhole -``` - -Methods: - -- client.intel.sinkholes.list(\*, account_id) -> SyncSinglePage[Sinkhole] - -## AttackSurfaceReport - -### IssueTypes - -Types: - -```python -from cloudflare.types.intel.attack_surface_report import IssueTypeGetResponse -``` - -Methods: - -- client.intel.attack_surface_report.issue_types.get(\*, account_id) -> SyncSinglePage[IssueTypeGetResponse] - -### Issues - -Types: - -```python -from cloudflare.types.intel.attack_surface_report import ( - IssueType, - SeverityQueryParam, - IssueListResponse, - IssueClassResponse, - IssueDismissResponse, - IssueSeverityResponse, - IssueTypeResponse, -) -``` - -Methods: - -- 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 - -Types: - -```python -from cloudflare.types.magic_transit import HealthCheck, HealthCheckRate, HealthCheckType -``` - -## Apps - -Types: - -```python -from cloudflare.types.magic_transit import ( - AppCreateResponse, - AppUpdateResponse, - AppListResponse, - AppDeleteResponse, - AppEditResponse, -) -``` - -Methods: - -- 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[AppDeleteResponse] -- client.magic_transit.apps.edit(account_app_id, \*, account_id, \*\*params) -> Optional[AppEditResponse] - -## CfInterconnects - -Types: - -```python -from cloudflare.types.magic_transit import ( - CfInterconnectUpdateResponse, - CfInterconnectListResponse, - CfInterconnectBulkUpdateResponse, - CfInterconnectGetResponse, -) -``` - -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 - -Types: - -```python -from cloudflare.types.magic_transit import ( - GRETunnelCreateResponse, - GRETunnelUpdateResponse, - GRETunnelListResponse, - GRETunnelDeleteResponse, - GRETunnelBulkUpdateResponse, - GRETunnelGetResponse, -) -``` - -Methods: - -- client.magic_transit.gre_tunnels.create(\*, account_id, \*\*params) -> GRETunnelCreateResponse -- 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 - -Types: - -```python -from cloudflare.types.magic_transit import ( - PSKMetadata, - IPSECTunnelCreateResponse, - IPSECTunnelUpdateResponse, - IPSECTunnelListResponse, - IPSECTunnelDeleteResponse, - IPSECTunnelBulkUpdateResponse, - IPSECTunnelGetResponse, - IPSECTunnelPSKGenerateResponse, -) -``` - -Methods: - -- client.magic_transit.ipsec_tunnels.create(\*, account_id, \*\*params) -> IPSECTunnelCreateResponse -- 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 - -## Routes - -Types: - -```python -from cloudflare.types.magic_transit import ( - Scope, - RouteCreateResponse, - RouteUpdateResponse, - RouteListResponse, - RouteDeleteResponse, - RouteBulkUpdateResponse, - RouteEmptyResponse, - RouteGetResponse, -) -``` - -Methods: - -- client.magic_transit.routes.create(\*, account_id, \*\*params) -> RouteCreateResponse -- 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 - -## Sites - -Types: - -```python -from cloudflare.types.magic_transit import Site, SiteLocation -``` - -Methods: - -- client.magic_transit.sites.create(\*, account_id, \*\*params) -> Site -- client.magic_transit.sites.update(site_id, \*, account_id, \*\*params) -> Site -- client.magic_transit.sites.list(\*, account_id, \*\*params) -> SyncSinglePage[Site] -- client.magic_transit.sites.delete(site_id, \*, account_id) -> Site -- client.magic_transit.sites.edit(site_id, \*, account_id, \*\*params) -> Site -- client.magic_transit.sites.get(site_id, \*, account_id) -> Site - -### ACLs - -Types: - -```python -from cloudflare.types.magic_transit.sites import ACL, ACLConfiguration, AllowedProtocol, Subnet -``` - -Methods: - -- client.magic_transit.sites.acls.create(site_id, \*, account_id, \*\*params) -> ACL -- client.magic_transit.sites.acls.update(acl_id, \*, account_id, site_id, \*\*params) -> ACL -- client.magic_transit.sites.acls.list(site_id, \*, account_id) -> SyncSinglePage[ACL] -- client.magic_transit.sites.acls.delete(acl_id, \*, account_id, site_id) -> ACL -- client.magic_transit.sites.acls.edit(acl_id, \*, account_id, site_id, \*\*params) -> ACL -- client.magic_transit.sites.acls.get(acl_id, \*, account_id, site_id) -> ACL - -### LANs - -Types: - -```python -from cloudflare.types.magic_transit.sites import ( - DHCPRelay, - DHCPServer, - LAN, - LANStaticAddressing, - Nat, - RoutedSubnet, -) -``` - -Methods: - -- 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 -- client.magic_transit.sites.lans.edit(lan_id, \*, account_id, site_id, \*\*params) -> LAN -- client.magic_transit.sites.lans.get(lan_id, \*, account_id, site_id) -> LAN - -### WANs - -Types: - -```python -from cloudflare.types.magic_transit.sites import WAN, WANStaticAddressing -``` - -Methods: - -- 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 -- client.magic_transit.sites.wans.edit(wan_id, \*, account_id, site_id, \*\*params) -> WAN -- client.magic_transit.sites.wans.get(wan_id, \*, account_id, site_id) -> WAN - -## Connectors - -Types: - -```python -from cloudflare.types.magic_transit import ( - ConnectorCreateResponse, - ConnectorUpdateResponse, - ConnectorListResponse, - ConnectorDeleteResponse, - ConnectorEditResponse, - ConnectorGetResponse, -) -``` - -Methods: - -- 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 - -### Events - -Types: - -```python -from cloudflare.types.magic_transit.connectors import EventListResponse, EventGetResponse -``` - -Methods: - -- 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 - -#### Latest - -Types: - -```python -from cloudflare.types.magic_transit.connectors.events import LatestListResponse -``` - -Methods: - -- client.magic_transit.connectors.events.latest.list(connector_id, \*, account_id) -> LatestListResponse - -### Snapshots - -Types: - -```python -from cloudflare.types.magic_transit.connectors import SnapshotListResponse, SnapshotGetResponse -``` - -Methods: - -- 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 - -#### Latest - -Types: - -```python -from cloudflare.types.magic_transit.connectors.snapshots import LatestListResponse -``` - -Methods: - -- client.magic_transit.connectors.snapshots.latest.list(connector_id, \*, account_id) -> LatestListResponse - -## PCAPs - -Types: - -```python -from cloudflare.types.magic_transit import ( - PCAP, - PCAPFilter, - PCAPCreateResponse, - PCAPListResponse, - PCAPGetResponse, -) -``` - -Methods: - -- 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 - -### Ownership - -Types: - -```python -from cloudflare.types.magic_transit.pcaps import Ownership -``` - -Methods: - -- 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 - -### Download - -Methods: - -- client.magic_transit.pcaps.download.get(pcap_id, \*, account_id) -> BinaryAPIResponse - -# MagicNetworkMonitoring - -## VPCFlows - -### Tokens - -Types: - -```python -from cloudflare.types.magic_network_monitoring.vpc_flows import TokenCreateResponse -``` - -Methods: - -- client.magic_network_monitoring.vpc_flows.tokens.create(\*, account_id) -> str - -## Configs - -Types: - -```python -from cloudflare.types.magic_network_monitoring import Configuration -``` - -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 - -### Full - -Methods: - -- client.magic_network_monitoring.configs.full.get(\*, account_id) -> Configuration - -## Rules - -Types: - -```python -from cloudflare.types.magic_network_monitoring import MagicNetworkMonitoringRule -``` - -Methods: - -- 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] - -### Advertisements - -Types: - -```python -from cloudflare.types.magic_network_monitoring.rules import Advertisement -``` - -Methods: - -- client.magic_network_monitoring.rules.advertisements.edit(rule_id, \*, account_id, \*\*params) -> Optional[Advertisement] - -# MagicCloudNetworking - -## CatalogSyncs - -Types: - -```python -from cloudflare.types.magic_cloud_networking import ( - CatalogSyncCreateResponse, - CatalogSyncUpdateResponse, - CatalogSyncListResponse, - CatalogSyncDeleteResponse, - CatalogSyncEditResponse, - CatalogSyncGetResponse, - CatalogSyncRefreshResponse, -) -``` - -Methods: - -- 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 - -### PrebuiltPolicies - -Types: - -```python -from cloudflare.types.magic_cloud_networking.catalog_syncs import PrebuiltPolicyListResponse -``` - -Methods: - -- client.magic_cloud_networking.catalog_syncs.prebuilt_policies.list(\*, account_id, \*\*params) -> SyncSinglePage[PrebuiltPolicyListResponse] - -## OnRamps - -Types: - -```python -from cloudflare.types.magic_cloud_networking import ( - OnRampCreateResponse, - OnRampUpdateResponse, - OnRampListResponse, - OnRampDeleteResponse, - OnRampApplyResponse, - OnRampEditResponse, - OnRampGetResponse, - OnRampPlanResponse, -) -``` - -Methods: - -- 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 - -### AddressSpaces - -Types: - -```python -from cloudflare.types.magic_cloud_networking.on_ramps import ( - AddressSpaceUpdateResponse, - AddressSpaceListResponse, - AddressSpaceEditResponse, -) -``` - -Methods: - -- 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 - -## CloudIntegrations - -Types: - -```python -from cloudflare.types.magic_cloud_networking import ( - CloudIntegrationCreateResponse, - CloudIntegrationUpdateResponse, - CloudIntegrationListResponse, - CloudIntegrationDeleteResponse, - CloudIntegrationDiscoverResponse, - CloudIntegrationDiscoverAllResponse, - CloudIntegrationEditResponse, - CloudIntegrationGetResponse, - CloudIntegrationInitialSetupResponse, -) -``` - -Methods: - -- 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 - -## Resources - -Types: - -```python -from cloudflare.types.magic_cloud_networking import ( - ResourceListResponse, - ResourceGetResponse, - ResourcePolicyPreviewResponse, -) -``` - -Methods: - -- 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 - -# NetworkInterconnects - -## CNIs - -Types: - -```python -from cloudflare.types.network_interconnects import ( - CNICreateResponse, - CNIUpdateResponse, - CNIListResponse, - CNIGetResponse, -) -``` - -Methods: - -- 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 - -## Interconnects - -Types: - -```python -from cloudflare.types.network_interconnects import ( - InterconnectCreateResponse, - InterconnectListResponse, - InterconnectGetResponse, - InterconnectStatusResponse, -) -``` - -Methods: - -- 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 - -## Settings - -Types: - -```python -from cloudflare.types.network_interconnects import SettingUpdateResponse, SettingGetResponse -``` - -Methods: - -- client.network_interconnects.settings.update(\*, account_id, \*\*params) -> SettingUpdateResponse -- client.network_interconnects.settings.get(\*, account_id) -> SettingGetResponse - -## Slots - -Types: - -```python -from cloudflare.types.network_interconnects import SlotListResponse, SlotGetResponse -``` - -Methods: - -- client.network_interconnects.slots.list(\*, account_id, \*\*params) -> SlotListResponse -- client.network_interconnects.slots.get(slot, \*, account_id) -> SlotGetResponse - -# MTLSCertificates - -Types: - -```python -from cloudflare.types.mtls_certificates import MTLSCertificate, MTLSCertificateCreateResponse -``` - -Methods: - -- client.mtls_certificates.create(\*, account_id, \*\*params) -> Optional[MTLSCertificateCreateResponse] -- client.mtls_certificates.list(\*, account_id, \*\*params) -> SyncSinglePage[MTLSCertificate] -- client.mtls_certificates.delete(mtls_certificate_id, \*, account_id) -> Optional[MTLSCertificate] -- client.mtls_certificates.get(mtls_certificate_id, \*, account_id) -> Optional[MTLSCertificate] - -## Associations - -Types: - -```python -from cloudflare.types.mtls_certificates import CertificateAsssociation -``` - -Methods: - -- client.mtls_certificates.associations.get(mtls_certificate_id, \*, account_id) -> SyncSinglePage[CertificateAsssociation] - -# Pages - -## Projects - -Types: - -```python -from cloudflare.types.pages import Deployment, Project, Stage -``` - -Methods: - -- 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 - -### Deployments - -Methods: - -- 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 - -#### History - -##### Logs - -Types: - -```python -from cloudflare.types.pages.projects.deployments.history import LogGetResponse -``` - -Methods: - -- client.pages.projects.deployments.history.logs.get(deployment_id, \*, account_id, project_name) -> LogGetResponse - -### Domains - -Types: - -```python -from cloudflare.types.pages.projects import ( - DomainCreateResponse, - DomainListResponse, - DomainEditResponse, - DomainGetResponse, -) -``` - -Methods: - -- 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 - -# Registrar - -Types: - -```python -from cloudflare.types.registrar import ( - Registration, - WorkflowStatus, - RegistrarCheckResponse, - RegistrarSearchResponse, -) -``` - -Methods: - -- client.registrar.check(\*, account_id, \*\*params) -> RegistrarCheckResponse -- client.registrar.search(\*, account_id, \*\*params) -> RegistrarSearchResponse - -## Domains - -Types: - -```python -from cloudflare.types.registrar import Domain -``` - -Methods: - -- 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 - -## Registrations - -Methods: - -- client.registrar.registrations.create(\*, account_id, \*\*params) -> WorkflowStatus -- client.registrar.registrations.edit(domain_name, \*, account_id, \*\*params) -> WorkflowStatus -- client.registrar.registrations.get(domain_name, \*, account_id) -> Registration - -## RegistrationStatus - -Methods: - -- client.registrar.registration_status.get(domain_name, \*, account_id) -> WorkflowStatus - -## UpdateStatus - -Methods: - -- client.registrar.update_status.get(domain_name, \*, account_id) -> WorkflowStatus - -# RequestTracers - -## Traces - -Types: - -```python -from cloudflare.types.request_tracers import Trace, TraceItem, TraceCreateResponse -``` - -Methods: - -- client.request_tracers.traces.create(\*, account_id, \*\*params) -> Optional[TraceCreateResponse] - -# Rules - -## Lists - -Types: - -```python -from cloudflare.types.rules import ( - Hostname, - ListsList, - Redirect, - ListCreateResponse, - ListUpdateResponse, - ListDeleteResponse, - ListGetResponse, -) -``` - -Methods: - -- 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 - -### BulkOperations - -Types: - -```python -from cloudflare.types.rules.lists import BulkOperationGetResponse -``` - -Methods: - -- client.rules.lists.bulk_operations.get(operation_id, \*, account_id) -> BulkOperationGetResponse - -### Items - -Types: - -```python -from cloudflare.types.rules.lists import ( - ListCursor, - ListItem, - ItemCreateResponse, - ItemUpdateResponse, - ItemListResponse, - ItemDeleteResponse, - ItemGetResponse, -) -``` - -Methods: - -- 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 - -# Stream - -Types: - -```python -from cloudflare.types.stream import AllowedOrigins, Video -``` - -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.edit(identifier, \*, account_id, \*\*params) -> Optional[Video] -- client.stream.get(identifier, \*, account_id) -> Optional[Video] - -## AudioTracks - -Types: - -```python -from cloudflare.types.stream import Audio, AudioTrackDeleteResponse, AudioTrackGetResponse -``` - -Methods: - -- 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) -> Optional[AudioTrackGetResponse] - -## 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[Video] - -## 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 WebhookUpdateResponse, WebhookDeleteResponse, WebhookGetResponse -``` - -Methods: - -- client.stream.webhooks.update(\*, account_id, \*\*params) -> Optional[WebhookUpdateResponse] -- client.stream.webhooks.delete(\*, account_id) -> str -- client.stream.webhooks.get(\*, account_id) -> Optional[WebhookGetResponse] - -## 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 - -Types: - -```python -from cloudflare.types.stream import ( - DownloadCreateResponse, - DownloadDeleteResponse, - DownloadGetResponse, -) -``` - -Methods: - -- client.stream.downloads.create(identifier, \*, account_id) -> Optional[DownloadCreateResponse] -- client.stream.downloads.delete(identifier, \*, account_id) -> str -- client.stream.downloads.get(identifier, \*, account_id) -> Optional[DownloadGetResponse] - -## Embed - -Types: - -```python -from cloudflare.types.stream import EmbedGetResponse -``` - -Methods: - -- client.stream.embed.get(identifier, \*, account_id) -> str - -## Token - -Types: - -```python -from cloudflare.types.stream import TokenCreateResponse -``` - -Methods: - -- client.stream.token.create(identifier, \*, account_id, \*\*params) -> Optional[TokenCreateResponse] - -# Alerting - -## AvailableAlerts - -Types: - -```python -from cloudflare.types.alerting import AvailableAlertListResponse -``` - -Methods: - -- client.alerting.available_alerts.list(\*, account_id) -> Optional[AvailableAlertListResponse] - -## Destinations - -### Eligible - -Types: - -```python -from cloudflare.types.alerting.destinations import EligibleGetResponse -``` - -Methods: - -- client.alerting.destinations.eligible.get(\*, account_id) -> Optional[EligibleGetResponse] - -### Pagerduty - -Types: - -```python -from cloudflare.types.alerting.destinations import ( - Pagerduty, - PagerdutyCreateResponse, - PagerdutyDeleteResponse, - PagerdutyLinkResponse, -) -``` - -Methods: - -- client.alerting.destinations.pagerduty.create(\*, account_id) -> Optional[PagerdutyCreateResponse] -- client.alerting.destinations.pagerduty.delete(\*, account_id) -> PagerdutyDeleteResponse -- client.alerting.destinations.pagerduty.get(\*, account_id) -> SyncSinglePage[Pagerduty] -- client.alerting.destinations.pagerduty.link(token_id, \*, account_id) -> Optional[PagerdutyLinkResponse] - -### Webhooks - -Types: - -```python -from cloudflare.types.alerting.destinations import ( - Webhooks, - WebhookCreateResponse, - WebhookUpdateResponse, - WebhookDeleteResponse, -) -``` - -Methods: - -- 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[Webhooks] - -## History - -Types: - -```python -from cloudflare.types.alerting import History -``` - -Methods: - -- client.alerting.history.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[History] - -## Policies - -Types: - -```python -from cloudflare.types.alerting import ( - Mechanism, - Policy, - PolicyFilter, - PolicyCreateResponse, - PolicyUpdateResponse, - PolicyDeleteResponse, -) -``` - -Methods: - -- 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[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 - -Types: - -```python -from cloudflare.types.d1 import D1 -``` - -## Database - -Types: - -```python -from cloudflare.types.d1 import ( - QueryResult, - DatabaseListResponse, - DatabaseExportResponse, - DatabaseImportResponse, - DatabaseRawResponse, -) -``` - -Methods: - -- 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] - -### TimeTravel - -Types: - -```python -from cloudflare.types.d1.database import TimeTravelGetBookmarkResponse, TimeTravelRestoreResponse -``` - -Methods: - -- 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 - -# R2 - -## Buckets - -Types: - -```python -from cloudflare.types.r2 import Bucket, BucketListResponse -``` - -Methods: - -- 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 - -### Lifecycle - -Types: - -```python -from cloudflare.types.r2.buckets import LifecycleGetResponse -``` - -Methods: - -- client.r2.buckets.lifecycle.update(bucket_name, \*, account_id, \*\*params) -> object -- client.r2.buckets.lifecycle.get(bucket_name, \*, account_id) -> LifecycleGetResponse - -### CORS - -Types: - -```python -from cloudflare.types.r2.buckets import CORSGetResponse -``` - -Methods: - -- 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 - -### Domains - -#### Custom - -Types: - -```python -from cloudflare.types.r2.buckets.domains import ( - CustomCreateResponse, - CustomUpdateResponse, - CustomListResponse, - CustomDeleteResponse, - CustomGetResponse, -) -``` - -Methods: - -- 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 - -#### Managed - -Types: - -```python -from cloudflare.types.r2.buckets.domains import ManagedUpdateResponse, ManagedListResponse -``` - -Methods: - -- client.r2.buckets.domains.managed.update(bucket_name, \*, account_id, \*\*params) -> ManagedUpdateResponse -- client.r2.buckets.domains.managed.list(bucket_name, \*, account_id) -> ManagedListResponse - -### EventNotifications - -Types: - -```python -from cloudflare.types.r2.buckets import EventNotificationListResponse, EventNotificationGetResponse -``` - -Methods: - -- 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 - -### Locks - -Types: - -```python -from cloudflare.types.r2.buckets import LockGetResponse -``` - -Methods: - -- client.r2.buckets.locks.update(bucket_name, \*, account_id, \*\*params) -> object -- client.r2.buckets.locks.get(bucket_name, \*, account_id) -> LockGetResponse - -### Metrics - -Types: - -```python -from cloudflare.types.r2.buckets import MetricListResponse -``` - -Methods: - -- client.r2.buckets.metrics.list(\*, account_id) -> MetricListResponse - -### Sippy - -Types: - -```python -from cloudflare.types.r2.buckets import Provider, Sippy, SippyDeleteResponse -``` - -Methods: - -- 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 - -## TemporaryCredentials - -Types: - -```python -from cloudflare.types.r2 import TemporaryCredential, TemporaryCredentialCreateResponse -``` - -Methods: - -- client.r2.temporary_credentials.create(\*, account_id, \*\*params) -> TemporaryCredentialCreateResponse - -## SuperSlurper - -### Jobs - -Types: - -```python -from cloudflare.types.r2.super_slurper import ( - JobCreateResponse, - JobListResponse, - JobAbortResponse, - JobAbortAllResponse, - JobGetResponse, - JobPauseResponse, - JobProgressResponse, - JobResumeResponse, -) -``` - -Methods: - -- 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 - -#### Logs - -Types: - -```python -from cloudflare.types.r2.super_slurper.jobs import LogListResponse -``` - -Methods: - -- client.r2.super_slurper.jobs.logs.list(job_id, \*, account_id, \*\*params) -> SyncSinglePage[LogListResponse] - -### ConnectivityPrecheck - -Types: - -```python -from cloudflare.types.r2.super_slurper import ( - ConnectivityPrecheckSourceResponse, - ConnectivityPrecheckTargetResponse, -) -``` - -Methods: - -- client.r2.super_slurper.connectivity_precheck.source(\*, account_id, \*\*params) -> Optional[ConnectivityPrecheckSourceResponse] -- client.r2.super_slurper.connectivity_precheck.target(\*, account_id, \*\*params) -> Optional[ConnectivityPrecheckTargetResponse] - -# R2DataCatalog - -Types: - -```python -from cloudflare.types.r2_data_catalog import ( - R2DataCatalogListResponse, - R2DataCatalogEnableResponse, - R2DataCatalogGetResponse, -) -``` - -Methods: - -- 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] - -## MaintenanceConfigs - -Types: - -```python -from cloudflare.types.r2_data_catalog import ( - MaintenanceConfigUpdateResponse, - MaintenanceConfigGetResponse, -) -``` - -Methods: - -- 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 - -## Namespaces - -Types: - -```python -from cloudflare.types.r2_data_catalog import NamespaceListResponse -``` - -Methods: - -- client.r2_data_catalog.namespaces.list(bucket_name, \*, account_id, \*\*params) -> Optional[NamespaceListResponse] - -### Tables - -Types: - -```python -from cloudflare.types.r2_data_catalog.namespaces import TableListResponse -``` - -Methods: - -- client.r2_data_catalog.namespaces.tables.list(namespace, \*, account_id, bucket_name, \*\*params) -> Optional[TableListResponse] - -#### MaintenanceConfigs - -Types: - -```python -from cloudflare.types.r2_data_catalog.namespaces.tables import ( - MaintenanceConfigUpdateResponse, - MaintenanceConfigGetResponse, -) -``` - -Methods: - -- 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] - -# WorkersForPlatforms - -## Dispatch - -### Namespaces - -Types: - -```python -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] - -### IPProfiles - -Types: - -```python -from cloudflare.types.zero_trust.devices import IPProfile, IPProfileDeleteResponse -``` - -Methods: - -- client.zero_trust.devices.ip_profiles.create(\*, account_id, \*\*params) -> IPProfile -- client.zero_trust.devices.ip_profiles.update(profile_id, \*, account_id, \*\*params) -> IPProfile -- client.zero_trust.devices.ip_profiles.list(\*, account_id, \*\*params) -> SyncSinglePage[IPProfile] -- client.zero_trust.devices.ip_profiles.delete(profile_id, \*, account_id) -> IPProfileDeleteResponse -- client.zero_trust.devices.ip_profiles.get(profile_id, \*, account_id) -> IPProfile - -### 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, - UserCreateResponse, - UserUpdateResponse, - UserListResponse, - UserGetResponse, -) -``` - -Methods: - -- client.zero_trust.access.users.create(\*, account_id, \*\*params) -> Optional[UserCreateResponse] -- client.zero_trust.access.users.update(user_id, \*, account_id, \*\*params) -> Optional[UserUpdateResponse] -- client.zero_trust.access.users.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[UserListResponse] -- client.zero_trust.access.users.delete(user_id, \*, account_id) -> object -- client.zero_trust.access.users.get(user_id, \*, account_id) -> Optional[UserGetResponse] - -#### 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] - -### Rules - -Types: - -```python -from cloudflare.types.zero_trust.dex import ( - RuleCreateResponse, - RuleUpdateResponse, - RuleListResponse, - RuleDeleteResponse, - RuleGetResponse, -) -``` - -Methods: - -- client.zero_trust.dex.rules.create(\*, account_id, \*\*params) -> Optional[RuleCreateResponse] -- client.zero_trust.dex.rules.update(rule_id, \*, account_id, \*\*params) -> Optional[RuleUpdateResponse] -- client.zero_trust.dex.rules.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[RuleListResponse]] -- client.zero_trust.dex.rules.delete(rule_id, \*, account_id) -> Optional[RuleDeleteResponse] -- client.zero_trust.dex.rules.get(rule_id, \*, account_id) -> Optional[RuleGetResponse] - -## 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 - -#### Connections - -Types: - -```python -from cloudflare.types.zero_trust.tunnels.warp_connector import ConnectionGetResponse -``` - -Methods: - -- client.zero_trust.tunnels.warp_connector.connections.get(tunnel_id, \*, account_id) -> SyncSinglePage[ConnectionGetResponse] - -#### Connectors - -Types: - -```python -from cloudflare.types.zero_trust.tunnels.warp_connector import ConnectorGetResponse -``` - -Methods: - -- client.zero_trust.tunnels.warp_connector.connectors.get(connector_id, \*, account_id, tunnel_id) -> ConnectorGetResponse - -#### Failover - -Methods: - -- client.zero_trust.tunnels.warp_connector.failover.update(tunnel_id, \*, account_id, \*\*params) -> object - -## 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 -``` - -Methods: - -- client.zero_trust.dlp.datasets.create(\*, account_id, \*\*params) -> Optional[DatasetCreation] -- client.zero_trust.dlp.datasets.update(dataset_id, \*, account_id, \*\*params) -> Optional[Dataset] -- 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[Dataset] - -#### Upload - -Types: - -```python -from cloudflare.types.zero_trust.dlp.datasets import NewVersion -``` - -Methods: - -- client.zero_trust.dlp.datasets.upload.create(dataset_id, \*, account_id) -> Optional[NewVersion] -- client.zero_trust.dlp.datasets.upload.edit(version, dataset, \*, account_id, dataset_id, \*\*params) -> Optional[Dataset] - -#### 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 -``` - -Methods: - -- client.zero_trust.dlp.profiles.list(\*, account_id, \*\*params) -> SyncSinglePage[Profile] -- client.zero_trust.dlp.profiles.get(profile_id, \*, account_id) -> Optional[Profile] - -#### Custom - -Types: - -```python -from cloudflare.types.zero_trust.dlp.profiles import CustomProfile, Pattern -``` - -Methods: - -- client.zero_trust.dlp.profiles.custom.create(\*, account_id, \*\*params) -> Optional[Profile] -- client.zero_trust.dlp.profiles.custom.update(profile_id, \*, account_id, \*\*params) -> Optional[Profile] -- client.zero_trust.dlp.profiles.custom.delete(profile_id, \*, account_id) -> object -- client.zero_trust.dlp.profiles.custom.get(profile_id, \*, account_id) -> Optional[Profile] - -#### Predefined - -Types: - -```python -from cloudflare.types.zero_trust.dlp.profiles import PredefinedProfile -``` - -Methods: - -- client.zero_trust.dlp.profiles.predefined.update(profile_id, \*, account_id, \*\*params) -> Optional[PredefinedProfile] -- client.zero_trust.dlp.profiles.predefined.delete(profile_id, \*, account_id) -> object -- client.zero_trust.dlp.profiles.predefined.get(profile_id, \*, account_id) -> Optional[PredefinedProfile] - -### 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] - -### Pacfiles - -Types: - -```python -from cloudflare.types.zero_trust.gateway import ( - PacfileCreateResponse, - PacfileUpdateResponse, - PacfileListResponse, - PacfileGetResponse, -) -``` - -Methods: - -- client.zero_trust.gateway.pacfiles.create(\*, account_id, \*\*params) -> Optional[PacfileCreateResponse] -- client.zero_trust.gateway.pacfiles.update(pacfile_id, \*, account_id, \*\*params) -> Optional[PacfileUpdateResponse] -- client.zero_trust.gateway.pacfiles.list(\*, account_id) -> SyncSinglePage[PacfileListResponse] -- client.zero_trust.gateway.pacfiles.delete(pacfile_id, \*, account_id) -> object -- client.zero_trust.gateway.pacfiles.get(pacfile_id, \*, account_id) -> Optional[PacfileGetResponse] - -## 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 - -Methods: - -- client.zero_trust.networks.subnets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Subnet] - -#### WARP - -Types: - -```python -from cloudflare.types.zero_trust.networks.subnets import Subnet, WARPDeleteResponse -``` - -Methods: - -- client.zero_trust.networks.subnets.warp.create(\*, account_id, \*\*params) -> Subnet -- client.zero_trust.networks.subnets.warp.delete(subnet_id, \*, account_id) -> Optional[WARPDeleteResponse] -- client.zero_trust.networks.subnets.warp.edit(subnet_id, \*, account_id, \*\*params) -> Subnet -- client.zero_trust.networks.subnets.warp.get(subnet_id, \*, account_id) -> Subnet - -#### CloudflareSource - -Methods: - -- client.zero_trust.networks.subnets.cloudflare_source.update(address_family, \*, account_id, \*\*params) -> Subnet - -### 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 - -# VulnerabilityScanner - -## CredentialSets - -Types: - -```python -from cloudflare.types.vulnerability_scanner import ( - CredentialSetCreateResponse, - CredentialSetUpdateResponse, - CredentialSetListResponse, - CredentialSetEditResponse, - CredentialSetGetResponse, -) -``` - -Methods: - -- client.vulnerability_scanner.credential_sets.create(\*, account_id, \*\*params) -> Optional[CredentialSetCreateResponse] -- client.vulnerability_scanner.credential_sets.update(credential_set_id, \*, account_id, \*\*params) -> Optional[CredentialSetUpdateResponse] -- client.vulnerability_scanner.credential_sets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[CredentialSetListResponse] -- client.vulnerability_scanner.credential_sets.delete(credential_set_id, \*, account_id) -> object -- client.vulnerability_scanner.credential_sets.edit(credential_set_id, \*, account_id, \*\*params) -> Optional[CredentialSetEditResponse] -- client.vulnerability_scanner.credential_sets.get(credential_set_id, \*, account_id) -> Optional[CredentialSetGetResponse] - -### Credentials - -Types: - -```python -from cloudflare.types.vulnerability_scanner.credential_sets import ( - CredentialCreateResponse, - CredentialUpdateResponse, - CredentialListResponse, - CredentialEditResponse, - CredentialGetResponse, -) -``` - -Methods: - -- client.vulnerability_scanner.credential_sets.credentials.create(credential_set_id, \*, account_id, \*\*params) -> Optional[CredentialCreateResponse] -- client.vulnerability_scanner.credential_sets.credentials.update(credential_id, \*, account_id, credential_set_id, \*\*params) -> Optional[CredentialUpdateResponse] -- client.vulnerability_scanner.credential_sets.credentials.list(credential_set_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[CredentialListResponse] -- client.vulnerability_scanner.credential_sets.credentials.delete(credential_id, \*, account_id, credential_set_id) -> object -- client.vulnerability_scanner.credential_sets.credentials.edit(credential_id, \*, account_id, credential_set_id, \*\*params) -> Optional[CredentialEditResponse] -- client.vulnerability_scanner.credential_sets.credentials.get(credential_id, \*, account_id, credential_set_id) -> Optional[CredentialGetResponse] - -## Scans - -Types: - -```python -from cloudflare.types.vulnerability_scanner import ( - ScanCreateResponse, - ScanListResponse, - ScanGetResponse, -) -``` - -Methods: - -- client.vulnerability_scanner.scans.create(\*, account_id, \*\*params) -> Optional[ScanCreateResponse] -- client.vulnerability_scanner.scans.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ScanListResponse] -- client.vulnerability_scanner.scans.get(scan_id, \*, account_id) -> Optional[ScanGetResponse] - -## TargetEnvironments - -Types: - -```python -from cloudflare.types.vulnerability_scanner import ( - TargetEnvironmentCreateResponse, - TargetEnvironmentUpdateResponse, - TargetEnvironmentListResponse, - TargetEnvironmentEditResponse, - TargetEnvironmentGetResponse, -) -``` - -Methods: - -- client.vulnerability_scanner.target_environments.create(\*, account_id, \*\*params) -> Optional[TargetEnvironmentCreateResponse] -- client.vulnerability_scanner.target_environments.update(target_environment_id, \*, account_id, \*\*params) -> Optional[TargetEnvironmentUpdateResponse] -- client.vulnerability_scanner.target_environments.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[TargetEnvironmentListResponse] -- client.vulnerability_scanner.target_environments.delete(target_environment_id, \*, account_id) -> object -- client.vulnerability_scanner.target_environments.edit(target_environment_id, \*, account_id, \*\*params) -> Optional[TargetEnvironmentEditResponse] -- client.vulnerability_scanner.target_environments.get(target_environment_id, \*, account_id) -> Optional[TargetEnvironmentGetResponse] - -# 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 - -## PostQuantum - -### Origin - -Types: - -```python -from cloudflare.types.radar.post_quantum import ( - OriginSummaryResponse, - OriginTimeseriesGroupsResponse, -) -``` - -Methods: - -- client.radar.post_quantum.origin.summary(dimension, \*\*params) -> OriginSummaryResponse -- client.radar.post_quantum.origin.timeseries_groups(dimension, \*\*params) -> OriginTimeseriesGroupsResponse - -### TLS - -Types: - -```python -from cloudflare.types.radar.post_quantum import TLSSupportResponse -``` - -Methods: - -- client.radar.post_quantum.tls.support(\*\*params) -> TLSSupportResponse - -## 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.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 - -### Top - -Types: - -```python -from cloudflare.types.radar.as112 import ( - TopDNSSECResponse, - TopEdnsResponse, - TopIPVersionResponse, - TopLocationsResponse, -) -``` - -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 - -## Email - -Types: - -```python -from cloudflare.types.radar import RadarEmailSeries, RadarEmailSummary -``` - -### Routing - -Types: - -```python -from cloudflare.types.radar.email import RoutingSummaryV2Response, RoutingTimeseriesGroupsV2Response -``` - -Methods: - -- client.radar.email.routing.summary_v2(dimension, \*\*params) -> RoutingSummaryV2Response -- client.radar.email.routing.timeseries_groups_v2(dimension, \*\*params) -> RoutingTimeseriesGroupsV2Response - -#### Summary - -Types: - -```python -from cloudflare.types.radar.email.routing import ( - SummaryARCResponse, - SummaryDKIMResponse, - SummaryDMARCResponse, - SummaryEncryptedResponse, - SummaryIPVersionResponse, - SummarySPFResponse, -) -``` - -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 - -#### TimeseriesGroups - -Types: - -```python -from cloudflare.types.radar.email.routing import ( - TimeseriesGroupARCResponse, - TimeseriesGroupDKIMResponse, - TimeseriesGroupDMARCResponse, - TimeseriesGroupEncryptedResponse, - TimeseriesGroupIPVersionResponse, - TimeseriesGroupSPFResponse, -) -``` - -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 - -Types: - -```python -from cloudflare.types.radar.email import ( - SecuritySummaryV2Response, - SecurityTimeseriesGroupsV2Response, -) -``` - -Methods: - -- client.radar.email.security.summary_v2(dimension, \*\*params) -> SecuritySummaryV2Response -- client.radar.email.security.timeseries_groups_v2(dimension, \*\*params) -> SecurityTimeseriesGroupsV2Response - -#### Top - -##### TLDs - -Types: - -```python -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.radar.attacks.layer3.top.attacks(\*\*params) -> TopAttacksResponse -- client.radar.attacks.layer3.top.industry(\*\*params) -> TopIndustryResponse -- client.radar.attacks.layer3.top.vertical(\*\*params) -> TopVerticalResponse - -##### Locations - -Types: - -```python -from cloudflare.types.radar.attacks.layer3.top import LocationOriginResponse, LocationTargetResponse -``` - -Methods: - -- client.radar.attacks.layer3.top.locations.origin(\*\*params) -> LocationOriginResponse -- client.radar.attacks.layer3.top.locations.target(\*\*params) -> LocationTargetResponse - -### Layer7 - -Types: - -```python -from cloudflare.types.radar.attacks import ( - Layer7SummaryV2Response, - Layer7TimeseriesResponse, - Layer7TimeseriesGroupsV2Response, -) -``` - -Methods: - -- 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 - -#### Summary - -Types: - -```python -from cloudflare.types.radar.attacks.layer7 import ( - SummaryHTTPMethodResponse, - SummaryHTTPVersionResponse, - SummaryIndustryResponse, - SummaryIPVersionResponse, - SummaryManagedRulesResponse, - SummaryMitigationProductResponse, - SummaryVerticalResponse, -) -``` - -Methods: - -- 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 - -#### TimeseriesGroups - -Types: - -```python -from cloudflare.types.radar.attacks.layer7 import ( - TimeseriesGroupHTTPMethodResponse, - TimeseriesGroupHTTPVersionResponse, - TimeseriesGroupIndustryResponse, - TimeseriesGroupIPVersionResponse, - TimeseriesGroupManagedRulesResponse, - TimeseriesGroupMitigationProductResponse, - TimeseriesGroupVerticalResponse, -) -``` - -Methods: - -- 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 - -#### Top - -Types: - -```python -from cloudflare.types.radar.attacks.layer7 import ( - TopAttacksResponse, - TopIndustryResponse, - TopVerticalResponse, -) -``` - -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 - -##### Locations - -Types: - -```python -from cloudflare.types.radar.attacks.layer7.top import LocationOriginResponse, LocationTargetResponse -``` - -Methods: - -- client.radar.attacks.layer7.top.locations.origin(\*\*params) -> LocationOriginResponse -- client.radar.attacks.layer7.top.locations.target(\*\*params) -> LocationTargetResponse - -##### Ases - -Types: - -```python -from cloudflare.types.radar.attacks.layer7.top import AseOriginResponse -``` - -Methods: - -- client.radar.attacks.layer7.top.ases.origin(\*\*params) -> AseOriginResponse - -## Entities - -Types: - -```python -from cloudflare.types.radar import EntityGetResponse -``` - -Methods: - -- client.radar.entities.get(\*\*params) -> EntityGetResponse - -### ASNs - -Types: - -```python -from cloudflare.types.radar.entities import ( - ASNListResponse, - ASNAsSetResponse, - ASNBotnetThreatFeedResponse, - ASNGetResponse, - ASNIPResponse, - ASNRelResponse, -) -``` - -Methods: - -- client.radar.entities.asns.list(\*\*params) -> ASNListResponse -- client.radar.entities.asns.as_set(asn, \*\*params) -> ASNAsSetResponse -- client.radar.entities.asns.botnet_threat_feed(\*\*params) -> ASNBotnetThreatFeedResponse -- client.radar.entities.asns.get(asn, \*\*params) -> ASNGetResponse -- client.radar.entities.asns.ip(\*\*params) -> ASNIPResponse -- client.radar.entities.asns.rel(asn, \*\*params) -> ASNRelResponse - -### Locations - -Types: - -```python -from cloudflare.types.radar.entities import LocationListResponse, LocationGetResponse -``` - -Methods: - -- client.radar.entities.locations.list(\*\*params) -> LocationListResponse -- client.radar.entities.locations.get(location, \*\*params) -> LocationGetResponse - -## Geolocations - -Types: - -```python -from cloudflare.types.radar import GeolocationListResponse, GeolocationGetResponse -``` - -Methods: - -- client.radar.geolocations.list(\*\*params) -> GeolocationListResponse -- client.radar.geolocations.get(geo_id, \*\*params) -> GeolocationGetResponse - -## HTTP - -Types: - -```python -from cloudflare.types.radar import ( - HTTPSummaryV2Response, - HTTPTimeseriesResponse, - HTTPTimeseriesGroupsV2Response, -) -``` - -Methods: - -- client.radar.http.summary_v2(dimension, \*\*params) -> HTTPSummaryV2Response -- client.radar.http.timeseries(\*\*params) -> HTTPTimeseriesResponse -- client.radar.http.timeseries_groups_v2(dimension, \*\*params) -> HTTPTimeseriesGroupsV2Response - -### Locations - -Types: - -```python -from cloudflare.types.radar.http import LocationGetResponse -``` - -Methods: - -- client.radar.http.locations.get(\*\*params) -> LocationGetResponse - -#### BotClass - -Types: - -```python -from cloudflare.types.radar.http.locations import BotClassGetResponse -``` - -Methods: - -- client.radar.http.locations.bot_class.get(bot_class, \*\*params) -> BotClassGetResponse - -#### DeviceType - -Types: - -```python -from cloudflare.types.radar.http.locations import DeviceTypeGetResponse -``` - -Methods: - -- client.radar.http.locations.device_type.get(device_type, \*\*params) -> DeviceTypeGetResponse - -#### HTTPProtocol - -Types: - -```python -from cloudflare.types.radar.http.locations import HTTPProtocolGetResponse -``` - -Methods: - -- client.radar.http.locations.http_protocol.get(http_protocol, \*\*params) -> HTTPProtocolGetResponse - -#### HTTPMethod - -Types: - -```python -from cloudflare.types.radar.http.locations import HTTPMethodGetResponse -``` - -Methods: - -- client.radar.http.locations.http_method.get(http_version, \*\*params) -> HTTPMethodGetResponse - -#### IPVersion - -Types: - -```python -from cloudflare.types.radar.http.locations import IPVersionGetResponse -``` - -Methods: - -- client.radar.http.locations.ip_version.get(ip_version, \*\*params) -> IPVersionGetResponse - -#### OS - -Types: - -```python -from cloudflare.types.radar.http.locations import OSGetResponse -``` - -Methods: - -- client.radar.http.locations.os.get(os, \*\*params) -> OSGetResponse - -#### TLSVersion - -Types: - -```python -from cloudflare.types.radar.http.locations import TLSVersionGetResponse -``` - -Methods: - -- client.radar.http.locations.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse - -#### BrowserFamily - -Types: - -```python -from cloudflare.types.radar.http.locations import BrowserFamilyGetResponse -``` - -Methods: - -- client.radar.http.locations.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse - -### Ases - -Types: - -```python -from cloudflare.types.radar.http import AseGetResponse -``` - -Methods: - -- client.radar.http.ases.get(\*\*params) -> AseGetResponse - -#### BotClass - -Types: - -```python -from cloudflare.types.radar.http.ases import BotClassGetResponse -``` - -Methods: - -- client.radar.http.ases.bot_class.get(bot_class, \*\*params) -> BotClassGetResponse - -#### DeviceType - -Types: - -```python -from cloudflare.types.radar.http.ases import DeviceTypeGetResponse -``` - -Methods: - -- client.radar.http.ases.device_type.get(device_type, \*\*params) -> DeviceTypeGetResponse - -#### HTTPProtocol - -Types: - -```python -from cloudflare.types.radar.http.ases import HTTPProtocolGetResponse -``` - -Methods: - -- client.radar.http.ases.http_protocol.get(http_protocol, \*\*params) -> HTTPProtocolGetResponse - -#### HTTPMethod - -Types: - -```python -from cloudflare.types.radar.http.ases import HTTPMethodGetResponse -``` - -Methods: - -- client.radar.http.ases.http_method.get(http_version, \*\*params) -> HTTPMethodGetResponse - -#### IPVersion - -Types: - -```python -from cloudflare.types.radar.http.ases import IPVersionGetResponse -``` - -Methods: - -- client.radar.http.ases.ip_version.get(ip_version, \*\*params) -> IPVersionGetResponse - -#### OS - -Types: - -```python -from cloudflare.types.radar.http.ases import OSGetResponse -``` - -Methods: - -- client.radar.http.ases.os.get(os, \*\*params) -> OSGetResponse - -#### TLSVersion - -Types: - -```python -from cloudflare.types.radar.http.ases import TLSVersionGetResponse -``` - -Methods: - -- client.radar.http.ases.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse - -#### BrowserFamily - -Types: - -```python -from cloudflare.types.radar.http.ases import BrowserFamilyGetResponse -``` - -Methods: - -- client.radar.http.ases.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse - -### Summary - -Types: - -```python -from cloudflare.types.radar.http import ( - SummaryBotClassResponse, - SummaryDeviceTypeResponse, - SummaryHTTPProtocolResponse, - SummaryHTTPVersionResponse, - SummaryIPVersionResponse, - SummaryOSResponse, - SummaryPostQuantumResponse, - SummaryTLSVersionResponse, -) -``` - -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 - -### TimeseriesGroups - -Types: - -```python -from cloudflare.types.radar.http import ( - TimeseriesGroupBotClassResponse, - TimeseriesGroupBrowserResponse, - TimeseriesGroupBrowserFamilyResponse, - TimeseriesGroupDeviceTypeResponse, - TimeseriesGroupHTTPProtocolResponse, - TimeseriesGroupHTTPVersionResponse, - TimeseriesGroupIPVersionResponse, - TimeseriesGroupOSResponse, - TimeseriesGroupPostQuantumResponse, - TimeseriesGroupTLSVersionResponse, -) -``` - -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 - -### Top - -Types: - -```python -from cloudflare.types.radar.http import TopBrowserResponse, TopBrowserFamilyResponse -``` - -Methods: - -- client.radar.http.top.browser(\*\*params) -> TopBrowserResponse -- client.radar.http.top.browser_family(\*\*params) -> TopBrowserFamilyResponse - -## Quality - -### IQI - -Types: - -```python -from cloudflare.types.radar.quality import IQISummaryResponse, IQITimeseriesGroupsResponse -``` - -Methods: - -- client.radar.quality.iqi.summary(\*\*params) -> IQISummaryResponse -- client.radar.quality.iqi.timeseries_groups(\*\*params) -> IQITimeseriesGroupsResponse - -### Speed - -Types: - -```python -from cloudflare.types.radar.quality import SpeedHistogramResponse, SpeedSummaryResponse -``` - -Methods: - -- client.radar.quality.speed.histogram(\*\*params) -> SpeedHistogramResponse -- client.radar.quality.speed.summary(\*\*params) -> SpeedSummaryResponse - -#### Top - -Types: - -```python -from cloudflare.types.radar.quality.speed import TopAsesResponse, TopLocationsResponse -``` - -Methods: - -- client.radar.quality.speed.top.ases(\*\*params) -> TopAsesResponse -- client.radar.quality.speed.top.locations(\*\*params) -> TopLocationsResponse - -## Ranking - -Types: - -```python -from cloudflare.types.radar import RankingTimeseriesGroupsResponse, RankingTopResponse -``` - -Methods: - -- client.radar.ranking.timeseries_groups(\*\*params) -> RankingTimeseriesGroupsResponse -- client.radar.ranking.top(\*\*params) -> RankingTopResponse - -### Domain - -Types: - -```python -from cloudflare.types.radar.ranking import DomainGetResponse -``` - -Methods: - -- client.radar.ranking.domain.get(domain, \*\*params) -> DomainGetResponse - -### InternetServices - -Types: - -```python -from cloudflare.types.radar.ranking import ( - InternetServiceCategoriesResponse, - InternetServiceTimeseriesGroupsResponse, - InternetServiceTopResponse, -) -``` - -Methods: - -- 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 - -## TrafficAnomalies - -Types: - -```python -from cloudflare.types.radar import TrafficAnomalyGetResponse -``` - -Methods: - -- client.radar.traffic_anomalies.get(\*\*params) -> TrafficAnomalyGetResponse - -### Locations - -Types: - -```python -from cloudflare.types.radar.traffic_anomalies import LocationGetResponse -``` - -Methods: - -- client.radar.traffic_anomalies.locations.get(\*\*params) -> LocationGetResponse - -## TCPResetsTimeouts - -Types: - -```python -from cloudflare.types.radar import ( - TCPResetsTimeoutSummaryResponse, - TCPResetsTimeoutTimeseriesGroupsResponse, -) -``` - -Methods: - -- client.radar.tcp_resets_timeouts.summary(\*\*params) -> TCPResetsTimeoutSummaryResponse -- client.radar.tcp_resets_timeouts.timeseries_groups(\*\*params) -> TCPResetsTimeoutTimeseriesGroupsResponse - -## RobotsTXT - -### Top - -Types: - -```python -from cloudflare.types.radar.robots_txt import TopDomainCategoriesResponse -``` - -Methods: - -- client.radar.robots_txt.top.domain_categories(\*\*params) -> TopDomainCategoriesResponse - -#### UserAgents - -Types: - -```python -from cloudflare.types.radar.robots_txt.top import UserAgentDirectiveResponse -``` - -Methods: - -- client.radar.robots_txt.top.user_agents.directive(\*\*params) -> UserAgentDirectiveResponse - -## LeakedCredentials - -Types: - -```python -from cloudflare.types.radar import ( - LeakedCredentialSummaryV2Response, - LeakedCredentialTimeseriesGroupsV2Response, -) -``` - -Methods: - -- client.radar.leaked_credentials.summary_v2(dimension, \*\*params) -> LeakedCredentialSummaryV2Response -- client.radar.leaked_credentials.timeseries_groups_v2(dimension, \*\*params) -> LeakedCredentialTimeseriesGroupsV2Response - -### Summary - -Types: - -```python -from cloudflare.types.radar.leaked_credentials import ( - SummaryBotClassResponse, - SummaryCompromisedResponse, -) -``` - -Methods: - -- client.radar.leaked_credentials.summary.bot_class(\*\*params) -> SummaryBotClassResponse -- client.radar.leaked_credentials.summary.compromised(\*\*params) -> SummaryCompromisedResponse - -### TimeseriesGroups - -Types: - -```python -from cloudflare.types.radar.leaked_credentials import ( - TimeseriesGroupBotClassResponse, - TimeseriesGroupCompromisedResponse, -) -``` - -Methods: - -- client.radar.leaked_credentials.timeseries_groups.bot_class(\*\*params) -> TimeseriesGroupBotClassResponse -- client.radar.leaked_credentials.timeseries_groups.compromised(\*\*params) -> TimeseriesGroupCompromisedResponse - -# BotManagement - -Types: - -```python -from cloudflare.types.bot_management import ( - BotFightModeConfiguration, - SubscriptionConfiguration, - SuperBotFightModeDefinitelyConfiguration, - SuperBotFightModeLikelyConfiguration, - BotManagementUpdateResponse, - BotManagementGetResponse, -) -``` - -Methods: - -- client.bot_management.update(\*, zone_id, \*\*params) -> Optional[BotManagementUpdateResponse] -- client.bot_management.get(\*, zone_id) -> Optional[BotManagementGetResponse] - -# Fraud - -Types: - -```python -from cloudflare.types.fraud import FraudSettings -``` - -Methods: - -- client.fraud.update(\*, zone_id, \*\*params) -> Optional[FraudSettings] -- client.fraud.get(\*, zone_id) -> Optional[FraudSettings] - -# OriginPostQuantumEncryption - -Types: - -```python -from cloudflare.types.origin_post_quantum_encryption import ( - OriginPostQuantumEncryptionUpdateResponse, - OriginPostQuantumEncryptionGetResponse, -) -``` - -Methods: - -- client.origin_post_quantum_encryption.update(\*, zone_id, \*\*params) -> Optional[OriginPostQuantumEncryptionUpdateResponse] -- client.origin_post_quantum_encryption.get(\*, zone_id) -> Optional[OriginPostQuantumEncryptionGetResponse] - -# GoogleTagGateway - -## Config - -Types: - -```python -from cloudflare.types.google_tag_gateway import Config -``` - -Methods: - -- client.google_tag_gateway.config.update(\*, zone_id, \*\*params) -> Optional[Config] -- client.google_tag_gateway.config.get(\*, zone_id) -> Optional[Config] - -# Zaraz - -Types: - -```python -from cloudflare.types.zaraz import ButtonTextTranslation, NeoEvent -``` - -Methods: - -- client.zaraz.update(\*, zone_id, \*\*params) -> Workflow - -## Config - -Types: - -```python -from cloudflare.types.zaraz import Configuration -``` - -Methods: - -- client.zaraz.config.update(\*, zone_id, \*\*params) -> Configuration -- client.zaraz.config.get(\*, zone_id) -> Configuration - -## Default - -Methods: - -- client.zaraz.default.get(\*, zone_id) -> Configuration - -## Export - -Methods: - -- client.zaraz.export.get(\*, zone_id) -> Configuration - -## History - -Types: - -```python -from cloudflare.types.zaraz import HistoryListResponse -``` - -Methods: - -- client.zaraz.history.update(\*, zone_id, \*\*params) -> Configuration -- client.zaraz.history.list(\*, zone_id, \*\*params) -> SyncSinglePage[HistoryListResponse] - -### Configs - -Types: - -```python -from cloudflare.types.zaraz.history import ConfigGetResponse -``` - -Methods: - -- client.zaraz.history.configs.get(\*, zone_id, \*\*params) -> ConfigGetResponse - -## Publish - -Types: - -```python -from cloudflare.types.zaraz import PublishCreateResponse -``` - -Methods: - -- client.zaraz.publish.create(\*, zone_id, \*\*params) -> str - -## Workflow - -Types: - -```python -from cloudflare.types.zaraz import Workflow -``` - -Methods: - -- client.zaraz.workflow.get(\*, zone_id) -> Workflow - -# Speed - -Types: - -```python -from cloudflare.types.speed import LabeledRegion, LighthouseReport, Trend -``` - -## Schedule - -Types: - -```python -from cloudflare.types.speed import Schedule, ScheduleCreateResponse, ScheduleDeleteResponse -``` - -Methods: - -- 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] - -## Availabilities - -Types: - -```python -from cloudflare.types.speed import Availability -``` - -Methods: - -- client.speed.availabilities.list(\*, zone_id) -> Optional[Availability] - -## Pages - -Types: - -```python -from cloudflare.types.speed import PageListResponse -``` - -Methods: - -- client.speed.pages.list(\*, zone_id) -> SyncSinglePage[PageListResponse] -- client.speed.pages.trend(url, \*, zone_id, \*\*params) -> Optional[Trend] - -### Tests - -Types: - -```python -from cloudflare.types.speed.pages import Test, TestDeleteResponse -``` - -Methods: - -- 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] - -# DCVDelegation - -Types: - -```python -from cloudflare.types.dcv_delegation import DCVDelegationUUID -``` - -Methods: - -- client.dcv_delegation.get(\*, zone_id) -> Optional[DCVDelegationUUID] - -# Hostnames - -## Settings - -### TLS - -Types: - -```python -from cloudflare.types.hostnames.settings import ( - Setting, - SettingValue, - TLSDeleteResponse, - TLSGetResponse, -) -``` - -Methods: - -- 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] - -# Snippets - -Types: - -```python -from cloudflare.types.snippets import SnippetUpdateResponse, SnippetListResponse, SnippetGetResponse -``` - -Methods: - -- client.snippets.update(snippet_name, \*, zone_id, \*\*params) -> SnippetUpdateResponse -- client.snippets.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[SnippetListResponse] -- client.snippets.delete(snippet_name, \*, zone_id) -> object -- client.snippets.get(snippet_name, \*, zone_id) -> SnippetGetResponse - -## Content - -Methods: - -- client.snippets.content.get(snippet_name, \*, zone_id) -> BinaryAPIResponse - -## Rules - -Methods: - -- client.snippets.rules.update(\*, zone_id, \*\*params) -> object -- client.snippets.rules.list(\*, zone_id) -> object -- client.snippets.rules.delete(\*, zone_id) -> object - -# RealtimeKit - -## Apps - -Types: - -```python -from cloudflare.types.realtime_kit import AppGetResponse, AppPostResponse -``` - -Methods: - -- client.realtime_kit.apps.get(\*, account_id) -> AppGetResponse -- client.realtime_kit.apps.post(\*, account_id, \*\*params) -> AppPostResponse - -## Meetings - -Types: - -```python -from cloudflare.types.realtime_kit import ( - MeetingCreateResponse, - MeetingAddParticipantResponse, - MeetingDeleteMeetingParticipantResponse, - MeetingEditParticipantResponse, - MeetingGetResponse, - MeetingGetMeetingByIDResponse, - MeetingGetMeetingParticipantResponse, - MeetingGetMeetingParticipantsResponse, - MeetingRefreshParticipantTokenResponse, - MeetingReplaceMeetingByIDResponse, - MeetingUpdateMeetingByIDResponse, -) -``` - -Methods: - -- 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 - -## Presets - -Types: - -```python -from cloudflare.types.realtime_kit import ( - PresetCreateResponse, - PresetUpdateResponse, - PresetDeleteResponse, - PresetGetResponse, - PresetGetPresetByIDResponse, -) -``` - -Methods: - -- 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 - -## Sessions - -Types: - -```python -from cloudflare.types.realtime_kit import ( - SessionGetParticipantDataFromPeerIDResponse, - SessionGetSessionChatResponse, - SessionGetSessionDetailsResponse, - SessionGetSessionParticipantDetailsResponse, - SessionGetSessionParticipantsResponse, - SessionGetSessionSummaryResponse, - SessionGetSessionTranscriptsResponse, - SessionGetSessionsResponse, -) -``` - -Methods: - -- 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 - -## Recordings - -Types: - -```python -from cloudflare.types.realtime_kit import ( - RecordingGetActiveRecordingsResponse, - RecordingGetOneRecordingResponse, - RecordingGetRecordingsResponse, - RecordingPauseResumeStopRecordingResponse, - RecordingStartRecordingsResponse, -) -``` - -Methods: - -- 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 - -## Webhooks - -Types: - -```python -from cloudflare.types.realtime_kit import ( - WebhookCreateWebhookResponse, - WebhookDeleteWebhookResponse, - WebhookEditWebhookResponse, - WebhookGetWebhookByIDResponse, - WebhookGetWebhooksResponse, - WebhookReplaceWebhookResponse, -) -``` - -Methods: - -- 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 - -## ActiveSession - -Types: - -```python -from cloudflare.types.realtime_kit import ( - ActiveSessionCreatePollResponse, - ActiveSessionGetActiveSessionResponse, - ActiveSessionKickAllParticipantsResponse, - ActiveSessionKickParticipantsResponse, -) -``` - -Methods: - -- 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 - -## Livestreams - -Types: - -```python -from cloudflare.types.realtime_kit import ( - LivestreamCreateIndependentLivestreamResponse, - LivestreamGetActiveLivestreamsForLivestreamIDResponse, - LivestreamGetAllLivestreamsResponse, - LivestreamGetLivestreamAnalyticsCompleteResponse, - LivestreamGetLivestreamSessionDetailsForSessionIDResponse, - LivestreamGetLivestreamSessionForLivestreamIDResponse, - LivestreamGetMeetingActiveLivestreamsResponse, - LivestreamGetOrgAnalyticsResponse, - LivestreamStartLivestreamingAMeetingResponse, - LivestreamStopLivestreamingAMeetingResponse, -) -``` - -Methods: - -- 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 - -## Analytics - -Types: - -```python -from cloudflare.types.realtime_kit import AnalyticsGetOrgAnalyticsResponse -``` - -Methods: - -- client.realtime_kit.analytics.get_org_analytics(app_id, \*, account_id, \*\*params) -> AnalyticsGetOrgAnalyticsResponse - -# Calls - -## SFU - -Types: - -```python -from cloudflare.types.calls import ( - SFUCreateResponse, - SFUUpdateResponse, - SFUListResponse, - SFUDeleteResponse, - SFUGetResponse, -) -``` - -Methods: - -- 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] - -## TURN - -Types: - -```python -from cloudflare.types.calls import ( - TURNCreateResponse, - TURNUpdateResponse, - TURNListResponse, - TURNDeleteResponse, - TURNGetResponse, -) -``` - -Methods: - -- 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] - -# CloudforceOne - -## Scans - -### Results - -Types: - -```python -from cloudflare.types.cloudforce_one.scans import ScanResult, ResultGetResponse -``` - -Methods: - -- client.cloudforce_one.scans.results.get(config_id, \*, account_id) -> ResultGetResponse - -### Config - -Types: - -```python -from cloudflare.types.cloudforce_one.scans import ( - ConfigCreateResponse, - ConfigListResponse, - ConfigEditResponse, -) -``` - -Methods: - -- 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] - -## BinaryStorage - -Types: - -```python -from cloudflare.types.cloudforce_one import BinaryStorageCreateResponse -``` - -Methods: - -- client.cloudforce_one.binary_storage.create(\*, account_id, \*\*params) -> BinaryStorageCreateResponse -- client.cloudforce_one.binary_storage.get(hash, \*, account_id) -> None - -## Requests - -Types: - -```python -from cloudflare.types.cloudforce_one import ( - Item, - ListItem, - Quota, - RequestConstants, - RequestTypes, - RequestDeleteResponse, - RequestTypesResponse, -) -``` - -Methods: - -- 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] - -### Message - -Types: - -```python -from cloudflare.types.cloudforce_one.requests import Message, MessageDeleteResponse -``` - -Methods: - -- 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] - -### Priority - -Types: - -```python -from cloudflare.types.cloudforce_one.requests import ( - Label, - Priority, - PriorityEdit, - PriorityDeleteResponse, -) -``` - -Methods: - -- 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] - -### Assets - -Types: - -```python -from cloudflare.types.cloudforce_one.requests import ( - AssetCreateResponse, - AssetUpdateResponse, - AssetDeleteResponse, - AssetGetResponse, -) -``` - -Methods: - -- 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] - -## ThreatEvents - -Types: - -```python -from cloudflare.types.cloudforce_one import ( - ThreatEventCreateResponse, - ThreatEventListResponse, - ThreatEventBulkCreateResponse, - ThreatEventEditResponse, - ThreatEventGetResponse, -) -``` - -Methods: - -- 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.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 - -### Attackers - -Types: - -```python -from cloudflare.types.cloudforce_one.threat_events import AttackerListResponse -``` - -Methods: - -- client.cloudforce_one.threat_events.attackers.list(\*, account_id, \*\*params) -> AttackerListResponse - -### Categories - -Types: - -```python -from cloudflare.types.cloudforce_one.threat_events import ( - CategoryCreateResponse, - CategoryListResponse, - CategoryDeleteResponse, - CategoryEditResponse, - CategoryGetResponse, -) -``` - -Methods: - -- 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.cloudforce_one.threat_events import CountryListResponse -``` - -Methods: - -- client.cloudforce_one.threat_events.countries.list(\*, account_id) -> CountryListResponse - -### Datasets - -Types: - -```python -from cloudflare.types.cloudforce_one.threat_events import ( - DatasetCreateResponse, - DatasetListResponse, - DatasetEditResponse, - DatasetGetResponse, - DatasetRawResponse, -) -``` - -Methods: - -- 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 - -### IndicatorTypes - -Types: - -```python -from cloudflare.types.cloudforce_one.threat_events import IndicatorTypeListResponse -``` - -Methods: - -- client.cloudforce_one.threat_events.indicator_types.list(\*, account_id) -> IndicatorTypeListResponse - -### Raw - -Types: - -```python -from cloudflare.types.cloudforce_one.threat_events import RawEditResponse, RawGetResponse -``` - -Methods: - -- 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 - -### Relate - -Types: - -```python -from cloudflare.types.cloudforce_one.threat_events import RelateDeleteResponse -``` - -Methods: - -- client.cloudforce_one.threat_events.relate.delete(event_id, \*, account_id) -> RelateDeleteResponse - -### Tags - -Types: - -```python -from cloudflare.types.cloudforce_one.threat_events import TagCreateResponse -``` - -Methods: - -- client.cloudforce_one.threat_events.tags.create(\*, account_id, \*\*params) -> TagCreateResponse - -### EventTags - -Types: - -```python -from cloudflare.types.cloudforce_one.threat_events import ( - EventTagCreateResponse, - EventTagDeleteResponse, -) -``` - -Methods: - -- 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 - -### TargetIndustries - -Types: - -```python -from cloudflare.types.cloudforce_one.threat_events import TargetIndustryListResponse -``` - -Methods: - -- client.cloudforce_one.threat_events.target_industries.list(\*, account_id, \*\*params) -> TargetIndustryListResponse - -# AIGateway - -Types: - -```python -from cloudflare.types.ai_gateway import ( - AIGatewayCreateResponse, - AIGatewayUpdateResponse, - AIGatewayListResponse, - AIGatewayDeleteResponse, - AIGatewayGetResponse, -) -``` - -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 - -## EvaluationTypes - -Types: - -```python -from cloudflare.types.ai_gateway import EvaluationTypeListResponse -``` - -Methods: - -- client.ai_gateway.evaluation_types.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[EvaluationTypeListResponse] - -## Logs - -Types: - -```python -from cloudflare.types.ai_gateway import LogListResponse, LogDeleteResponse, LogGetResponse -``` - -Methods: - -- 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 - -## Datasets - -Types: - -```python -from cloudflare.types.ai_gateway import ( - DatasetCreateResponse, - DatasetUpdateResponse, - DatasetListResponse, - DatasetDeleteResponse, - DatasetGetResponse, -) -``` - -Methods: - -- 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 - -## Evaluations - -Types: - -```python -from cloudflare.types.ai_gateway import ( - EvaluationCreateResponse, - EvaluationListResponse, - EvaluationDeleteResponse, - EvaluationGetResponse, -) -``` - -Methods: - -- 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 - -## DynamicRouting - -Types: - -```python -from cloudflare.types.ai_gateway import ( - DynamicRoutingCreateResponse, - DynamicRoutingUpdateResponse, - DynamicRoutingListResponse, - DynamicRoutingDeleteResponse, - DynamicRoutingCreateDeploymentResponse, - DynamicRoutingCreateVersionResponse, - DynamicRoutingGetResponse, - DynamicRoutingGetVersionResponse, - DynamicRoutingListDeploymentsResponse, - DynamicRoutingListVersionsResponse, -) -``` - -Methods: - -- 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 - -## ProviderConfigs - -Types: - -```python -from cloudflare.types.ai_gateway import ProviderConfigCreateResponse, ProviderConfigListResponse -``` - -Methods: - -- 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] - -## URLs - -Types: - -```python -from cloudflare.types.ai_gateway import URLGetResponse -``` - -Methods: - -- client.ai_gateway.urls.get(provider, \*, account_id, gateway_id) -> str - -# IAM - -## PermissionGroups - -Types: - -```python -from cloudflare.types.iam import PermissionGroupListResponse, PermissionGroupGetResponse -``` - -Methods: - -- client.iam.permission_groups.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[PermissionGroupListResponse] -- client.iam.permission_groups.get(permission_group_id, \*, account_id) -> Optional[PermissionGroupGetResponse] - -## ResourceGroups - -Types: - -```python -from cloudflare.types.iam import ( - ResourceGroupCreateResponse, - ResourceGroupUpdateResponse, - ResourceGroupListResponse, - ResourceGroupDeleteResponse, - ResourceGroupGetResponse, -) -``` - -Methods: - -- 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] - -## UserGroups - -Types: - -```python -from cloudflare.types.iam import ( - UserGroupCreateResponse, - UserGroupUpdateResponse, - UserGroupListResponse, - UserGroupDeleteResponse, - UserGroupGetResponse, -) -``` - -Methods: - -- 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] - -### Members - -Types: - -```python -from cloudflare.types.iam.user_groups import ( - MemberCreateResponse, - MemberUpdateResponse, - MemberListResponse, - MemberDeleteResponse, -) -``` - -Methods: - -- 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] - -## SSO - -Types: - -```python -from cloudflare.types.iam import ( - SSOCreateResponse, - SSOUpdateResponse, - SSOListResponse, - SSODeleteResponse, - SSOBeginVerificationResponse, - SSOGetResponse, -) -``` - -Methods: - -- 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] - -# CloudConnector - -## Rules - -Types: - -```python -from cloudflare.types.cloud_connector import RuleUpdateResponse, RuleListResponse -``` - -Methods: - -- client.cloud_connector.rules.update(\*, zone_id, \*\*params) -> SyncSinglePage[RuleUpdateResponse] -- client.cloud_connector.rules.list(\*, zone_id) -> SyncSinglePage[RuleListResponse] - -# BotnetFeed - -## ASN - -Types: - -```python -from cloudflare.types.botnet_feed import ASNDayReportResponse, ASNFullReportResponse -``` - -Methods: - -- 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] - -## Configs - -### ASN - -Types: - -```python -from cloudflare.types.botnet_feed.configs import ASNDeleteResponse, ASNGetResponse -``` - -Methods: - -- client.botnet_feed.configs.asn.delete(asn_id, \*, account_id) -> Optional[ASNDeleteResponse] -- client.botnet_feed.configs.asn.get(\*, account_id) -> Optional[ASNGetResponse] - -# SecurityTXT - -Types: - -```python -from cloudflare.types.security_txt import ( - SecurityTXTUpdateResponse, - SecurityTXTDeleteResponse, - SecurityTXTGetResponse, -) -``` - -Methods: - -- client.security_txt.update(\*, zone_id, \*\*params) -> SecurityTXTUpdateResponse -- client.security_txt.delete(\*, zone_id) -> SecurityTXTDeleteResponse -- client.security_txt.get(\*, zone_id) -> Optional[SecurityTXTGetResponse] - -# Workflows - -Types: - -```python -from cloudflare.types.workflows import ( - WorkflowUpdateResponse, - WorkflowListResponse, - WorkflowDeleteResponse, - WorkflowGetResponse, -) -``` - -Methods: - -- 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 - -## Instances - -Types: - -```python -from cloudflare.types.workflows import ( - InstanceCreateResponse, - InstanceListResponse, - InstanceBulkResponse, - InstanceGetResponse, -) -``` - -Methods: - -- 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, \*\*params) -> InstanceGetResponse - -### Status - -Types: - -```python -from cloudflare.types.workflows.instances import StatusEditResponse -``` - -Methods: - -- client.workflows.instances.status.edit(instance_id, \*, account_id, workflow_name, \*\*params) -> StatusEditResponse - -### Events - -Methods: - -- client.workflows.instances.events.create(event_type, \*, account_id, workflow_name, instance_id, \*\*params) -> object - -## Versions - -Types: - -```python -from cloudflare.types.workflows import VersionListResponse, VersionGetResponse -``` - -Methods: - -- client.workflows.versions.list(workflow_name, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[VersionListResponse] -- client.workflows.versions.get(version_id, \*, account_id, workflow_name) -> VersionGetResponse - -# ResourceSharing - -Types: - -```python -from cloudflare.types.resource_sharing import ( - ResourceSharingCreateResponse, - ResourceSharingUpdateResponse, - ResourceSharingListResponse, - ResourceSharingDeleteResponse, - ResourceSharingGetResponse, -) -``` - -Methods: - -- 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] - -## Recipients - -Types: - -```python -from cloudflare.types.resource_sharing import ( - RecipientCreateResponse, - RecipientListResponse, - RecipientDeleteResponse, - RecipientGetResponse, -) -``` - -Methods: - -- 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] - -## Resources - -Types: - -```python -from cloudflare.types.resource_sharing import ( - ResourceCreateResponse, - ResourceUpdateResponse, - ResourceListResponse, - ResourceDeleteResponse, - ResourceGetResponse, -) -``` - -Methods: - -- 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] - -# ResourceTagging - -Types: - -```python -from cloudflare.types.resource_tagging import ResourceTaggingListResponse -``` - -Methods: - -- client.resource_tagging.list(\*, account_id, \*\*params) -> SyncCursorPaginationAfter[ResourceTaggingListResponse] - -## AccountTags - -Types: - -```python -from cloudflare.types.resource_tagging import AccountTagUpdateResponse, AccountTagGetResponse -``` - -Methods: - -- client.resource_tagging.account_tags.update(\*, account_id, \*\*params) -> Optional[AccountTagUpdateResponse] -- client.resource_tagging.account_tags.delete(\*, account_id) -> None -- client.resource_tagging.account_tags.get(\*, account_id, \*\*params) -> Optional[AccountTagGetResponse] - -## ZoneTags - -Types: - -```python -from cloudflare.types.resource_tagging import ZoneTagUpdateResponse, ZoneTagGetResponse -``` - -Methods: - -- client.resource_tagging.zone_tags.update(\*, zone_id, \*\*params) -> Optional[ZoneTagUpdateResponse] -- client.resource_tagging.zone_tags.delete(\*, zone_id) -> None -- client.resource_tagging.zone_tags.get(\*, zone_id, \*\*params) -> Optional[ZoneTagGetResponse] - -## Keys - -Types: - -```python -from cloudflare.types.resource_tagging import KeyListResponse -``` - -Methods: - -- client.resource_tagging.keys.list(\*, account_id, \*\*params) -> SyncCursorPaginationAfter[KeyListResponse] - -## Values - -Types: - -```python -from cloudflare.types.resource_tagging import ValueListResponse -``` - -Methods: - -- client.resource_tagging.values.list(tag_key, \*, account_id, \*\*params) -> SyncCursorPaginationAfter[ValueListResponse] - -# LeakedCredentialChecks - -Types: - -```python -from cloudflare.types.leaked_credential_checks import ( - LeakedCredentialCheckCreateResponse, - LeakedCredentialCheckGetResponse, -) -``` - -Methods: - -- client.leaked_credential_checks.create(\*, zone_id, \*\*params) -> LeakedCredentialCheckCreateResponse -- client.leaked_credential_checks.get(\*, zone_id) -> LeakedCredentialCheckGetResponse - -## Detections - -Types: - -```python -from cloudflare.types.leaked_credential_checks import ( - DetectionCreateResponse, - DetectionUpdateResponse, - DetectionListResponse, - DetectionGetResponse, -) -``` - -Methods: - -- 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 - -# ContentScanning - -Types: - -```python -from cloudflare.types.content_scanning import ( - ContentScanningCreateResponse, - ContentScanningUpdateResponse, - ContentScanningGetResponse, -) -``` - -Methods: - -- 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 - -## Payloads - -Types: - -```python -from cloudflare.types.content_scanning import ( - PayloadCreateResponse, - PayloadListResponse, - PayloadDeleteResponse, -) -``` - -Methods: - -- 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] - -## Settings - -Types: - -```python -from cloudflare.types.content_scanning import SettingGetResponse -``` - -Methods: - -- client.content_scanning.settings.get(\*, zone_id) -> SettingGetResponse - -# AbuseReports - -Types: - -```python -from cloudflare.types.abuse_reports import ( - AbuseReportCreateResponse, - AbuseReportListResponse, - AbuseReportGetResponse, -) -``` - -Methods: - -- 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 - -## Mitigations - -Types: - -```python -from cloudflare.types.abuse_reports import MitigationListResponse, MitigationReviewResponse -``` - -Methods: - -- 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] - -# AI - -Types: - -```python -from cloudflare.types.ai import AIRunResponse -``` - -Methods: - -- client.ai.run(model_name, \*, account_id, \*\*params) -> Optional[AIRunResponse] - -## Finetunes - -Types: - -```python -from cloudflare.types.ai import FinetuneCreateResponse, FinetuneListResponse -``` - -Methods: - -- client.ai.finetunes.create(\*, account_id, \*\*params) -> FinetuneCreateResponse -- client.ai.finetunes.list(\*, account_id) -> FinetuneListResponse - -### Assets - -Types: - -```python -from cloudflare.types.ai.finetunes import AssetCreateResponse -``` - -Methods: - -- client.ai.finetunes.assets.create(finetune_id, \*, account_id, \*\*params) -> AssetCreateResponse - -### Public - -Types: - -```python -from cloudflare.types.ai.finetunes import PublicListResponse -``` - -Methods: - -- client.ai.finetunes.public.list(\*, account_id, \*\*params) -> SyncSinglePage[PublicListResponse] - -## Authors - -Methods: - -- client.ai.authors.list(\*, account_id) -> SyncSinglePage[object] - -## Tasks - -Methods: - -- client.ai.tasks.list(\*, account_id) -> SyncSinglePage[object] - -## Models - -Methods: - -- client.ai.models.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[object] - -### Schema - -Types: - -```python -from cloudflare.types.ai.models import SchemaGetResponse -``` +# [OriginCACertificates](src/cloudflare/resources/origin_ca_certificates/api.md) -Methods: +# [IPs](src/cloudflare/resources/ips/api.md) -- client.ai.models.schema.get(\*, account_id, \*\*params) -> SchemaGetResponse +# [Memberships](src/cloudflare/resources/memberships/api.md) -## ToMarkdown +# [User](src/cloudflare/resources/user/api.md) -Types: +# [Zones](src/cloudflare/resources/zones/api.md) -```python -from cloudflare.types.ai import ToMarkdownSupportedResponse, ToMarkdownTransformResponse -``` - -Methods: - -- client.ai.to_markdown.supported(\*, account_id) -> SyncSinglePage[ToMarkdownSupportedResponse] -- client.ai.to_markdown.transform(\*, account_id, \*\*params) -> SyncSinglePage[ToMarkdownTransformResponse] - -# AISearch - -## Instances - -Types: - -```python -from cloudflare.types.aisearch import ( - InstanceCreateResponse, - InstanceUpdateResponse, - InstanceListResponse, - InstanceDeleteResponse, - InstanceChatCompletionsResponse, - InstanceReadResponse, - InstanceSearchResponse, - InstanceStatsResponse, -) -``` - -Methods: - -- 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 - -### Jobs - -Types: - -```python -from cloudflare.types.aisearch.instances import ( - JobCreateResponse, - JobListResponse, - JobGetResponse, - JobLogsResponse, -) -``` - -Methods: - -- client.aisearch.instances.jobs.create(id, \*, account_id, \*\*params) -> 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 - -## Tokens - -Types: - -```python -from cloudflare.types.aisearch import ( - TokenCreateResponse, - TokenUpdateResponse, - TokenListResponse, - TokenDeleteResponse, - TokenReadResponse, -) -``` - -Methods: - -- 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 - -# BrowserRendering - -## Content - -Types: - -```python -from cloudflare.types.browser_rendering import ContentCreateResponse -``` - -Methods: - -- client.browser_rendering.content.create(\*, account_id, \*\*params) -> str - -## PDF - -Methods: - -- client.browser_rendering.pdf.create(\*, account_id, \*\*params) -> BinaryAPIResponse - -## Scrape - -Types: - -```python -from cloudflare.types.browser_rendering import ScrapeCreateResponse -``` - -Methods: - -- client.browser_rendering.scrape.create(\*, account_id, \*\*params) -> ScrapeCreateResponse - -## Screenshot - -Types: - -```python -from cloudflare.types.browser_rendering import ScreenshotCreateResponse -``` - -Methods: - -- client.browser_rendering.screenshot.create(\*, account_id, \*\*params) -> ScreenshotCreateResponse - -## Snapshot - -Types: - -```python -from cloudflare.types.browser_rendering import SnapshotCreateResponse -``` - -Methods: - -- client.browser_rendering.snapshot.create(\*, account_id, \*\*params) -> Optional[SnapshotCreateResponse] - -## Json - -Types: - -```python -from cloudflare.types.browser_rendering import JsonCreateResponse -``` - -Methods: - -- client.browser_rendering.json.create(\*, account_id, \*\*params) -> JsonCreateResponse - -## Links - -Types: - -```python -from cloudflare.types.browser_rendering import LinkCreateResponse -``` - -Methods: - -- client.browser_rendering.links.create(\*, account_id, \*\*params) -> LinkCreateResponse - -## Markdown - -Types: - -```python -from cloudflare.types.browser_rendering import MarkdownCreateResponse -``` +# [LoadBalancers](src/cloudflare/resources/load_balancers/api.md) -Methods: +# [Cache](src/cloudflare/resources/cache/api.md) -- client.browser_rendering.markdown.create(\*, account_id, \*\*params) -> str +# [SSL](src/cloudflare/resources/ssl/api.md) -## Crawl +# [ACM](src/cloudflare/resources/acm/api.md) -Types: +# [Argo](src/cloudflare/resources/argo/api.md) -```python -from cloudflare.types.browser_rendering import ( - CrawlCreateResponse, - CrawlDeleteResponse, - CrawlGetResponse, -) -``` - -Methods: +# [CertificateAuthorities](src/cloudflare/resources/certificate_authorities/api.md) -- client.browser_rendering.crawl.create(\*, account_id, \*\*params) -> str -- client.browser_rendering.crawl.delete(job_id, \*, account_id) -> CrawlDeleteResponse -- client.browser_rendering.crawl.get(job_id, \*, account_id, \*\*params) -> CrawlGetResponse +# [ClientCertificates](src/cloudflare/resources/client_certificates/api.md) -## Devtools +# [CustomCertificates](src/cloudflare/resources/custom_certificates/api.md) -### Session +# [CustomHostnames](src/cloudflare/resources/custom_hostnames/api.md) -Types: +# [CustomNameservers](src/cloudflare/resources/custom_nameservers/api.md) -```python -from cloudflare.types.browser_rendering.devtools import SessionListResponse, SessionGetResponse -``` +# [DNSFirewall](src/cloudflare/resources/dns_firewall/api.md) -Methods: +# [DNS](src/cloudflare/resources/dns/api.md) -- client.browser_rendering.devtools.session.list(\*, account_id, \*\*params) -> SessionListResponse -- client.browser_rendering.devtools.session.get(session_id, \*, account_id) -> Optional[SessionGetResponse] +# [EmailSecurity](src/cloudflare/resources/email_security/api.md) -### Browser +# [EmailRouting](src/cloudflare/resources/email_routing/api.md) -Types: +# [EmailSending](src/cloudflare/resources/email_sending/api.md) -```python -from cloudflare.types.browser_rendering.devtools import ( - BrowserCreateResponse, - BrowserDeleteResponse, - BrowserProtocolResponse, - BrowserVersionResponse, -) -``` +# [Filters](src/cloudflare/resources/filters/api.md) -Methods: +# [Firewall](src/cloudflare/resources/firewall/api.md) -- client.browser_rendering.devtools.browser.create(\*, account_id, \*\*params) -> BrowserCreateResponse -- client.browser_rendering.devtools.browser.delete(session_id, \*, account_id) -> BrowserDeleteResponse -- client.browser_rendering.devtools.browser.connect(session_id, \*, account_id, \*\*params) -> None -- client.browser_rendering.devtools.browser.launch(\*, account_id, \*\*params) -> None -- client.browser_rendering.devtools.browser.protocol(session_id, \*, account_id) -> BrowserProtocolResponse -- client.browser_rendering.devtools.browser.version(session_id, \*, account_id) -> BrowserVersionResponse +# [Healthchecks](src/cloudflare/resources/healthchecks/api.md) -#### Page +# [KeylessCertificates](src/cloudflare/resources/keyless_certificates/api.md) -Methods: +# [Logpush](src/cloudflare/resources/logpush/api.md) -- client.browser_rendering.devtools.browser.page.get(target_id, \*, account_id, session_id) -> None +# [Logs](src/cloudflare/resources/logs/api.md) -#### Targets +# [OriginTLSClientAuth](src/cloudflare/resources/origin_tls_client_auth/api.md) -Types: +# [PageRules](src/cloudflare/resources/page_rules/api.md) -```python -from cloudflare.types.browser_rendering.devtools.browser import ( - TargetCreateResponse, - TargetListResponse, - TargetActivateResponse, - TargetGetResponse, -) -``` +# [RateLimits](src/cloudflare/resources/rate_limits/api.md) -Methods: +# [WaitingRooms](src/cloudflare/resources/waiting_rooms/api.md) -- client.browser_rendering.devtools.browser.targets.create(session_id, \*, account_id, \*\*params) -> TargetCreateResponse -- client.browser_rendering.devtools.browser.targets.list(session_id, \*, account_id) -> TargetListResponse -- client.browser_rendering.devtools.browser.targets.activate(target_id, \*, account_id, session_id) -> TargetActivateResponse -- client.browser_rendering.devtools.browser.targets.get(target_id, \*, account_id, session_id) -> TargetGetResponse +# [Web3](src/cloudflare/resources/web3/api.md) -# CustomPages +# [Workers](src/cloudflare/resources/workers/api.md) -Types: +# [KV](src/cloudflare/resources/kv/api.md) -```python -from cloudflare.types.custom_pages import ( - CustomPageUpdateResponse, - CustomPageListResponse, - CustomPageGetResponse, -) -``` +# [DurableObjects](src/cloudflare/resources/durable_objects/api.md) -Methods: +# [Queues](src/cloudflare/resources/queues/api.md) -- 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] +# [APIGateway](src/cloudflare/resources/api_gateway/api.md) -## Assets +# [ManagedTransforms](src/cloudflare/resources/managed_transforms/api.md) -Types: +# [PageShield](src/cloudflare/resources/page_shield/api.md) -```python -from cloudflare.types.custom_pages import ( - AssetCreateResponse, - AssetUpdateResponse, - AssetListResponse, - AssetGetResponse, -) -``` +# [Rulesets](src/cloudflare/resources/rulesets/api.md) -Methods: +# [URLNormalization](src/cloudflare/resources/url_normalization/api.md) -- client.custom_pages.assets.create(\*, account_id, zone_id, \*\*params) -> Optional[AssetCreateResponse] -- client.custom_pages.assets.update(asset_name, \*, account_id, zone_id, \*\*params) -> Optional[AssetUpdateResponse] -- client.custom_pages.assets.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[AssetListResponse] -- client.custom_pages.assets.delete(asset_name, \*, account_id, zone_id) -> None -- client.custom_pages.assets.get(asset_name, \*, account_id, zone_id) -> Optional[AssetGetResponse] +# [Spectrum](src/cloudflare/resources/spectrum/api.md) -# SecretsStore +# [Addressing](src/cloudflare/resources/addressing/api.md) -## Stores +# [AuditLogs](src/cloudflare/resources/audit_logs/api.md) -Types: +# [Billing](src/cloudflare/resources/billing/api.md) -```python -from cloudflare.types.secrets_store import StoreCreateResponse, StoreListResponse -``` +# [BrandProtection](src/cloudflare/resources/brand_protection/api.md) -Methods: +# [Diagnostics](src/cloudflare/resources/diagnostics/api.md) -- client.secrets_store.stores.create(\*, account_id, \*\*params) -> Optional[StoreCreateResponse] -- client.secrets_store.stores.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[StoreListResponse] -- client.secrets_store.stores.delete(store_id, \*, account_id) -> object +# [Images](src/cloudflare/resources/images/api.md) -### Secrets +# [Intel](src/cloudflare/resources/intel/api.md) -Types: +# [MagicTransit](src/cloudflare/resources/magic_transit/api.md) -```python -from cloudflare.types.secrets_store.stores import ( - SecretCreateResponse, - SecretListResponse, - SecretDuplicateResponse, - SecretEditResponse, - SecretGetResponse, -) -``` +# [MagicNetworkMonitoring](src/cloudflare/resources/magic_network_monitoring/api.md) -Methods: +# [MagicCloudNetworking](src/cloudflare/resources/magic_cloud_networking/api.md) -- 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) -> object -- client.secrets_store.stores.secrets.bulk_delete(store_id, \*, account_id) -> object -- 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] +# [NetworkInterconnects](src/cloudflare/resources/network_interconnects/api.md) -## Quota +# [MTLSCertificates](src/cloudflare/resources/mtls_certificates/api.md) -Types: +# [Pages](src/cloudflare/resources/pages/api.md) -```python -from cloudflare.types.secrets_store import QuotaGetResponse -``` +# [Registrar](src/cloudflare/resources/registrar/api.md) -Methods: +# [RequestTracers](src/cloudflare/resources/request_tracers/api.md) -- client.secrets_store.quota.get(\*, account_id) -> Optional[QuotaGetResponse] +# [Rules](src/cloudflare/resources/rules/api.md) -# Pipelines +# [Stream](src/cloudflare/resources/stream/api.md) -Types: +# [Alerting](src/cloudflare/resources/alerting/api.md) -```python -from cloudflare.types.pipelines import ( - PipelineCreateResponse, - PipelineUpdateResponse, - PipelineListResponse, - PipelineCreateV1Response, - PipelineGetResponse, - PipelineGetV1Response, - PipelineListV1Response, - PipelineValidateSqlResponse, -) -``` +# [D1](src/cloudflare/resources/d1/api.md) -Methods: +# [R2](src/cloudflare/resources/r2/api.md) -- 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) -> object -- 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 +# [R2DataCatalog](src/cloudflare/resources/r2_data_catalog/api.md) -## Sinks +# [WorkersForPlatforms](src/cloudflare/resources/workers_for_platforms/api.md) -Types: +# [ZeroTrust](src/cloudflare/resources/zero_trust/api.md) -```python -from cloudflare.types.pipelines import SinkCreateResponse, SinkListResponse, SinkGetResponse -``` +# [Turnstile](src/cloudflare/resources/turnstile/api.md) -Methods: +# [Connectivity](src/cloudflare/resources/connectivity/api.md) -- 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) -> object -- client.pipelines.sinks.get(sink_id, \*, account_id) -> SinkGetResponse +# [Hyperdrive](src/cloudflare/resources/hyperdrive/api.md) -## Streams +# [RUM](src/cloudflare/resources/rum/api.md) -Types: +# [Vectorize](src/cloudflare/resources/vectorize/api.md) -```python -from cloudflare.types.pipelines import ( - StreamCreateResponse, - StreamUpdateResponse, - StreamListResponse, - StreamGetResponse, -) -``` +# [URLScanner](src/cloudflare/resources/url_scanner/api.md) -Methods: +# [VulnerabilityScanner](src/cloudflare/resources/vulnerability_scanner/api.md) -- 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) -> object -- client.pipelines.streams.get(stream_id, \*, account_id) -> StreamGetResponse +# [Radar](src/cloudflare/resources/radar/api.md) -# SchemaValidation +# [BotManagement](src/cloudflare/resources/bot_management/api.md) -## Schemas +# [Fraud](src/cloudflare/resources/fraud/api.md) -Types: +# [OriginPostQuantumEncryption](src/cloudflare/resources/origin_post_quantum_encryption/api.md) -```python -from cloudflare.types.schema_validation import PublicSchema, SchemaDeleteResponse -``` +# [GoogleTagGateway](src/cloudflare/resources/google_tag_gateway/api.md) -Methods: +# [Zaraz](src/cloudflare/resources/zaraz/api.md) -- 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 +# [Speed](src/cloudflare/resources/speed/api.md) -## Settings +# [DCVDelegation](src/cloudflare/resources/dcv_delegation/api.md) -Types: +# [Hostnames](src/cloudflare/resources/hostnames/api.md) -```python -from cloudflare.types.schema_validation import ( - SettingUpdateResponse, - SettingEditResponse, - SettingGetResponse, -) -``` +# [Snippets](src/cloudflare/resources/snippets/api.md) -Methods: +# [RealtimeKit](src/cloudflare/resources/realtime_kit/api.md) -- 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 +# [Calls](src/cloudflare/resources/calls/api.md) -### Operations +# [CloudforceOne](src/cloudflare/resources/cloudforce_one/api.md) -Types: +# [AIGateway](src/cloudflare/resources/ai_gateway/api.md) -```python -from cloudflare.types.schema_validation.settings import ( - OperationUpdateResponse, - OperationListResponse, - OperationDeleteResponse, - OperationBulkEditResponse, - OperationGetResponse, -) -``` +# [IAM](src/cloudflare/resources/iam/api.md) -Methods: +# [CloudConnector](src/cloudflare/resources/cloud_connector/api.md) -- 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 +# [BotnetFeed](src/cloudflare/resources/botnet_feed/api.md) -# TokenValidation +# [SecurityTXT](src/cloudflare/resources/security_txt/api.md) -## Configuration +# [Workflows](src/cloudflare/resources/workflows/api.md) -Types: +# [ResourceSharing](src/cloudflare/resources/resource_sharing/api.md) -```python -from cloudflare.types.token_validation import ( - TokenConfig, - ConfigurationDeleteResponse, - ConfigurationEditResponse, -) -``` +# [ResourceTagging](src/cloudflare/resources/resource_tagging/api.md) -Methods: +# [LeakedCredentialChecks](src/cloudflare/resources/leaked_credential_checks/api.md) -- 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 +# [ContentScanning](src/cloudflare/resources/content_scanning/api.md) -### Credentials +# [AbuseReports](src/cloudflare/resources/abuse_reports/api.md) -Types: +# [AI](src/cloudflare/resources/ai/api.md) -```python -from cloudflare.types.token_validation.configuration import CredentialUpdateResponse -``` +# [AISearch](src/cloudflare/resources/aisearch/api.md) -Methods: +# [SecurityCenter](src/cloudflare/resources/security_center/api.md) -- client.token_validation.configuration.credentials.update(config_id, \*, zone_id, \*\*params) -> CredentialUpdateResponse +# [BrowserRendering](src/cloudflare/resources/browser_rendering/api.md) -## Rules +# [CustomPages](src/cloudflare/resources/custom_pages/api.md) -Types: +# [SecretsStore](src/cloudflare/resources/secrets_store/api.md) -```python -from cloudflare.types.token_validation import TokenValidationRule -``` +# [Pipelines](src/cloudflare/resources/pipelines/api.md) -Methods: +# [SchemaValidation](src/cloudflare/resources/schema_validation/api.md) -- 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 +# [TokenValidation](src/cloudflare/resources/token_validation/api.md) diff --git a/pyproject.toml b/pyproject.toml index a5a2adb78ec..f04e6800cd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ authors = [ dependencies = [ "httpx>=0.23.0, <1", "pydantic>=1.9.0, <3", - "typing-extensions>=4.10, <5", + "typing-extensions>=4.14, <5", "anyio>=3.5.0, <5", "distro>=1.7.0, <2", "sniffio", @@ -70,7 +70,7 @@ format = { chain = [ # run formatting again to fix any inconsistencies when imports are stripped "format:ruff", ]} -"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md" +"format:docs" = "bash -c 'python scripts/utils/ruffen-docs.py README.md $(find . -type f -name api.md)'" "format:ruff" = "ruff format" "lint" = { chain = [ diff --git a/requirements-dev.lock b/requirements-dev.lock index 9fb207c1220..be86ad20d91 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -12,14 +12,14 @@ -e file:. aiohappyeyeballs==2.6.1 # via aiohttp -aiohttp==3.13.2 +aiohttp==3.13.3 # via cloudflare # via httpx-aiohttp aiosignal==1.4.0 # via aiohttp annotated-types==0.7.0 # via pydantic -anyio==4.12.0 +anyio==4.12.1 # via cloudflare # via httpx argcomplete==3.6.3 @@ -31,7 +31,7 @@ attrs==25.4.0 # via nox backports-asyncio-runner==1.2.0 # via pytest-asyncio -certifi==2025.11.12 +certifi==2026.1.4 # via httpcore # via httpx colorama==0.4.6 @@ -64,7 +64,7 @@ httpx==0.28.1 # via cloudflare # via httpx-aiohttp # via respx -httpx-aiohttp==0.1.9 +httpx-aiohttp==0.1.12 # via cloudflare humanize==4.13.0 # via nox @@ -72,7 +72,7 @@ idna==3.11 # via anyio # via httpx # via yarl -importlib-metadata==8.7.0 +importlib-metadata==8.7.1 iniconfig==2.1.0 # via pytest markdown-it-py==3.0.0 @@ -85,14 +85,14 @@ multidict==6.7.0 mypy==1.17.0 mypy-extensions==1.1.0 # via mypy -nodeenv==1.9.1 +nodeenv==1.10.0 # via pyright nox==2025.11.12 packaging==25.0 # via dependency-groups # via nox # via pytest -pathspec==0.12.1 +pathspec==1.0.3 # via mypy platformdirs==4.4.0 # via virtualenv @@ -118,13 +118,13 @@ python-dateutil==2.9.0.post0 # via time-machine respx==0.22.0 rich==14.2.0 -ruff==0.14.7 +ruff==0.14.13 six==1.17.0 # via python-dateutil sniffio==1.3.1 # via cloudflare time-machine==2.19.0 -tomli==2.3.0 +tomli==2.4.0 # via dependency-groups # via mypy # via nox @@ -144,7 +144,7 @@ typing-extensions==4.15.0 # via virtualenv typing-inspection==0.4.2 # via pydantic -virtualenv==20.35.4 +virtualenv==20.36.1 # via nox yarl==1.22.0 # via aiohttp diff --git a/requirements.lock b/requirements.lock index c948e87d644..67880761fcb 100644 --- a/requirements.lock +++ b/requirements.lock @@ -12,21 +12,21 @@ -e file:. aiohappyeyeballs==2.6.1 # via aiohttp -aiohttp==3.13.2 +aiohttp==3.13.3 # via cloudflare # via httpx-aiohttp aiosignal==1.4.0 # via aiohttp annotated-types==0.7.0 # via pydantic -anyio==4.12.0 +anyio==4.12.1 # via cloudflare # via httpx async-timeout==5.0.1 # via aiohttp attrs==25.4.0 # via aiohttp -certifi==2025.11.12 +certifi==2026.1.4 # via httpcore # via httpx distro==1.9.0 @@ -43,7 +43,7 @@ httpcore==1.0.9 httpx==0.28.1 # via cloudflare # via httpx-aiohttp -httpx-aiohttp==0.1.9 +httpx-aiohttp==0.1.12 # via cloudflare idna==3.11 # via anyio diff --git a/scripts/mock b/scripts/mock index 0b28f6ea23d..bcf3b392b3b 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,11 +21,22 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then + # Pre-install the package so the download doesn't eat into the startup timeout + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - # Wait for server to come online + # Wait for server to come online (max 30s) echo -n "Waiting for server" + attempts=0 while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + attempts=$((attempts + 1)) + if [ "$attempts" -ge 300 ]; then + echo + echo "Timed out waiting for Prism server to start" + cat .prism.log + exit 1 + fi echo -n "." sleep 0.1 done diff --git a/src/cloudflare/_base_client.py b/src/cloudflare/_base_client.py index e6310e5837d..3d7dc067190 100644 --- a/src/cloudflare/_base_client.py +++ b/src/cloudflare/_base_client.py @@ -88,6 +88,7 @@ APIConnectionError, APIResponseValidationError, ) +from ._utils._json import openapi_dumps log: logging.Logger = logging.getLogger(__name__) @@ -563,6 +564,10 @@ def _build_request( files = cast(HttpxRequestFiles, ForceMultipartDict()) prepared_url = self._prepare_url(options.url) + # preserve hard-coded query params from the url + if params and prepared_url.query: + params = {**dict(prepared_url.params.items()), **params} + prepared_url = prepared_url.copy_with(raw_path=prepared_url.raw_path.split(b"?", 1)[0]) if "_" in prepared_url.host: # work around https://github.com/encode/httpx/discussions/2880 kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")} @@ -578,8 +583,10 @@ def _build_request( 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 + elif not files: + # Don't set content when JSON is sent as multipart/form-data, + # since httpx's content param overrides other body arguments + kwargs["content"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None kwargs["files"] = files else: headers.pop("Content-Type", None) diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 03cb74b4e69..898c9afa236 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -69,6 +69,7 @@ aisearch, alerting, firewall, + rulesets, snippets, spectrum, hostnames, @@ -112,6 +113,7 @@ durable_objects, r2_data_catalog, request_tracers, + security_center, brand_protection, content_scanning, custom_hostnames, @@ -139,76 +141,69 @@ 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.ips.ips import IPsResource, AsyncIPsResource 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.fraud.fraud import FraudResource, AsyncFraudResource 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.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.filters.filters import FiltersResource, AsyncFiltersResource 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.audit_logs.audit_logs import AuditLogsResource, AsyncAuditLogsResource from .resources.hyperdrive.hyperdrive import HyperdriveResource, AsyncHyperdriveResource + from .resources.page_rules.page_rules import PageRulesResource, AsyncPageRulesResource 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.memberships.memberships import MembershipsResource, AsyncMembershipsResource from .resources.page_shield.page_shield import PageShieldResource, AsyncPageShieldResource + from .resources.rate_limits.rate_limits import RateLimitsResource, AsyncRateLimitsResource from .resources.url_scanner.url_scanner import URLScannerResource, AsyncURLScannerResource from .resources.connectivity.connectivity import ConnectivityResource, AsyncConnectivityResource from .resources.custom_pages.custom_pages import CustomPagesResource, AsyncCustomPagesResource 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.security_txt.security_txt import SecurityTXTResource, AsyncSecurityTXTResource from .resources.abuse_reports.abuse_reports import AbuseReportsResource, AsyncAbuseReportsResource from .resources.email_routing.email_routing import EmailRoutingResource, AsyncEmailRoutingResource from .resources.email_sending.email_sending import EmailSendingResource, AsyncEmailSendingResource @@ -216,17 +211,16 @@ 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.bot_management.bot_management import BotManagementResource, AsyncBotManagementResource from .resources.cloudforce_one.cloudforce_one import CloudforceOneResource, AsyncCloudforceOneResource + from .resources.dcv_delegation.dcv_delegation import DCVDelegationResource, AsyncDCVDelegationResource 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 @@ -236,11 +230,28 @@ 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.url_normalization.url_normalization import URLNormalizationResource, AsyncURLNormalizationResource + from .resources.custom_nameservers.custom_nameservers import ( + CustomNameserversResource, + AsyncCustomNameserversResource, + ) from .resources.google_tag_gateway.google_tag_gateway import GoogleTagGatewayResource, AsyncGoogleTagGatewayResource + from .resources.managed_transforms.managed_transforms import ( + ManagedTransformsResource, + AsyncManagedTransformsResource, + ) + from .resources.client_certificates.client_certificates import ( + ClientCertificatesResource, + AsyncClientCertificatesResource, + ) from .resources.custom_certificates.custom_certificates import ( CustomCertificatesResource, AsyncCustomCertificatesResource, ) + from .resources.keyless_certificates.keyless_certificates import ( + KeylessCertificatesResource, + AsyncKeylessCertificatesResource, + ) from .resources.network_interconnects.network_interconnects import ( NetworkInterconnectsResource, AsyncNetworkInterconnectsResource, @@ -257,6 +268,10 @@ MagicCloudNetworkingResource, AsyncMagicCloudNetworkingResource, ) + from .resources.origin_ca_certificates.origin_ca_certificates import ( + OriginCACertificatesResource, + AsyncOriginCACertificatesResource, + ) from .resources.origin_tls_client_auth.origin_tls_client_auth import ( OriginTLSClientAuthResource, AsyncOriginTLSClientAuthResource, @@ -273,6 +288,10 @@ MagicNetworkMonitoringResource, AsyncMagicNetworkMonitoringResource, ) + from .resources.origin_post_quantum_encryption.origin_post_quantum_encryption import ( + OriginPostQuantumEncryptionResource, + AsyncOriginPostQuantumEncryptionResource, + ) __all__ = [ "Timeout", @@ -292,6 +311,8 @@ class Cloudflare(SyncAPIClient): api_key: str | None api_email: str | None user_service_key: str | None + account_id: str | None + zone_id: str | None def __init__( self, @@ -300,6 +321,8 @@ def __init__( api_key: str | None = None, api_email: str | None = None, user_service_key: str | None = None, + account_id: str | None = None, + zone_id: str | None = None, base_url: str | httpx.URL | None = None, api_version: str | None = None, timeout: float | Timeout | None | NotGiven = not_given, @@ -327,6 +350,8 @@ def __init__( - `api_key` from `CLOUDFLARE_API_KEY` - `api_email` from `CLOUDFLARE_EMAIL` - `user_service_key` from `CLOUDFLARE_API_USER_SERVICE_KEY` + - `account_id` from `CLOUDFLARE_ACCOUNT_ID` + - `zone_id` from `CLOUDFLARE_ZONE_ID` """ if api_token is None: api_token = os.environ.get("CLOUDFLARE_API_TOKEN") @@ -344,6 +369,14 @@ def __init__( user_service_key = os.environ.get("CLOUDFLARE_API_USER_SERVICE_KEY") self.user_service_key = user_service_key + if account_id is None: + account_id = os.environ.get("CLOUDFLARE_ACCOUNT_ID") + self.account_id = account_id + + if zone_id is None: + zone_id = os.environ.get("CLOUDFLARE_ZONE_ID") + self.zone_id = zone_id + if base_url is None: base_url = os.environ.get("CLOUDFLARE_BASE_URL") if base_url is None: @@ -604,6 +637,12 @@ def page_shield(self) -> 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 @@ -952,6 +991,12 @@ def aisearch(self) -> 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 @@ -1078,6 +1123,8 @@ def copy( api_key: str | None = None, api_email: str | None = None, user_service_key: str | None = None, + account_id: str | None = None, + zone_id: str | None = None, base_url: str | httpx.URL | None = None, api_version: str | None = None, timeout: float | Timeout | None | NotGiven = not_given, @@ -1116,6 +1163,8 @@ def copy( api_key=api_key or self.api_key, api_email=api_email or self.api_email, user_service_key=user_service_key or self.user_service_key, + account_id=account_id or self.account_id, + zone_id=zone_id or self.zone_id, 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, @@ -1130,6 +1179,24 @@ def copy( # client.with_options(timeout=10).foo.create(...) with_options = copy + def _get_account_id_path_param(self) -> str: + from_client = self.account_id + if from_client is not None: + return from_client + + raise ValueError( + "Missing account_id argument; Please provide it at the client level, e.g. Cloudflare(account_id='abcd') or per method." + ) + + def _get_zone_id_path_param(self) -> str: + from_client = self.zone_id + if from_client is not None: + return from_client + + raise ValueError( + "Missing zone_id argument; Please provide it at the client level, e.g. Cloudflare(zone_id='abcd') or per method." + ) + @override def _make_status_error( self, @@ -1170,6 +1237,8 @@ class AsyncCloudflare(AsyncAPIClient): api_key: str | None api_email: str | None user_service_key: str | None + account_id: str | None + zone_id: str | None def __init__( self, @@ -1178,6 +1247,8 @@ def __init__( api_key: str | None = None, api_email: str | None = None, user_service_key: str | None = None, + account_id: str | None = None, + zone_id: str | None = None, base_url: str | httpx.URL | None = None, api_version: str | None = None, timeout: float | Timeout | None | NotGiven = not_given, @@ -1205,6 +1276,8 @@ def __init__( - `api_key` from `CLOUDFLARE_API_KEY` - `api_email` from `CLOUDFLARE_EMAIL` - `user_service_key` from `CLOUDFLARE_API_USER_SERVICE_KEY` + - `account_id` from `CLOUDFLARE_ACCOUNT_ID` + - `zone_id` from `CLOUDFLARE_ZONE_ID` """ if api_token is None: api_token = os.environ.get("CLOUDFLARE_API_TOKEN") @@ -1222,6 +1295,14 @@ def __init__( user_service_key = os.environ.get("CLOUDFLARE_API_USER_SERVICE_KEY") self.user_service_key = user_service_key + if account_id is None: + account_id = os.environ.get("CLOUDFLARE_ACCOUNT_ID") + self.account_id = account_id + + if zone_id is None: + zone_id = os.environ.get("CLOUDFLARE_ZONE_ID") + self.zone_id = zone_id + if base_url is None: base_url = os.environ.get("CLOUDFLARE_BASE_URL") if base_url is None: @@ -1482,6 +1563,12 @@ def page_shield(self) -> 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 @@ -1830,6 +1917,12 @@ def aisearch(self) -> 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 @@ -1956,6 +2049,8 @@ def copy( api_key: str | None = None, api_email: str | None = None, user_service_key: str | None = None, + account_id: str | None = None, + zone_id: str | None = None, base_url: str | httpx.URL | None = None, api_version: str | None = None, timeout: float | Timeout | None | NotGiven = not_given, @@ -1994,6 +2089,8 @@ def copy( api_key=api_key or self.api_key, api_email=api_email or self.api_email, user_service_key=user_service_key or self.user_service_key, + account_id=account_id or self.account_id, + zone_id=zone_id or self.zone_id, 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, @@ -2008,6 +2105,24 @@ def copy( # client.with_options(timeout=10).foo.create(...) with_options = copy + def _get_account_id_path_param(self) -> str: + from_client = self.account_id + if from_client is not None: + return from_client + + raise ValueError( + "Missing account_id argument; Please provide it at the client level, e.g. AsyncCloudflare(account_id='abcd') or per method." + ) + + def _get_zone_id_path_param(self) -> str: + from_client = self.zone_id + if from_client is not None: + return from_client + + raise ValueError( + "Missing zone_id argument; Please provide it at the client level, e.g. AsyncCloudflare(zone_id='abcd') or per method." + ) + @override def _make_status_error( self, @@ -2288,6 +2403,12 @@ def page_shield(self) -> page_shield.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 @@ -2638,6 +2759,12 @@ def aisearch(self) -> aisearch.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 @@ -2921,6 +3048,12 @@ def page_shield(self) -> page_shield.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 @@ -3271,6 +3404,12 @@ def aisearch(self) -> aisearch.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 @@ -3554,6 +3693,12 @@ def page_shield(self) -> page_shield.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 @@ -3904,6 +4049,12 @@ def aisearch(self) -> aisearch.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 @@ -4189,6 +4340,12 @@ def page_shield(self) -> page_shield.AsyncPageShieldResourceWithStreamingRespons 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 @@ -4547,6 +4704,12 @@ def aisearch(self) -> aisearch.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 diff --git a/src/cloudflare/_compat.py b/src/cloudflare/_compat.py index be9bcfb2c1f..946de7d6921 100644 --- a/src/cloudflare/_compat.py +++ b/src/cloudflare/_compat.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload from datetime import date, datetime -from typing_extensions import Self, Literal +from typing_extensions import Self, Literal, TypedDict import pydantic from pydantic.fields import FieldInfo @@ -132,6 +132,10 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str: return model.model_dump_json(indent=indent) +class _ModelDumpKwargs(TypedDict, total=False): + by_alias: bool + + def model_dump( model: pydantic.BaseModel, *, @@ -140,8 +144,12 @@ def model_dump( exclude_defaults: bool = False, warnings: bool = True, mode: Literal["json", "python"] = "python", + by_alias: bool | None = None, ) -> dict[str, Any]: if (not PYDANTIC_V1) or hasattr(model, "model_dump"): + kwargs: _ModelDumpKwargs = {} + if by_alias is not None: + kwargs["by_alias"] = by_alias return model.model_dump( mode=mode, exclude=exclude, @@ -149,13 +157,12 @@ def model_dump( exclude_defaults=exclude_defaults, # warnings are not supported in Pydantic v1 warnings=True if PYDANTIC_V1 else warnings, + **kwargs, ) return cast( "dict[str, Any]", model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast] - exclude=exclude, - exclude_unset=exclude_unset, - exclude_defaults=exclude_defaults, + exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, by_alias=bool(by_alias) ), ) diff --git a/src/cloudflare/_qs.py b/src/cloudflare/_qs.py index ada6fd3f721..de8c99bc63a 100644 --- a/src/cloudflare/_qs.py +++ b/src/cloudflare/_qs.py @@ -101,7 +101,10 @@ def _stringify_item( items.extend(self._stringify_item(key, item, opts)) return items elif array_format == "indices": - raise NotImplementedError("The array indices format is not supported yet") + items = [] + for i, item in enumerate(value): + items.extend(self._stringify_item(f"{key}[{i}]", item, opts)) + return items elif array_format == "brackets": items = [] key = key + "[]" diff --git a/src/cloudflare/_response.py b/src/cloudflare/_response.py index c23d0dd7811..2dceb9df741 100644 --- a/src/cloudflare/_response.py +++ b/src/cloudflare/_response.py @@ -152,6 +152,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: ), response=self.http_response, client=cast(Any, self._client), + options=self._options, ), ) @@ -162,6 +163,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: cast_to=extract_stream_chunk_type(self._stream_cls), response=self.http_response, client=cast(Any, self._client), + options=self._options, ), ) @@ -175,6 +177,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: cast_to=cast_to, response=self.http_response, client=cast(Any, self._client), + options=self._options, ), ) diff --git a/src/cloudflare/_streaming.py b/src/cloudflare/_streaming.py index d26f2aaf70a..d995ba7bc49 100644 --- a/src/cloudflare/_streaming.py +++ b/src/cloudflare/_streaming.py @@ -4,7 +4,7 @@ import json import inspect from types import TracebackType -from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, AsyncIterator, cast +from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, Optional, AsyncIterator, cast from typing_extensions import Self, Protocol, TypeGuard, override, get_origin, runtime_checkable import httpx @@ -13,6 +13,7 @@ if TYPE_CHECKING: from ._client import Cloudflare, AsyncCloudflare + from ._models import FinalRequestOptions _T = TypeVar("_T") @@ -22,7 +23,7 @@ class Stream(Generic[_T]): """Provides the core interface to iterate over a synchronous stream response.""" response: httpx.Response - + _options: Optional[FinalRequestOptions] = None _decoder: SSEBytesDecoder def __init__( @@ -31,10 +32,12 @@ def __init__( cast_to: type[_T], response: httpx.Response, client: Cloudflare, + options: Optional[FinalRequestOptions] = None, ) -> None: self.response = response self._cast_to = cast_to self._client = client + self._options = options self._decoder = client._make_sse_decoder() self._iterator = self.__stream__() @@ -85,7 +88,7 @@ class AsyncStream(Generic[_T]): """Provides the core interface to iterate over an asynchronous stream response.""" response: httpx.Response - + _options: Optional[FinalRequestOptions] = None _decoder: SSEDecoder | SSEBytesDecoder def __init__( @@ -94,10 +97,12 @@ def __init__( cast_to: type[_T], response: httpx.Response, client: AsyncCloudflare, + options: Optional[FinalRequestOptions] = None, ) -> None: self.response = response self._cast_to = cast_to self._client = client + self._options = options self._decoder = client._make_sse_decoder() self._iterator = self.__stream__() diff --git a/src/cloudflare/_utils/__init__.py b/src/cloudflare/_utils/__init__.py index dc64e29a1c0..10cb66d2d95 100644 --- a/src/cloudflare/_utils/__init__.py +++ b/src/cloudflare/_utils/__init__.py @@ -1,3 +1,4 @@ +from ._path import path_template as path_template from ._sync import asyncify as asyncify from ._proxy import LazyProxy as LazyProxy from ._utils import ( diff --git a/src/cloudflare/_utils/_compat.py b/src/cloudflare/_utils/_compat.py index dd703233c56..2c70b299ce4 100644 --- a/src/cloudflare/_utils/_compat.py +++ b/src/cloudflare/_utils/_compat.py @@ -26,7 +26,7 @@ def is_union(tp: Optional[Type[Any]]) -> bool: else: import types - return tp is Union or tp is types.UnionType + return tp is Union or tp is types.UnionType # type: ignore[comparison-overlap] def is_typeddict(tp: Type[Any]) -> bool: diff --git a/src/cloudflare/_utils/_json.py b/src/cloudflare/_utils/_json.py new file mode 100644 index 00000000000..60584214af7 --- /dev/null +++ b/src/cloudflare/_utils/_json.py @@ -0,0 +1,35 @@ +import json +from typing import Any +from datetime import datetime +from typing_extensions import override + +import pydantic + +from .._compat import model_dump + + +def openapi_dumps(obj: Any) -> bytes: + """ + Serialize an object to UTF-8 encoded JSON bytes. + + Extends the standard json.dumps with support for additional types + commonly used in the SDK, such as `datetime`, `pydantic.BaseModel`, etc. + """ + return json.dumps( + obj, + cls=_CustomEncoder, + # Uses the same defaults as httpx's JSON serialization + ensure_ascii=False, + separators=(",", ":"), + allow_nan=False, + ).encode() + + +class _CustomEncoder(json.JSONEncoder): + @override + def default(self, o: Any) -> Any: + if isinstance(o, datetime): + return o.isoformat() + if isinstance(o, pydantic.BaseModel): + return model_dump(o, exclude_unset=True, mode="json", by_alias=True) + return super().default(o) diff --git a/src/cloudflare/_utils/_path.py b/src/cloudflare/_utils/_path.py new file mode 100644 index 00000000000..4d6e1e4cbca --- /dev/null +++ b/src/cloudflare/_utils/_path.py @@ -0,0 +1,127 @@ +from __future__ import annotations + +import re +from typing import ( + Any, + Mapping, + Callable, +) +from urllib.parse import quote + +# Matches '.' or '..' where each dot is either literal or percent-encoded (%2e / %2E). +_DOT_SEGMENT_RE = re.compile(r"^(?:\.|%2[eE]){1,2}$") + +_PLACEHOLDER_RE = re.compile(r"\{(\w+)\}") + + +def _quote_path_segment_part(value: str) -> str: + """Percent-encode `value` for use in a URI path segment. + + Considers characters not in `pchar` set from RFC 3986 §3.3 to be unsafe. + https://datatracker.ietf.org/doc/html/rfc3986#section-3.3 + """ + # quote() already treats unreserved characters (letters, digits, and -._~) + # as safe, so we only need to add sub-delims, ':', and '@'. + # Notably, unlike the default `safe` for quote(), / is unsafe and must be quoted. + return quote(value, safe="!$&'()*+,;=:@") + + +def _quote_query_part(value: str) -> str: + """Percent-encode `value` for use in a URI query string. + + Considers &, = and characters not in `query` set from RFC 3986 §3.4 to be unsafe. + https://datatracker.ietf.org/doc/html/rfc3986#section-3.4 + """ + return quote(value, safe="!$'()*+,;:@/?") + + +def _quote_fragment_part(value: str) -> str: + """Percent-encode `value` for use in a URI fragment. + + Considers characters not in `fragment` set from RFC 3986 §3.5 to be unsafe. + https://datatracker.ietf.org/doc/html/rfc3986#section-3.5 + """ + return quote(value, safe="!$&'()*+,;=:@/?") + + +def _interpolate( + template: str, + values: Mapping[str, Any], + quoter: Callable[[str], str], +) -> str: + """Replace {name} placeholders in `template`, quoting each value with `quoter`. + + Placeholder names are looked up in `values`. + + Raises: + KeyError: If a placeholder is not found in `values`. + """ + # re.split with a capturing group returns alternating + # [text, name, text, name, ..., text] elements. + parts = _PLACEHOLDER_RE.split(template) + + for i in range(1, len(parts), 2): + name = parts[i] + if name not in values: + raise KeyError(f"a value for placeholder {{{name}}} was not provided") + val = values[name] + if val is None: + parts[i] = "null" + elif isinstance(val, bool): + parts[i] = "true" if val else "false" + else: + parts[i] = quoter(str(values[name])) + + return "".join(parts) + + +def path_template(template: str, /, **kwargs: Any) -> str: + """Interpolate {name} placeholders in `template` from keyword arguments. + + Args: + template: The template string containing {name} placeholders. + **kwargs: Keyword arguments to interpolate into the template. + + Returns: + The template with placeholders interpolated and percent-encoded. + + Safe characters for percent-encoding are dependent on the URI component. + Placeholders in path and fragment portions are percent-encoded where the `segment` + and `fragment` sets from RFC 3986 respectively are considered safe. + Placeholders in the query portion are percent-encoded where the `query` set from + RFC 3986 §3.3 is considered safe except for = and & characters. + + Raises: + KeyError: If a placeholder is not found in `kwargs`. + ValueError: If resulting path contains /./ or /../ segments (including percent-encoded dot-segments). + """ + # Split the template into path, query, and fragment portions. + fragment_template: str | None = None + query_template: str | None = None + + rest = template + if "#" in rest: + rest, fragment_template = rest.split("#", 1) + if "?" in rest: + rest, query_template = rest.split("?", 1) + path_template = rest + + # Interpolate each portion with the appropriate quoting rules. + path_result = _interpolate(path_template, kwargs, _quote_path_segment_part) + + # Reject dot-segments (. and ..) in the final assembled path. The check + # runs after interpolation so that adjacent placeholders or a mix of static + # text and placeholders that together form a dot-segment are caught. + # Also reject percent-encoded dot-segments to protect against incorrectly + # implemented normalization in servers/proxies. + for segment in path_result.split("/"): + if _DOT_SEGMENT_RE.match(segment): + raise ValueError(f"Constructed path {path_result!r} contains dot-segment {segment!r} which is not allowed") + + result = path_result + if query_template is not None: + result += "?" + _interpolate(query_template, kwargs, _quote_query_part) + if fragment_template is not None: + result += "#" + _interpolate(fragment_template, kwargs, _quote_fragment_part) + + return result diff --git a/src/cloudflare/_utils/_utils.py b/src/cloudflare/_utils/_utils.py index eec7f4a1f23..63b8cd602a6 100644 --- a/src/cloudflare/_utils/_utils.py +++ b/src/cloudflare/_utils/_utils.py @@ -86,8 +86,9 @@ def _extract_items( index += 1 if is_dict(obj): try: - # We are at the last entry in the path so we must remove the field - if (len(path)) == index: + # Remove the field if there are no more dict keys in the path, + # only "" traversal markers or end. + if all(p == "" for p in path[index:]): item = obj.pop(key) else: item = obj[key] diff --git a/src/cloudflare/resources/abuse_reports/abuse_reports.py b/src/cloudflare/resources/abuse_reports/abuse_reports.py index 2b4cbdb2f5a..e1e4c79487a 100644 --- a/src/cloudflare/resources/abuse_reports/abuse_reports.py +++ b/src/cloudflare/resources/abuse_reports/abuse_reports.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -65,7 +65,7 @@ def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_dmca"], address1: str, agent_name: str, @@ -175,7 +175,7 @@ def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_trademark"], email: str, email2: str, @@ -266,7 +266,7 @@ def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_general"], email: str, email2: str, @@ -364,7 +364,7 @@ def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_phishing"], email: str, email2: str, @@ -450,7 +450,7 @@ def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_children"], email: str, email2: str, @@ -540,7 +540,7 @@ def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_threat"], email: str, email2: str, @@ -622,7 +622,7 @@ def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_registrar_whois"], email: str, email2: str, @@ -698,7 +698,7 @@ def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_ncsei"], email: str, email2: str, @@ -779,7 +779,6 @@ def create( @required_args( [ - "account_id", "act", "address1", "agent_name", @@ -797,7 +796,6 @@ def create( "urls", ], [ - "account_id", "act", "email", "email2", @@ -810,19 +808,8 @@ def create( "trademark_symbol", "urls", ], + ["act", "email", "email2", "host_notification", "justification", "name", "owner_notification", "urls"], [ - "account_id", - "act", - "email", - "email2", - "host_notification", - "justification", - "name", - "owner_notification", - "urls", - ], - [ - "account_id", "act", "email", "email2", @@ -833,9 +820,8 @@ def create( "owner_notification", "urls", ], - ["account_id", "act", "email", "email2", "name", "owner_notification", "urls"], + ["act", "email", "email2", "name", "owner_notification", "urls"], [ - "account_id", "act", "email", "email2", @@ -850,7 +836,7 @@ def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_dmca"] | Literal["abuse_trademark"] | Literal["abuse_general"] @@ -896,12 +882,16 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/abuse-reports/{report_param}", account_id=account_id, report_param=report_param + ), body=maybe_transform( { "act": act, @@ -951,7 +941,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, created_after: str | Omit = omit, created_before: str | Omit = omit, domain: str | Omit = omit, @@ -998,10 +988,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/abuse-reports", account_id=account_id), page=SyncV4PagePagination[Optional[AbuseReportListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -1030,7 +1022,7 @@ def get( self, report_param: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1050,12 +1042,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/abuse-reports/{report_param}", account_id=account_id, report_param=report_param + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1096,7 +1092,7 @@ async def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_dmca"], address1: str, agent_name: str, @@ -1206,7 +1202,7 @@ async def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_trademark"], email: str, email2: str, @@ -1297,7 +1293,7 @@ async def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_general"], email: str, email2: str, @@ -1395,7 +1391,7 @@ async def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_phishing"], email: str, email2: str, @@ -1481,7 +1477,7 @@ async def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_children"], email: str, email2: str, @@ -1571,7 +1567,7 @@ async def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_threat"], email: str, email2: str, @@ -1653,7 +1649,7 @@ async def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_registrar_whois"], email: str, email2: str, @@ -1729,7 +1725,7 @@ async def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_ncsei"], email: str, email2: str, @@ -1810,7 +1806,6 @@ async def create( @required_args( [ - "account_id", "act", "address1", "agent_name", @@ -1828,7 +1823,6 @@ async def create( "urls", ], [ - "account_id", "act", "email", "email2", @@ -1841,19 +1835,8 @@ async def create( "trademark_symbol", "urls", ], + ["act", "email", "email2", "host_notification", "justification", "name", "owner_notification", "urls"], [ - "account_id", - "act", - "email", - "email2", - "host_notification", - "justification", - "name", - "owner_notification", - "urls", - ], - [ - "account_id", "act", "email", "email2", @@ -1864,9 +1847,8 @@ async def create( "owner_notification", "urls", ], - ["account_id", "act", "email", "email2", "name", "owner_notification", "urls"], + ["act", "email", "email2", "name", "owner_notification", "urls"], [ - "account_id", "act", "email", "email2", @@ -1881,7 +1863,7 @@ async def create( self, report_param: str, *, - account_id: str, + account_id: str | None = None, act: Literal["abuse_dmca"] | Literal["abuse_trademark"] | Literal["abuse_general"] @@ -1927,12 +1909,16 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/abuse-reports/{report_param}", account_id=account_id, report_param=report_param + ), body=await async_maybe_transform( { "act": act, @@ -1982,7 +1968,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, created_after: str | Omit = omit, created_before: str | Omit = omit, domain: str | Omit = omit, @@ -2029,10 +2015,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/abuse-reports", account_id=account_id), page=AsyncV4PagePagination[Optional[AbuseReportListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -2061,7 +2049,7 @@ async def get( self, report_param: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -2081,12 +2069,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/abuse-reports/{report_param}", account_id=account_id, report_param=report_param + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/abuse_reports/api.md b/src/cloudflare/resources/abuse_reports/api.md new file mode 100644 index 00000000000..30ecdfde687 --- /dev/null +++ b/src/cloudflare/resources/abuse_reports/api.md @@ -0,0 +1,30 @@ +# AbuseReports + +Types: + +```python +from cloudflare.types.abuse_reports import ( + AbuseReportCreateResponse, + AbuseReportListResponse, + AbuseReportGetResponse, +) +``` + +Methods: + +- 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 + +## Mitigations + +Types: + +```python +from cloudflare.types.abuse_reports import MitigationListResponse, MitigationReviewResponse +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/abuse_reports/mitigations.py b/src/cloudflare/resources/abuse_reports/mitigations.py index 854d18824d2..f0714b399b2 100644 --- a/src/cloudflare/resources/abuse_reports/mitigations.py +++ b/src/cloudflare/resources/abuse_reports/mitigations.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def list( self, report_id: str, *, - account_id: str, + account_id: str | None = None, effective_after: str | Omit = omit, effective_before: str | Omit = omit, entity_type: Literal["url_pattern", "account", "zone"] | Omit = omit, @@ -115,12 +115,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/abuse-reports/{report_id}/mitigations", + account_id=account_id, + report_id=report_id, + ), page=SyncV4PagePagination[Optional[MitigationListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -148,7 +154,7 @@ def review( self, report_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -171,12 +177,18 @@ def review( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/abuse-reports/{report_id}/mitigations/appeal", + account_id=account_id, + report_id=report_id, + ), page=SyncSinglePage[MitigationReviewResponse], body=maybe_transform({"appeals": appeals}, mitigation_review_params.MitigationReviewParams), options=make_request_options( @@ -211,7 +223,7 @@ def list( self, report_id: str, *, - account_id: str, + account_id: str | None = None, effective_after: str | Omit = omit, effective_before: str | Omit = omit, entity_type: Literal["url_pattern", "account", "zone"] | Omit = omit, @@ -276,12 +288,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/abuse-reports/{report_id}/mitigations", + account_id=account_id, + report_id=report_id, + ), page=AsyncV4PagePagination[Optional[MitigationListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -309,7 +327,7 @@ def review( self, report_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -332,12 +350,18 @@ def review( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/abuse-reports/{report_id}/mitigations/appeal", + account_id=account_id, + report_id=report_id, + ), page=AsyncSinglePage[MitigationReviewResponse], body=maybe_transform({"appeals": appeals}, mitigation_review_params.MitigationReviewParams), options=make_request_options( diff --git a/src/cloudflare/resources/accounts/accounts.py b/src/cloudflare/resources/accounts/accounts.py index aedb92f84e7..301d01381e7 100644 --- a/src/cloudflare/resources/accounts/accounts.py +++ b/src/cloudflare/resources/accounts/accounts.py @@ -24,7 +24,7 @@ AsyncMembersResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from .logs.logs import ( LogsResource, @@ -161,7 +161,7 @@ def create( def update( self, *, - account_id: str, + account_id: str | None = None, id: str, name: str, type: Literal["standard", "enterprise"], @@ -196,10 +196,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}", account_id=account_id), body=maybe_transform( { "id": id, @@ -278,7 +280,7 @@ def list( def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -303,10 +305,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -320,7 +324,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -342,10 +346,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -451,7 +457,7 @@ async def create( async def update( self, *, - account_id: str, + account_id: str | None = None, id: str, name: str, type: Literal["standard", "enterprise"], @@ -486,10 +492,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}", account_id=account_id), body=await async_maybe_transform( { "id": id, @@ -568,7 +576,7 @@ def list( async def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -593,10 +601,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -610,7 +620,7 @@ async def delete( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -632,10 +642,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/accounts/api.md b/src/cloudflare/resources/accounts/api.md new file mode 100644 index 00000000000..47d53810d58 --- /dev/null +++ b/src/cloudflare/resources/accounts/api.md @@ -0,0 +1,103 @@ +# Accounts + +Types: + +```python +from cloudflare.types.accounts import Account, AccountDeleteResponse +``` + +Methods: + +- 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, MemberDeleteResponse +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/accounts/logs/audit.py b/src/cloudflare/resources/accounts/logs/audit.py index 2eef3ce2f8d..f059652a65e 100644 --- a/src/cloudflare/resources/accounts/logs/audit.py +++ b/src/cloudflare/resources/accounts/logs/audit.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> AuditResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, before: Union[str, date], since: Union[str, date], id: audit_list_params.ID | Omit = omit, @@ -116,10 +116,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/logs/audit", account_id=account_id), page=SyncCursorPaginationAfter[AuditListResponse], options=make_request_options( extra_headers=extra_headers, @@ -186,7 +188,7 @@ def with_streaming_response(self) -> AsyncAuditResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, before: Union[str, date], since: Union[str, date], id: audit_list_params.ID | Omit = omit, @@ -253,10 +255,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/logs/audit", account_id=account_id), page=AsyncCursorPaginationAfter[AuditListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index 015215bb852..f69d6eb0ef4 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> MembersResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, email: str, roles: SequenceNotStr[str], status: Literal["accepted", "pending"] | Omit = omit, @@ -91,7 +91,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, email: str, policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy], status: Literal["accepted", "pending"] | Omit = omit, @@ -126,11 +126,11 @@ def create( """ ... - @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) + @required_args(["email", "roles"], ["email", "policies"]) def create( self, *, - account_id: str, + account_id: str | None = None, email: str, roles: SequenceNotStr[str] | Omit = omit, status: Literal["accepted", "pending"] | Omit = omit, @@ -142,10 +142,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Member]: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/members", + path_template("/accounts/{account_id}/members", account_id=account_id), body=maybe_transform( { "email": email, @@ -170,7 +172,7 @@ def update( self, member_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -204,7 +206,7 @@ def update( self, member_id: str, *, - account_id: str, + account_id: str | None = None, policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -233,12 +235,11 @@ def update( """ ... - @required_args(["account_id"], ["account_id", "policies"]) def update( self, member_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -248,12 +249,14 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Member]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") return self._put( - f"/accounts/{account_id}/members/{member_id}", + path_template("/accounts/{account_id}/members/{member_id}", account_id=account_id, member_id=member_id), body=maybe_transform( { "roles": roles, @@ -274,7 +277,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["user.first_name", "user.last_name", "user.email", "status"] | Omit = omit, page: float | Omit = omit, @@ -311,10 +314,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/members", + path_template("/accounts/{account_id}/members", account_id=account_id), page=SyncV4PagePaginationArray[Member], options=make_request_options( extra_headers=extra_headers, @@ -339,7 +344,7 @@ def delete( self, member_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -363,12 +368,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") return self._delete( - f"/accounts/{account_id}/members/{member_id}", + path_template("/accounts/{account_id}/members/{member_id}", account_id=account_id, member_id=member_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -383,7 +390,7 @@ def get( self, member_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -407,12 +414,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") return self._get( - f"/accounts/{account_id}/members/{member_id}", + path_template("/accounts/{account_id}/members/{member_id}", account_id=account_id, member_id=member_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -448,7 +457,7 @@ def with_streaming_response(self) -> AsyncMembersResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, email: str, roles: SequenceNotStr[str], status: Literal["accepted", "pending"] | Omit = omit, @@ -487,7 +496,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, email: str, policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy], status: Literal["accepted", "pending"] | Omit = omit, @@ -522,11 +531,11 @@ async def create( """ ... - @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) + @required_args(["email", "roles"], ["email", "policies"]) async def create( self, *, - account_id: str, + account_id: str | None = None, email: str, roles: SequenceNotStr[str] | Omit = omit, status: Literal["accepted", "pending"] | Omit = omit, @@ -538,10 +547,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Member]: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/members", + path_template("/accounts/{account_id}/members", account_id=account_id), body=await async_maybe_transform( { "email": email, @@ -566,7 +577,7 @@ async def update( self, member_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -600,7 +611,7 @@ async def update( self, member_id: str, *, - account_id: str, + account_id: str | None = None, policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -629,12 +640,11 @@ async def update( """ ... - @required_args(["account_id"], ["account_id", "policies"]) async def update( self, member_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -644,12 +654,14 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Member]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") return await self._put( - f"/accounts/{account_id}/members/{member_id}", + path_template("/accounts/{account_id}/members/{member_id}", account_id=account_id, member_id=member_id), body=await async_maybe_transform( { "roles": roles, @@ -670,7 +682,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["user.first_name", "user.last_name", "user.email", "status"] | Omit = omit, page: float | Omit = omit, @@ -707,10 +719,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/members", + path_template("/accounts/{account_id}/members", account_id=account_id), page=AsyncV4PagePaginationArray[Member], options=make_request_options( extra_headers=extra_headers, @@ -735,7 +749,7 @@ async def delete( self, member_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -759,12 +773,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") return await self._delete( - f"/accounts/{account_id}/members/{member_id}", + path_template("/accounts/{account_id}/members/{member_id}", account_id=account_id, member_id=member_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -779,7 +795,7 @@ async def get( self, member_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -803,12 +819,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") return await self._get( - f"/accounts/{account_id}/members/{member_id}", + path_template("/accounts/{account_id}/members/{member_id}", account_id=account_id, member_id=member_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/accounts/roles.py b/src/cloudflare/resources/accounts/roles.py index 399ad9f9449..fd478bef16d 100644 --- a/src/cloudflare/resources/accounts/roles.py +++ b/src/cloudflare/resources/accounts/roles.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> RolesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -76,10 +76,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/roles", + path_template("/accounts/{account_id}/roles", account_id=account_id), page=SyncV4PagePaginationArray[Role], options=make_request_options( extra_headers=extra_headers, @@ -101,7 +103,7 @@ def get( self, role_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -125,12 +127,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/roles/{role_id}", account_id=account_id, role_id=role_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -165,7 +169,7 @@ def with_streaming_response(self) -> AsyncRolesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -193,10 +197,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/roles", + path_template("/accounts/{account_id}/roles", account_id=account_id), page=AsyncV4PagePaginationArray[Role], options=make_request_options( extra_headers=extra_headers, @@ -218,7 +224,7 @@ async def get( self, role_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -242,12 +248,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/roles/{role_id}", account_id=account_id, role_id=role_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/accounts/subscriptions.py b/src/cloudflare/resources/accounts/subscriptions.py index 7209c025dfa..18c404d7ddd 100644 --- a/src/cloudflare/resources/accounts/subscriptions.py +++ b/src/cloudflare/resources/accounts/subscriptions.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> SubscriptionsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -79,10 +79,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/subscriptions", account_id=account_id), body=maybe_transform( { "frequency": frequency, @@ -104,7 +106,7 @@ def update( self, subscription_identifier: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -134,6 +136,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_identifier: @@ -141,7 +145,11 @@ def update( f"Expected a non-empty value for `subscription_identifier` but received {subscription_identifier!r}" ) return self._put( - f"/accounts/{account_id}/subscriptions/{subscription_identifier}", + path_template( + "/accounts/{account_id}/subscriptions/{subscription_identifier}", + account_id=account_id, + subscription_identifier=subscription_identifier, + ), body=maybe_transform( { "frequency": frequency, @@ -163,7 +171,7 @@ def delete( self, subscription_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -187,6 +195,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_identifier: @@ -194,7 +204,11 @@ def delete( f"Expected a non-empty value for `subscription_identifier` but received {subscription_identifier!r}" ) return self._delete( - f"/accounts/{account_id}/subscriptions/{subscription_identifier}", + path_template( + "/accounts/{account_id}/subscriptions/{subscription_identifier}", + account_id=account_id, + subscription_identifier=subscription_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -208,7 +222,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -230,10 +244,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/subscriptions", account_id=account_id), page=SyncSinglePage[Subscription], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -265,7 +281,7 @@ def with_streaming_response(self) -> AsyncSubscriptionsResourceWithStreamingResp async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -293,10 +309,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/subscriptions", account_id=account_id), body=await async_maybe_transform( { "frequency": frequency, @@ -318,7 +336,7 @@ async def update( self, subscription_identifier: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -348,6 +366,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_identifier: @@ -355,7 +375,11 @@ async def update( 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}", + path_template( + "/accounts/{account_id}/subscriptions/{subscription_identifier}", + account_id=account_id, + subscription_identifier=subscription_identifier, + ), body=await async_maybe_transform( { "frequency": frequency, @@ -377,7 +401,7 @@ async def delete( self, subscription_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -401,6 +425,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_identifier: @@ -408,7 +434,11 @@ async def delete( 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}", + path_template( + "/accounts/{account_id}/subscriptions/{subscription_identifier}", + account_id=account_id, + subscription_identifier=subscription_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -422,7 +452,7 @@ async def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -444,10 +474,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/subscriptions", account_id=account_id), page=AsyncSinglePage[Subscription], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/accounts/tokens/permission_groups.py b/src/cloudflare/resources/accounts/tokens/permission_groups.py index 2efe092f8ec..459dc683be4 100644 --- a/src/cloudflare/resources/accounts/tokens/permission_groups.py +++ b/src/cloudflare/resources/accounts/tokens/permission_groups.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> PermissionGroupsResourceWithStreamingRespon def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -77,10 +77,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens/permission_groups", account_id=account_id), page=SyncSinglePage[PermissionGroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -101,7 +103,7 @@ def list( def get( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -129,10 +131,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens/permission_groups", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -174,7 +178,7 @@ def with_streaming_response(self) -> AsyncPermissionGroupsResourceWithStreamingR def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -202,10 +206,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens/permission_groups", account_id=account_id), page=AsyncSinglePage[PermissionGroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -226,7 +232,7 @@ def list( async def get( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -254,10 +260,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens/permission_groups", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/accounts/tokens/tokens.py b/src/cloudflare/resources/accounts/tokens/tokens.py index eb6d7826528..5f65511d4c0 100644 --- a/src/cloudflare/resources/accounts/tokens/tokens.py +++ b/src/cloudflare/resources/accounts/tokens/tokens.py @@ -17,7 +17,7 @@ AsyncValueResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -78,7 +78,7 @@ def with_streaming_response(self) -> TokensResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, policies: Iterable[TokenPolicy], condition: token_create_params.Condition | Omit = omit, @@ -114,10 +114,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens", account_id=account_id), body=maybe_transform( { "name": name, @@ -142,7 +144,7 @@ def update( self, token_id: str, *, - account_id: str, + account_id: str | None = None, name: str, policies: Iterable[TokenPolicy], condition: token_update_params.Condition | Omit = omit, @@ -183,12 +185,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/tokens/{token_id}", account_id=account_id, token_id=token_id), body=maybe_transform( { "name": name, @@ -213,7 +217,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -244,10 +248,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens", account_id=account_id), page=SyncV4PagePaginationArray[Token], options=make_request_options( extra_headers=extra_headers, @@ -270,7 +276,7 @@ def delete( self, token_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -294,12 +300,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/tokens/{token_id}", account_id=account_id, token_id=token_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -314,7 +322,7 @@ def get( self, token_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -338,12 +346,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/tokens/{token_id}", account_id=account_id, token_id=token_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -357,7 +367,7 @@ def get( def verify( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -379,10 +389,12 @@ def verify( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens/verify", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -425,7 +437,7 @@ def with_streaming_response(self) -> AsyncTokensResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, policies: Iterable[TokenPolicy], condition: token_create_params.Condition | Omit = omit, @@ -461,10 +473,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -489,7 +503,7 @@ async def update( self, token_id: str, *, - account_id: str, + account_id: str | None = None, name: str, policies: Iterable[TokenPolicy], condition: token_update_params.Condition | Omit = omit, @@ -530,12 +544,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/tokens/{token_id}", account_id=account_id, token_id=token_id), body=await async_maybe_transform( { "name": name, @@ -560,7 +576,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -591,10 +607,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens", account_id=account_id), page=AsyncV4PagePaginationArray[Token], options=make_request_options( extra_headers=extra_headers, @@ -617,7 +635,7 @@ async def delete( self, token_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -641,12 +659,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/tokens/{token_id}", account_id=account_id, token_id=token_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -661,7 +681,7 @@ async def get( self, token_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -685,12 +705,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/tokens/{token_id}", account_id=account_id, token_id=token_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -704,7 +726,7 @@ async def get( async def verify( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -726,10 +748,12 @@ async def verify( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens/verify", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/accounts/tokens/value.py b/src/cloudflare/resources/accounts/tokens/value.py index 5e76bc54948..62cc5c437af 100644 --- a/src/cloudflare/resources/accounts/tokens/value.py +++ b/src/cloudflare/resources/accounts/tokens/value.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def update( self, token_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -73,12 +73,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens/{token_id}/value", account_id=account_id, token_id=token_id), body=maybe_transform(body, value_update_params.ValueUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -115,7 +117,7 @@ async def update( self, token_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -140,12 +142,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/tokens/{token_id}/value", account_id=account_id, token_id=token_id), body=await async_maybe_transform(body, value_update_params.ValueUpdateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/acm/api.md b/src/cloudflare/resources/acm/api.md new file mode 100644 index 00000000000..7dbc1c5dca9 --- /dev/null +++ b/src/cloudflare/resources/acm/api.md @@ -0,0 +1,35 @@ +# ACM + +## TotalTLS + +Types: + +```python +from cloudflare.types.acm import ( + CertificateAuthority, + TotalTLSUpdateResponse, + TotalTLSEditResponse, + TotalTLSGetResponse, +) +``` + +Methods: + +- 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] + +## CustomTrustStore + +Types: + +```python +from cloudflare.types.acm import CustomTrustStore, CustomTrustStoreDeleteResponse +``` + +Methods: + +- client.acm.custom_trust_store.create(\*, zone_id, \*\*params) -> Optional[CustomTrustStore] +- client.acm.custom_trust_store.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[CustomTrustStore] +- client.acm.custom_trust_store.delete(custom_origin_trust_store_id, \*, zone_id) -> Optional[CustomTrustStoreDeleteResponse] +- client.acm.custom_trust_store.get(custom_origin_trust_store_id, \*, zone_id) -> Optional[CustomTrustStore] diff --git a/src/cloudflare/resources/acm/custom_trust_store.py b/src/cloudflare/resources/acm/custom_trust_store.py index d7b87885150..7f12f52a217 100644 --- a/src/cloudflare/resources/acm/custom_trust_store.py +++ b/src/cloudflare/resources/acm/custom_trust_store.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> CustomTrustStoreResourceWithStreamingRespon def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: 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. @@ -74,10 +74,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/custom_trust_store", + path_template("/zones/{zone_id}/acm/custom_trust_store", zone_id=zone_id), body=maybe_transform( {"certificate": certificate}, custom_trust_store_create_params.CustomTrustStoreCreateParams ), @@ -94,7 +96,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, limit: int | Omit = omit, offset: int | Omit = omit, page: float | Omit = omit, @@ -128,10 +130,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/acm/custom_trust_store", + path_template("/zones/{zone_id}/acm/custom_trust_store", zone_id=zone_id), page=SyncV4PagePaginationArray[CustomTrustStore], options=make_request_options( extra_headers=extra_headers, @@ -155,7 +159,7 @@ def delete( self, custom_origin_trust_store_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -181,6 +185,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_origin_trust_store_id: @@ -188,7 +194,11 @@ def delete( f"Expected a non-empty value for `custom_origin_trust_store_id` but received {custom_origin_trust_store_id!r}" ) return self._delete( - f"/zones/{zone_id}/acm/custom_trust_store/{custom_origin_trust_store_id}", + path_template( + "/zones/{zone_id}/acm/custom_trust_store/{custom_origin_trust_store_id}", + zone_id=zone_id, + custom_origin_trust_store_id=custom_origin_trust_store_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -203,7 +213,7 @@ def get( self, custom_origin_trust_store_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -228,6 +238,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_origin_trust_store_id: @@ -235,7 +247,11 @@ def get( f"Expected a non-empty value for `custom_origin_trust_store_id` but received {custom_origin_trust_store_id!r}" ) return self._get( - f"/zones/{zone_id}/acm/custom_trust_store/{custom_origin_trust_store_id}", + path_template( + "/zones/{zone_id}/acm/custom_trust_store/{custom_origin_trust_store_id}", + zone_id=zone_id, + custom_origin_trust_store_id=custom_origin_trust_store_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -270,7 +286,7 @@ def with_streaming_response(self) -> AsyncCustomTrustStoreResourceWithStreamingR async def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: 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. @@ -295,10 +311,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/custom_trust_store", + path_template("/zones/{zone_id}/acm/custom_trust_store", zone_id=zone_id), body=await async_maybe_transform( {"certificate": certificate}, custom_trust_store_create_params.CustomTrustStoreCreateParams ), @@ -315,7 +333,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, limit: int | Omit = omit, offset: int | Omit = omit, page: float | Omit = omit, @@ -349,10 +367,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/acm/custom_trust_store", + path_template("/zones/{zone_id}/acm/custom_trust_store", zone_id=zone_id), page=AsyncV4PagePaginationArray[CustomTrustStore], options=make_request_options( extra_headers=extra_headers, @@ -376,7 +396,7 @@ async def delete( self, custom_origin_trust_store_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -402,6 +422,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_origin_trust_store_id: @@ -409,7 +431,11 @@ async def delete( f"Expected a non-empty value for `custom_origin_trust_store_id` but received {custom_origin_trust_store_id!r}" ) return await self._delete( - f"/zones/{zone_id}/acm/custom_trust_store/{custom_origin_trust_store_id}", + path_template( + "/zones/{zone_id}/acm/custom_trust_store/{custom_origin_trust_store_id}", + zone_id=zone_id, + custom_origin_trust_store_id=custom_origin_trust_store_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -424,7 +450,7 @@ async def get( self, custom_origin_trust_store_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -449,6 +475,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_origin_trust_store_id: @@ -456,7 +484,11 @@ async def get( f"Expected a non-empty value for `custom_origin_trust_store_id` but received {custom_origin_trust_store_id!r}" ) return await self._get( - f"/zones/{zone_id}/acm/custom_trust_store/{custom_origin_trust_store_id}", + path_template( + "/zones/{zone_id}/acm/custom_trust_store/{custom_origin_trust_store_id}", + zone_id=zone_id, + custom_origin_trust_store_id=custom_origin_trust_store_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/acm/total_tls.py b/src/cloudflare/resources/acm/total_tls.py index ed1c54d9f7e..9fbe1565d77 100644 --- a/src/cloudflare/resources/acm/total_tls.py +++ b/src/cloudflare/resources/acm/total_tls.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> TotalTLSResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -79,10 +79,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/acm/total_tls", zone_id=zone_id), body=maybe_transform( { "enabled": enabled, @@ -103,7 +105,7 @@ def update( def edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -132,10 +134,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/acm/total_tls", zone_id=zone_id), body=maybe_transform( { "enabled": enabled, @@ -156,7 +160,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -178,10 +182,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/acm/total_tls", + path_template("/zones/{zone_id}/acm/total_tls", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -216,7 +222,7 @@ def with_streaming_response(self) -> AsyncTotalTLSResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -245,10 +251,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/acm/total_tls", zone_id=zone_id), body=await async_maybe_transform( { "enabled": enabled, @@ -269,7 +277,7 @@ async def update( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -298,10 +306,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/acm/total_tls", zone_id=zone_id), body=await async_maybe_transform( { "enabled": enabled, @@ -322,7 +332,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -344,10 +354,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/acm/total_tls", + path_template("/zones/{zone_id}/acm/total_tls", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/addressing/address_maps/accounts.py b/src/cloudflare/resources/addressing/address_maps/accounts.py index 9d839d4a42d..001086dc20d 100644 --- a/src/cloudflare/resources/addressing/address_maps/accounts.py +++ b/src/cloudflare/resources/addressing/address_maps/accounts.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +46,7 @@ def update( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -71,12 +71,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return self._put( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", + account_id=account_id, + address_map_id=address_map_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 @@ -88,7 +94,7 @@ def delete( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -112,12 +118,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return self._delete( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", + account_id=account_id, + address_map_id=address_map_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -149,7 +161,7 @@ async def update( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -174,12 +186,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return await self._put( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", + account_id=account_id, + address_map_id=address_map_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 @@ -191,7 +209,7 @@ async def delete( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -215,12 +233,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return await self._delete( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", + account_id=account_id, + address_map_id=address_map_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/addressing/address_maps/address_maps.py b/src/cloudflare/resources/addressing/address_maps/address_maps.py index af03cd6994b..49378248039 100644 --- a/src/cloudflare/resources/addressing/address_maps/address_maps.py +++ b/src/cloudflare/resources/addressing/address_maps/address_maps.py @@ -31,7 +31,7 @@ AsyncAccountsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -87,7 +87,7 @@ def with_streaming_response(self) -> AddressMapsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, description: Optional[str] | Omit = omit, enabled: Optional[bool] | Omit = omit, ips: SequenceNotStr[str] | Omit = omit, @@ -122,10 +122,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/address_maps", + path_template("/accounts/{account_id}/addressing/address_maps", account_id=account_id), body=maybe_transform( { "description": description, @@ -148,7 +150,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -170,10 +172,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/address_maps", + path_template("/accounts/{account_id}/addressing/address_maps", account_id=account_id), page=SyncSinglePage[AddressMap], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -185,7 +189,7 @@ def delete( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -211,12 +215,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return self._delete( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}", + account_id=account_id, + address_map_id=address_map_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -227,7 +237,7 @@ def edit( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, default_sni: Optional[str] | Omit = omit, description: Optional[str] | Omit = omit, enabled: Optional[bool] | Omit = omit, @@ -266,12 +276,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return self._patch( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}", + account_id=account_id, + address_map_id=address_map_id, + ), body=maybe_transform( { "default_sni": default_sni, @@ -294,7 +310,7 @@ def get( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -318,12 +334,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return self._get( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}", + account_id=account_id, + address_map_id=address_map_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -370,7 +392,7 @@ def with_streaming_response(self) -> AsyncAddressMapsResourceWithStreamingRespon async def create( self, *, - account_id: str, + account_id: str | None = None, description: Optional[str] | Omit = omit, enabled: Optional[bool] | Omit = omit, ips: SequenceNotStr[str] | Omit = omit, @@ -405,10 +427,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/address_maps", + path_template("/accounts/{account_id}/addressing/address_maps", account_id=account_id), body=await async_maybe_transform( { "description": description, @@ -431,7 +455,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -453,10 +477,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/address_maps", + path_template("/accounts/{account_id}/addressing/address_maps", account_id=account_id), page=AsyncSinglePage[AddressMap], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -468,7 +494,7 @@ async def delete( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -494,12 +520,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return await self._delete( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}", + account_id=account_id, + address_map_id=address_map_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -510,7 +542,7 @@ async def edit( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, default_sni: Optional[str] | Omit = omit, description: Optional[str] | Omit = omit, enabled: Optional[bool] | Omit = omit, @@ -549,12 +581,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return await self._patch( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}", + account_id=account_id, + address_map_id=address_map_id, + ), body=await async_maybe_transform( { "default_sni": default_sni, @@ -577,7 +615,7 @@ async def get( self, address_map_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -601,12 +639,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return await self._get( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}", + account_id=account_id, + address_map_id=address_map_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/addressing/address_maps/ips.py b/src/cloudflare/resources/addressing/address_maps/ips.py index 78313356374..dfa69fd5403 100644 --- a/src/cloudflare/resources/addressing/address_maps/ips.py +++ b/src/cloudflare/resources/addressing/address_maps/ips.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +46,7 @@ def update( self, ip_address: str, *, - account_id: str, + account_id: str | None = None, address_map_id: str, body: object, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -74,6 +74,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: @@ -81,7 +83,12 @@ def update( if not ip_address: raise ValueError(f"Expected a non-empty value for `ip_address` but received {ip_address!r}") return self._put( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", + account_id=account_id, + address_map_id=address_map_id, + ip_address=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 @@ -93,7 +100,7 @@ def delete( self, ip_address: str, *, - account_id: str, + account_id: str | None = None, address_map_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. @@ -120,6 +127,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: @@ -127,7 +136,12 @@ def delete( if not ip_address: raise ValueError(f"Expected a non-empty value for `ip_address` but received {ip_address!r}") return self._delete( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", + account_id=account_id, + address_map_id=address_map_id, + ip_address=ip_address, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -159,7 +173,7 @@ async def update( self, ip_address: str, *, - account_id: str, + account_id: str | None = None, address_map_id: str, body: object, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -187,6 +201,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: @@ -194,7 +210,12 @@ async def update( if not ip_address: raise ValueError(f"Expected a non-empty value for `ip_address` but received {ip_address!r}") return await self._put( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", + account_id=account_id, + address_map_id=address_map_id, + ip_address=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 @@ -206,7 +227,7 @@ async def delete( self, ip_address: str, *, - account_id: str, + account_id: str | None = None, address_map_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. @@ -233,6 +254,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: @@ -240,7 +263,12 @@ async def delete( if not ip_address: raise ValueError(f"Expected a non-empty value for `ip_address` but received {ip_address!r}") return await self._delete( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", + account_id=account_id, + address_map_id=address_map_id, + ip_address=ip_address, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/addressing/address_maps/zones.py b/src/cloudflare/resources/addressing/address_maps/zones.py index e6ac1d4e043..a1d6df21295 100644 --- a/src/cloudflare/resources/addressing/address_maps/zones.py +++ b/src/cloudflare/resources/addressing/address_maps/zones.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,8 +46,8 @@ def update( self, address_map_id: str, *, - zone_id: str, - account_id: str, + zone_id: str | None = None, + account_id: str | None = None, 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. @@ -74,14 +74,23 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return self._put( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", + zone_id=zone_id, + account_id=account_id, + address_map_id=address_map_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 @@ -93,8 +102,8 @@ def delete( self, address_map_id: str, *, - zone_id: str, - account_id: str, + zone_id: str | None = None, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -120,14 +129,23 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return self._delete( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", + zone_id=zone_id, + account_id=account_id, + address_map_id=address_map_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -159,8 +177,8 @@ async def update( self, address_map_id: str, *, - zone_id: str, - account_id: str, + zone_id: str | None = None, + account_id: str | None = None, 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. @@ -187,14 +205,23 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return await self._put( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", + zone_id=zone_id, + account_id=account_id, + address_map_id=address_map_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 @@ -206,8 +233,8 @@ async def delete( self, address_map_id: str, *, - zone_id: str, - account_id: str, + zone_id: str | None = None, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -233,14 +260,23 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_map_id: raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}") return await self._delete( - f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", + path_template( + "/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", + zone_id=zone_id, + account_id=account_id, + address_map_id=address_map_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/addressing/api.md b/src/cloudflare/resources/addressing/api.md new file mode 100644 index 00000000000..0e7c10008bd --- /dev/null +++ b/src/cloudflare/resources/addressing/api.md @@ -0,0 +1,197 @@ +# Addressing + +## RegionalHostnames + +Types: + +```python +from cloudflare.types.addressing import ( + RegionalHostnameCreateResponse, + RegionalHostnameListResponse, + RegionalHostnameDeleteResponse, + RegionalHostnameEditResponse, + RegionalHostnameGetResponse, +) +``` + +Methods: + +- 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[RegionalHostnameEditResponse] +- client.addressing.regional_hostnames.get(hostname, \*, zone_id) -> Optional[RegionalHostnameGetResponse] + +### Regions + +Types: + +```python +from cloudflare.types.addressing.regional_hostnames import RegionListResponse +``` + +Methods: + +- client.addressing.regional_hostnames.regions.list(\*, account_id) -> SyncSinglePage[RegionListResponse] + +## Services + +Types: + +```python +from cloudflare.types.addressing import ServiceListResponse +``` + +Methods: + +- client.addressing.services.list(\*, account_id) -> SyncSinglePage[ServiceListResponse] + +## AddressMaps + +Types: + +```python +from cloudflare.types.addressing import ( + AddressMap, + Kind, + AddressMapCreateResponse, + AddressMapDeleteResponse, + AddressMapGetResponse, +) +``` + +Methods: + +- 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) -> 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 + +Types: + +```python +from cloudflare.types.addressing.address_maps import AccountUpdateResponse, AccountDeleteResponse +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.addressing.address_maps import IPUpdateResponse, IPDeleteResponse +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.addressing.address_maps import ZoneUpdateResponse, ZoneDeleteResponse +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.addressing import LOADocumentCreateResponse +``` + +Methods: + +- client.addressing.loa_documents.create(\*, account_id, \*\*params) -> Optional[LOADocumentCreateResponse] +- client.addressing.loa_documents.get(loa_document_id, \*, account_id) -> BinaryAPIResponse + +## Prefixes + +Types: + +```python +from cloudflare.types.addressing import Prefix, PrefixDeleteResponse +``` + +Methods: + +- 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) -> PrefixDeleteResponse +- client.addressing.prefixes.edit(prefix_id, \*, account_id, \*\*params) -> Optional[Prefix] +- client.addressing.prefixes.get(prefix_id, \*, account_id) -> Optional[Prefix] + +### ServiceBindings + +Types: + +```python +from cloudflare.types.addressing.prefixes import ServiceBinding, ServiceBindingDeleteResponse +``` + +Methods: + +- 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] + +### BGPPrefixes + +Types: + +```python +from cloudflare.types.addressing.prefixes import BGPPrefix +``` + +Methods: + +- 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] + +### AdvertisementStatus + +Types: + +```python +from cloudflare.types.addressing.prefixes import ( + AdvertisementStatusEditResponse, + AdvertisementStatusGetResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.addressing.prefixes import Delegations, DelegationDeleteResponse +``` + +Methods: + +- 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[DelegationDeleteResponse] diff --git a/src/cloudflare/resources/addressing/loa_documents.py b/src/cloudflare/resources/addressing/loa_documents.py index a1765c32f97..f2d4bfb9db9 100644 --- a/src/cloudflare/resources/addressing/loa_documents.py +++ b/src/cloudflare/resources/addressing/loa_documents.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -55,7 +55,7 @@ def with_streaming_response(self) -> LOADocumentsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -80,6 +80,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 @@ -87,7 +89,7 @@ def create( # 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", + path_template("/accounts/{account_id}/addressing/loa_documents", account_id=account_id), body=maybe_transform({"loa_document": loa_document}, loa_document_create_params.LOADocumentCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -101,9 +103,9 @@ def create( def get( self, - loa_document_id: Optional[str], + loa_document_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,13 +129,19 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download", + account_id=account_id, + loa_document_id=loa_document_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -164,7 +172,7 @@ def with_streaming_response(self) -> AsyncLOADocumentsResourceWithStreamingRespo async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -189,6 +197,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 @@ -196,7 +206,7 @@ async def create( # 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", + path_template("/accounts/{account_id}/addressing/loa_documents", account_id=account_id), body=await async_maybe_transform( {"loa_document": loa_document}, loa_document_create_params.LOADocumentCreateParams ), @@ -212,9 +222,9 @@ async def create( async def get( self, - loa_document_id: Optional[str], + loa_document_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -238,13 +248,19 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download", + account_id=account_id, + loa_document_id=loa_document_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/addressing/prefixes/advertisement_status.py b/src/cloudflare/resources/addressing/prefixes/advertisement_status.py index 7b71630f5b2..4f5b488c4f7 100644 --- a/src/cloudflare/resources/addressing/prefixes/advertisement_status.py +++ b/src/cloudflare/resources/addressing/prefixes/advertisement_status.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def edit( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -82,12 +82,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", + account_id=account_id, + prefix_id=prefix_id, + ), body=maybe_transform( {"advertised": advertised}, advertisement_status_edit_params.AdvertisementStatusEditParams ), @@ -108,7 +114,7 @@ def get( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -135,12 +141,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", + account_id=account_id, + prefix_id=prefix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -177,7 +189,7 @@ async def edit( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -208,12 +220,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", + account_id=account_id, + prefix_id=prefix_id, + ), body=await async_maybe_transform( {"advertised": advertised}, advertisement_status_edit_params.AdvertisementStatusEditParams ), @@ -234,7 +252,7 @@ async def get( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -261,12 +279,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", + account_id=account_id, + prefix_id=prefix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/addressing/prefixes/bgp_prefixes.py b/src/cloudflare/resources/addressing/prefixes/bgp_prefixes.py index 2f997e3a34f..388ac2ec2de 100644 --- a/src/cloudflare/resources/addressing/prefixes/bgp_prefixes.py +++ b/src/cloudflare/resources/addressing/prefixes/bgp_prefixes.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def create( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -78,12 +78,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", + account_id=account_id, + prefix_id=prefix_id, + ), body=maybe_transform({"cidr": cidr}, bgp_prefix_create_params.BGPPrefixCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -99,7 +105,7 @@ def list( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,12 +133,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", + account_id=account_id, + prefix_id=prefix_id, + ), page=SyncSinglePage[BGPPrefix], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -144,7 +156,7 @@ def edit( self, bgp_prefix_id: str, *, - account_id: str, + account_id: str | None = None, prefix_id: str, asn_prepend_count: int | Omit = omit, auto_advertise_withdraw: bool | Omit = omit, @@ -182,6 +194,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -189,7 +203,12 @@ def edit( 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", + account_id=account_id, + prefix_id=prefix_id, + bgp_prefix_id=bgp_prefix_id, + ), body=maybe_transform( { "asn_prepend_count": asn_prepend_count, @@ -212,7 +231,7 @@ def get( self, bgp_prefix_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -239,6 +258,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -246,7 +267,12 @@ def get( 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", + account_id=account_id, + prefix_id=prefix_id, + bgp_prefix_id=bgp_prefix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -282,7 +308,7 @@ async def create( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -311,12 +337,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", + account_id=account_id, + prefix_id=prefix_id, + ), body=await async_maybe_transform({"cidr": cidr}, bgp_prefix_create_params.BGPPrefixCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -332,7 +364,7 @@ def list( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -360,12 +392,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", + account_id=account_id, + prefix_id=prefix_id, + ), page=AsyncSinglePage[BGPPrefix], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -377,7 +415,7 @@ async def edit( self, bgp_prefix_id: str, *, - account_id: str, + account_id: str | None = None, prefix_id: str, asn_prepend_count: int | Omit = omit, auto_advertise_withdraw: bool | Omit = omit, @@ -415,6 +453,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -422,7 +462,12 @@ async def edit( 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", + account_id=account_id, + prefix_id=prefix_id, + bgp_prefix_id=bgp_prefix_id, + ), body=await async_maybe_transform( { "asn_prepend_count": asn_prepend_count, @@ -445,7 +490,7 @@ async def get( self, bgp_prefix_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -472,6 +517,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -479,7 +526,12 @@ async def get( 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", + account_id=account_id, + prefix_id=prefix_id, + bgp_prefix_id=bgp_prefix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/addressing/prefixes/delegations.py b/src/cloudflare/resources/addressing/prefixes/delegations.py index cdc8824f1d3..bbaec487686 100644 --- a/src/cloudflare/resources/addressing/prefixes/delegations.py +++ b/src/cloudflare/resources/addressing/prefixes/delegations.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def create( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, cidr: str, delegated_account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -80,12 +80,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/delegations", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations", + account_id=account_id, + prefix_id=prefix_id, + ), body=maybe_transform( { "cidr": cidr, @@ -107,7 +113,7 @@ def list( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -131,12 +137,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/delegations", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations", + account_id=account_id, + prefix_id=prefix_id, + ), page=SyncSinglePage[Delegations], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -148,7 +160,7 @@ def delete( self, delegation_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -175,6 +187,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -182,7 +196,12 @@ def delete( if not delegation_id: raise ValueError(f"Expected a non-empty value for `delegation_id` but received {delegation_id!r}") return self._delete( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations/{delegation_id}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations/{delegation_id}", + account_id=account_id, + prefix_id=prefix_id, + delegation_id=delegation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -218,7 +237,7 @@ async def create( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, cidr: str, delegated_account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -248,12 +267,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/delegations", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations", + account_id=account_id, + prefix_id=prefix_id, + ), body=await async_maybe_transform( { "cidr": cidr, @@ -275,7 +300,7 @@ def list( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -299,12 +324,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/delegations", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations", + account_id=account_id, + prefix_id=prefix_id, + ), page=AsyncSinglePage[Delegations], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -316,7 +347,7 @@ async def delete( self, delegation_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -343,6 +374,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -350,7 +383,12 @@ async def delete( if not delegation_id: raise ValueError(f"Expected a non-empty value for `delegation_id` but received {delegation_id!r}") return await self._delete( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations/{delegation_id}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations/{delegation_id}", + account_id=account_id, + prefix_id=prefix_id, + delegation_id=delegation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/addressing/prefixes/prefixes.py b/src/cloudflare/resources/addressing/prefixes/prefixes.py index 6c9785fa6cf..60cf4c0a008 100644 --- a/src/cloudflare/resources/addressing/prefixes/prefixes.py +++ b/src/cloudflare/resources/addressing/prefixes/prefixes.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from .delegations import ( DelegationsResource, @@ -97,7 +97,7 @@ def with_streaming_response(self) -> PrefixesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, asn: int, cidr: str, delegate_loa_creation: bool | Omit = omit, @@ -135,10 +135,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/prefixes", + path_template("/accounts/{account_id}/addressing/prefixes", account_id=account_id), body=maybe_transform( { "asn": asn, @@ -162,7 +164,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -184,10 +186,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/prefixes", + path_template("/accounts/{account_id}/addressing/prefixes", account_id=account_id), page=SyncSinglePage[Prefix], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -199,7 +203,7 @@ def delete( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -223,12 +227,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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._delete( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}", account_id=account_id, prefix_id=prefix_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -239,7 +247,7 @@ def edit( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, description: 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. @@ -266,12 +274,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}", account_id=account_id, prefix_id=prefix_id + ), body=maybe_transform({"description": description}, prefix_edit_params.PrefixEditParams), options=make_request_options( extra_headers=extra_headers, @@ -287,7 +299,7 @@ def get( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -311,12 +323,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}", account_id=account_id, prefix_id=prefix_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -367,7 +383,7 @@ def with_streaming_response(self) -> AsyncPrefixesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, asn: int, cidr: str, delegate_loa_creation: bool | Omit = omit, @@ -405,10 +421,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/prefixes", + path_template("/accounts/{account_id}/addressing/prefixes", account_id=account_id), body=await async_maybe_transform( { "asn": asn, @@ -432,7 +450,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -454,10 +472,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/prefixes", + path_template("/accounts/{account_id}/addressing/prefixes", account_id=account_id), page=AsyncSinglePage[Prefix], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -469,7 +489,7 @@ async def delete( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -493,12 +513,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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._delete( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}", account_id=account_id, prefix_id=prefix_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -509,7 +533,7 @@ async def edit( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, description: 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. @@ -536,12 +560,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}", account_id=account_id, prefix_id=prefix_id + ), body=await async_maybe_transform({"description": description}, prefix_edit_params.PrefixEditParams), options=make_request_options( extra_headers=extra_headers, @@ -557,7 +585,7 @@ async def get( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -581,12 +609,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}", account_id=account_id, prefix_id=prefix_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/addressing/prefixes/service_bindings.py b/src/cloudflare/resources/addressing/prefixes/service_bindings.py index 163f77b5a40..d8e617cc87e 100644 --- a/src/cloudflare/resources/addressing/prefixes/service_bindings.py +++ b/src/cloudflare/resources/addressing/prefixes/service_bindings.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def create( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -86,12 +86,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", + account_id=account_id, + prefix_id=prefix_id, + ), body=maybe_transform( { "cidr": cidr, @@ -113,7 +119,7 @@ def list( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -143,12 +149,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", + account_id=account_id, + prefix_id=prefix_id, + ), page=SyncSinglePage[ServiceBinding], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -160,7 +172,7 @@ def delete( self, binding_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -187,6 +199,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -194,7 +208,12 @@ def delete( 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", + account_id=account_id, + prefix_id=prefix_id, + binding_id=binding_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -205,7 +224,7 @@ def get( self, binding_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -232,6 +251,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -239,7 +260,12 @@ def get( 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", + account_id=account_id, + prefix_id=prefix_id, + binding_id=binding_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -275,7 +301,7 @@ async def create( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -311,12 +337,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", + account_id=account_id, + prefix_id=prefix_id, + ), body=await async_maybe_transform( { "cidr": cidr, @@ -338,7 +370,7 @@ def list( self, prefix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -368,12 +400,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", + account_id=account_id, + prefix_id=prefix_id, + ), page=AsyncSinglePage[ServiceBinding], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -385,7 +423,7 @@ async def delete( self, binding_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -412,6 +450,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -419,7 +459,12 @@ async def delete( 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", + account_id=account_id, + prefix_id=prefix_id, + binding_id=binding_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -430,7 +475,7 @@ async def get( self, binding_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -457,6 +502,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not prefix_id: @@ -464,7 +511,12 @@ async def get( 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}", + path_template( + "/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", + account_id=account_id, + prefix_id=prefix_id, + binding_id=binding_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py b/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py index e404f48a4d1..5bee3bcf4f7 100644 --- a/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py +++ b/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py @@ -15,7 +15,7 @@ AsyncRegionsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -64,7 +64,7 @@ def with_streaming_response(self) -> RegionalHostnamesResourceWithStreamingRespo def create( self, *, - zone_id: str, + zone_id: str | None = None, hostname: str, region_key: str, routing: str | Omit = omit, @@ -100,10 +100,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/addressing/regional_hostnames", + path_template("/zones/{zone_id}/addressing/regional_hostnames", zone_id=zone_id), body=maybe_transform( { "hostname": hostname, @@ -125,7 +127,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -147,10 +149,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/addressing/regional_hostnames", + path_template("/zones/{zone_id}/addressing/regional_hostnames", zone_id=zone_id), page=SyncSinglePage[RegionalHostnameListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -162,7 +166,7 @@ def delete( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -187,12 +191,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return self._delete( - f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + path_template( + "/zones/{zone_id}/addressing/regional_hostnames/{hostname}", zone_id=zone_id, hostname=hostname + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -203,7 +211,7 @@ def edit( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, region_key: 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. @@ -233,12 +241,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return self._patch( - f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + path_template( + "/zones/{zone_id}/addressing/regional_hostnames/{hostname}", zone_id=zone_id, hostname=hostname + ), body=maybe_transform({"region_key": region_key}, regional_hostname_edit_params.RegionalHostnameEditParams), options=make_request_options( extra_headers=extra_headers, @@ -254,7 +266,7 @@ def get( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -279,12 +291,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return self._get( - f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + path_template( + "/zones/{zone_id}/addressing/regional_hostnames/{hostname}", zone_id=zone_id, hostname=hostname + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -323,7 +339,7 @@ def with_streaming_response(self) -> AsyncRegionalHostnamesResourceWithStreaming async def create( self, *, - zone_id: str, + zone_id: str | None = None, hostname: str, region_key: str, routing: str | Omit = omit, @@ -359,10 +375,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/addressing/regional_hostnames", + path_template("/zones/{zone_id}/addressing/regional_hostnames", zone_id=zone_id), body=await async_maybe_transform( { "hostname": hostname, @@ -384,7 +402,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -406,10 +424,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/addressing/regional_hostnames", + path_template("/zones/{zone_id}/addressing/regional_hostnames", zone_id=zone_id), page=AsyncSinglePage[RegionalHostnameListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -421,7 +441,7 @@ async def delete( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -446,12 +466,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return await self._delete( - f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + path_template( + "/zones/{zone_id}/addressing/regional_hostnames/{hostname}", zone_id=zone_id, hostname=hostname + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -462,7 +486,7 @@ async def edit( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, region_key: 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. @@ -492,12 +516,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return await self._patch( - f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + path_template( + "/zones/{zone_id}/addressing/regional_hostnames/{hostname}", zone_id=zone_id, hostname=hostname + ), body=await async_maybe_transform( {"region_key": region_key}, regional_hostname_edit_params.RegionalHostnameEditParams ), @@ -515,7 +543,7 @@ async def get( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -540,12 +568,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return await self._get( - f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + path_template( + "/zones/{zone_id}/addressing/regional_hostnames/{hostname}", zone_id=zone_id, hostname=hostname + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/addressing/regional_hostnames/regions.py b/src/cloudflare/resources/addressing/regional_hostnames/regions.py index e94af76ff04..a9d0344c3ed 100644 --- a/src/cloudflare/resources/addressing/regional_hostnames/regions.py +++ b/src/cloudflare/resources/addressing/regional_hostnames/regions.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -43,7 +44,7 @@ def with_streaming_response(self) -> RegionsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -65,10 +66,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/regional_hostnames/regions", + path_template("/accounts/{account_id}/addressing/regional_hostnames/regions", account_id=account_id), page=SyncSinglePage[RegionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -100,7 +103,7 @@ def with_streaming_response(self) -> AsyncRegionsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -122,10 +125,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/regional_hostnames/regions", + path_template("/accounts/{account_id}/addressing/regional_hostnames/regions", account_id=account_id), page=AsyncSinglePage[RegionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/addressing/services.py b/src/cloudflare/resources/addressing/services.py index 959ced7ff44..9dff6ddfedf 100644 --- a/src/cloudflare/resources/addressing/services.py +++ b/src/cloudflare/resources/addressing/services.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -43,7 +44,7 @@ def with_streaming_response(self) -> ServicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,10 +69,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/services", + path_template("/accounts/{account_id}/addressing/services", account_id=account_id), page=SyncSinglePage[ServiceListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -103,7 +106,7 @@ def with_streaming_response(self) -> AsyncServicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -128,10 +131,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/addressing/services", + path_template("/accounts/{account_id}/addressing/services", account_id=account_id), page=AsyncSinglePage[ServiceListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/ai/ai.py b/src/cloudflare/resources/ai/ai.py index 9a53d1b3df5..96306c52c9a 100644 --- a/src/cloudflare/resources/ai/ai.py +++ b/src/cloudflare/resources/ai/ai.py @@ -24,7 +24,7 @@ AsyncAuthorsResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ...types.ai import ai_run_params from ..._resource import SyncAPIResource, AsyncAPIResource @@ -110,7 +110,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -148,7 +148,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, prompt: str, guidance: float | Omit = omit, height: int | Omit = omit, @@ -220,7 +220,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -262,7 +262,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -300,7 +300,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, audio: Iterable[float], source_lang: str | Omit = omit, target_lang: str | Omit = omit, @@ -346,7 +346,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -385,7 +385,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -424,7 +424,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, prompt: str, frequency_penalty: float | Omit = omit, lora: str | Omit = omit, @@ -503,7 +503,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, messages: Iterable[ai_run_params.MessagesMessage], frequency_penalty: float | Omit = omit, functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit, @@ -583,7 +583,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, target_lang: str, text: str, source_lang: str | Omit = omit, @@ -628,7 +628,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -669,7 +669,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, image: Iterable[float], frequency_penalty: float | Omit = omit, max_tokens: int | Omit = omit, @@ -744,7 +744,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, image: str, prompt: str, frequency_penalty: float | Omit = omit, @@ -818,7 +818,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, image: str, messages: Iterable[ai_run_params.Variant13Message], frequency_penalty: float | Omit = omit, @@ -892,7 +892,7 @@ def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -926,23 +926,11 @@ def run( """ ... - @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, + account_id: str | None = None, text: str | Union[str, SequenceNotStr[str]] | SequenceNotStr[str] | Omit = omit, prompt: str | Omit = omit, guidance: float | Omit = omit, @@ -983,6 +971,8 @@ def run( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AIRunResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not model_name: @@ -990,7 +980,9 @@ def run( return cast( Optional[AIRunResponse], self._post( - f"/accounts/{account_id}/ai/run/{model_name}", + path_template( + "/accounts/{account_id}/ai/run/{model_name}", account_id=account_id, model_name=model_name + ), body=maybe_transform( { "text": text, @@ -1088,7 +1080,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -1126,7 +1118,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, prompt: str, guidance: float | Omit = omit, height: int | Omit = omit, @@ -1198,7 +1190,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -1240,7 +1232,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -1278,7 +1270,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, audio: Iterable[float], source_lang: str | Omit = omit, target_lang: str | Omit = omit, @@ -1324,7 +1316,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -1363,7 +1355,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -1402,7 +1394,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, prompt: str, frequency_penalty: float | Omit = omit, lora: str | Omit = omit, @@ -1481,7 +1473,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, messages: Iterable[ai_run_params.MessagesMessage], frequency_penalty: float | Omit = omit, functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit, @@ -1561,7 +1553,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, target_lang: str, text: str, source_lang: str | Omit = omit, @@ -1606,7 +1598,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -1647,7 +1639,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, image: Iterable[float], frequency_penalty: float | Omit = omit, max_tokens: int | Omit = omit, @@ -1722,7 +1714,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, image: str, prompt: str, frequency_penalty: float | Omit = omit, @@ -1796,7 +1788,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, image: str, messages: Iterable[ai_run_params.Variant13Message], frequency_penalty: float | Omit = omit, @@ -1870,7 +1862,7 @@ async def run( self, model_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -1904,23 +1896,11 @@ async def run( """ ... - @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, + account_id: str | None = None, text: str | Union[str, SequenceNotStr[str]] | SequenceNotStr[str] | Omit = omit, prompt: str | Omit = omit, guidance: float | Omit = omit, @@ -1961,6 +1941,8 @@ async def run( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AIRunResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not model_name: @@ -1968,7 +1950,9 @@ async def run( return cast( Optional[AIRunResponse], await self._post( - f"/accounts/{account_id}/ai/run/{model_name}", + path_template( + "/accounts/{account_id}/ai/run/{model_name}", account_id=account_id, model_name=model_name + ), body=await async_maybe_transform( { "text": text, diff --git a/src/cloudflare/resources/ai/api.md b/src/cloudflare/resources/ai/api.md new file mode 100644 index 00000000000..88e791ba4ae --- /dev/null +++ b/src/cloudflare/resources/ai/api.md @@ -0,0 +1,91 @@ +# AI + +Types: + +```python +from cloudflare.types.ai import AIRunResponse +``` + +Methods: + +- client.ai.run(model_name, \*, account_id, \*\*params) -> Optional[AIRunResponse] + +## Finetunes + +Types: + +```python +from cloudflare.types.ai import FinetuneCreateResponse, FinetuneListResponse +``` + +Methods: + +- client.ai.finetunes.create(\*, account_id, \*\*params) -> FinetuneCreateResponse +- client.ai.finetunes.list(\*, account_id) -> FinetuneListResponse + +### Assets + +Types: + +```python +from cloudflare.types.ai.finetunes import AssetCreateResponse +``` + +Methods: + +- client.ai.finetunes.assets.create(finetune_id, \*, account_id, \*\*params) -> AssetCreateResponse + +### Public + +Types: + +```python +from cloudflare.types.ai.finetunes import PublicListResponse +``` + +Methods: + +- client.ai.finetunes.public.list(\*, account_id, \*\*params) -> SyncSinglePage[PublicListResponse] + +## Authors + +Methods: + +- client.ai.authors.list(\*, account_id) -> SyncSinglePage[object] + +## Tasks + +Methods: + +- client.ai.tasks.list(\*, account_id) -> SyncSinglePage[object] + +## Models + +Methods: + +- client.ai.models.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[object] + +### Schema + +Types: + +```python +from cloudflare.types.ai.models import SchemaGetResponse +``` + +Methods: + +- client.ai.models.schema.get(\*, account_id, \*\*params) -> SchemaGetResponse + +## ToMarkdown + +Types: + +```python +from cloudflare.types.ai import ToMarkdownSupportedResponse, ToMarkdownTransformResponse +``` + +Methods: + +- client.ai.to_markdown.supported(\*, account_id) -> SyncSinglePage[ToMarkdownSupportedResponse] +- client.ai.to_markdown.transform(\*, account_id, \*\*params) -> SyncSinglePage[ToMarkdownTransformResponse] diff --git a/src/cloudflare/resources/ai/authors.py b/src/cloudflare/resources/ai/authors.py index e6b3360823b..cb44ddc0d5e 100644 --- a/src/cloudflare/resources/ai/authors.py +++ b/src/cloudflare/resources/ai/authors.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -42,7 +43,7 @@ def with_streaming_response(self) -> AuthorsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -62,10 +63,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/authors/search", account_id=account_id), page=SyncSinglePage[object], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -97,7 +100,7 @@ def with_streaming_response(self) -> AsyncAuthorsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -117,10 +120,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/authors/search", account_id=account_id), page=AsyncSinglePage[object], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/ai/finetunes/assets.py b/src/cloudflare/resources/ai/finetunes/assets.py index ada060fb7b2..00306dbe6c1 100644 --- a/src/cloudflare/resources/ai/finetunes/assets.py +++ b/src/cloudflare/resources/ai/finetunes/assets.py @@ -7,7 +7,7 @@ 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 ...._utils import extract_files, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def create( self, finetune_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -69,6 +69,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not finetune_id: @@ -85,7 +87,11 @@ def create( # 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", + path_template( + "/accounts/{account_id}/ai/finetunes/{finetune_id}/finetune-assets", + account_id=account_id, + finetune_id=finetune_id, + ), body=maybe_transform(body, asset_create_params.AssetCreateParams), files=files, options=make_request_options( @@ -119,7 +125,7 @@ async def create( self, finetune_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -141,6 +147,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not finetune_id: @@ -157,7 +165,11 @@ async def create( # 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", + path_template( + "/accounts/{account_id}/ai/finetunes/{finetune_id}/finetune-assets", + account_id=account_id, + finetune_id=finetune_id, + ), body=await async_maybe_transform(body, asset_create_params.AssetCreateParams), files=files, options=make_request_options( diff --git a/src/cloudflare/resources/ai/finetunes/finetunes.py b/src/cloudflare/resources/ai/finetunes/finetunes.py index ed583d0a69e..a0d28ad0bcb 100644 --- a/src/cloudflare/resources/ai/finetunes/finetunes.py +++ b/src/cloudflare/resources/ai/finetunes/finetunes.py @@ -23,7 +23,7 @@ AsyncPublicResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ....types.ai import finetune_create_params from ...._resource import SyncAPIResource, AsyncAPIResource @@ -72,7 +72,7 @@ def with_streaming_response(self) -> FinetunesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, model: str, name: str, description: str | Omit = omit, @@ -96,10 +96,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/finetunes", account_id=account_id), body=maybe_transform( { "model": model, @@ -122,7 +124,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -142,10 +144,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/finetunes", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -188,7 +192,7 @@ def with_streaming_response(self) -> AsyncFinetunesResourceWithStreamingResponse async def create( self, *, - account_id: str, + account_id: str | None = None, model: str, name: str, description: str | Omit = omit, @@ -212,10 +216,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/finetunes", account_id=account_id), body=await async_maybe_transform( { "model": model, @@ -238,7 +244,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -258,10 +264,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/finetunes", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ai/finetunes/public.py b/src/cloudflare/resources/ai/finetunes/public.py index 1f519ce3564..711f22f3af7 100644 --- a/src/cloudflare/resources/ai/finetunes/public.py +++ b/src/cloudflare/resources/ai/finetunes/public.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +45,7 @@ def with_streaming_response(self) -> PublicResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, limit: float | Omit = omit, offset: float | Omit = omit, order_by: str | Omit = omit, @@ -74,10 +74,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/finetunes/public", account_id=account_id), page=SyncSinglePage[PublicListResponse], options=make_request_options( extra_headers=extra_headers, @@ -120,7 +122,7 @@ def with_streaming_response(self) -> AsyncPublicResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, limit: float | Omit = omit, offset: float | Omit = omit, order_by: str | Omit = omit, @@ -149,10 +151,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/finetunes/public", account_id=account_id), page=AsyncSinglePage[PublicListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/ai/models/models.py b/src/cloudflare/resources/ai/models/models.py index c2f40e2e160..4b5845d98cb 100644 --- a/src/cloudflare/resources/ai/models/models.py +++ b/src/cloudflare/resources/ai/models/models.py @@ -13,7 +13,7 @@ AsyncSchemaResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ....types.ai import model_list_params from ...._resource import SyncAPIResource, AsyncAPIResource @@ -56,7 +56,7 @@ def with_streaming_response(self) -> ModelsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, author: str | Omit = omit, hide_experimental: bool | Omit = omit, page: int | Omit = omit, @@ -93,10 +93,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/models/search", account_id=account_id), page=SyncV4PagePaginationArray[object], options=make_request_options( extra_headers=extra_headers, @@ -147,7 +149,7 @@ def with_streaming_response(self) -> AsyncModelsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, author: str | Omit = omit, hide_experimental: bool | Omit = omit, page: int | Omit = omit, @@ -184,10 +186,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/models/search", account_id=account_id), page=AsyncV4PagePaginationArray[object], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/ai/models/schema.py b/src/cloudflare/resources/ai/models/schema.py index a041d762955..605cc4f6384 100644 --- a/src/cloudflare/resources/ai/models/schema.py +++ b/src/cloudflare/resources/ai/models/schema.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> SchemaResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -70,10 +70,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/models/schema", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -109,7 +111,7 @@ def with_streaming_response(self) -> AsyncSchemaResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -132,10 +134,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/models/schema", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ai/tasks.py b/src/cloudflare/resources/ai/tasks.py index a312b56238e..3fcc901ea28 100644 --- a/src/cloudflare/resources/ai/tasks.py +++ b/src/cloudflare/resources/ai/tasks.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -42,7 +43,7 @@ def with_streaming_response(self) -> TasksResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -62,10 +63,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/tasks/search", account_id=account_id), page=SyncSinglePage[object], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -97,7 +100,7 @@ def with_streaming_response(self) -> AsyncTasksResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -117,10 +120,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/tasks/search", account_id=account_id), page=AsyncSinglePage[object], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/ai/to_markdown.py b/src/cloudflare/resources/ai/to_markdown.py index a4792606100..27fe9dd2ebc 100644 --- a/src/cloudflare/resources/ai/to_markdown.py +++ b/src/cloudflare/resources/ai/to_markdown.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import extract_files, maybe_transform, deepcopy_minimal +from ..._utils import extract_files, path_template, maybe_transform, deepcopy_minimal from ..._compat import cached_property from ...types.ai import to_markdown_transform_params from ..._resource import SyncAPIResource, AsyncAPIResource @@ -48,7 +48,7 @@ def with_streaming_response(self) -> ToMarkdownResourceWithStreamingResponse: def supported( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,10 +68,12 @@ def supported( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/tomarkdown/supported", account_id=account_id), page=SyncSinglePage[ToMarkdownSupportedResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -82,7 +84,7 @@ def supported( def transform( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -103,6 +105,8 @@ def transform( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") body = deepcopy_minimal(file) @@ -111,8 +115,8 @@ def transform( # 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", + return self._get_api_list( + path_template("/accounts/{account_id}/ai/tomarkdown", account_id=account_id), page=SyncSinglePage[ToMarkdownTransformResponse], body=maybe_transform(body, to_markdown_transform_params.ToMarkdownTransformParams), files=files, # pyright: ignore[reportCallIssue] # type: ignore[call-arg] @@ -147,7 +151,7 @@ def with_streaming_response(self) -> AsyncToMarkdownResourceWithStreamingRespons def supported( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -167,10 +171,12 @@ def supported( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai/tomarkdown/supported", account_id=account_id), page=AsyncSinglePage[ToMarkdownSupportedResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -181,7 +187,7 @@ def supported( def transform( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -202,6 +208,8 @@ def transform( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") body = deepcopy_minimal(file) @@ -210,8 +218,8 @@ def transform( # 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", + return self._get_api_list( + path_template("/accounts/{account_id}/ai/tomarkdown", account_id=account_id), page=AsyncSinglePage[ToMarkdownTransformResponse], body=maybe_transform(body, to_markdown_transform_params.ToMarkdownTransformParams), files=files, # pyright: ignore[reportCallIssue] # type: ignore[call-arg] diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 608295f937f..2591ae29f5f 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -24,7 +24,7 @@ AsyncURLsResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .datasets import ( DatasetsResource, AsyncDatasetsResource, @@ -137,7 +137,7 @@ def with_streaming_response(self) -> AIGatewayResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, id: str, cache_invalidate_on_update: bool, cache_ttl: Optional[int], @@ -185,10 +185,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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-gateway/gateways", + path_template("/accounts/{account_id}/ai-gateway/gateways", account_id=account_id), body=maybe_transform( { "id": id, @@ -225,7 +227,7 @@ def update( self, id: str, *, - account_id: str, + account_id: str | None = None, cache_invalidate_on_update: bool, cache_ttl: Optional[int], collect_logs: bool, @@ -276,12 +278,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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-gateway/gateways/{id}", + path_template("/accounts/{account_id}/ai-gateway/gateways/{id}", account_id=account_id, id=id), body=maybe_transform( { "cache_invalidate_on_update": cache_invalidate_on_update, @@ -320,7 +324,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -345,10 +349,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/gateways", + path_template("/accounts/{account_id}/ai-gateway/gateways", account_id=account_id), page=SyncV4PagePaginationArray[AIGatewayListResponse], options=make_request_options( extra_headers=extra_headers, @@ -371,7 +377,7 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -393,12 +399,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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-gateway/gateways/{id}", + path_template("/accounts/{account_id}/ai-gateway/gateways/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -413,7 +421,7 @@ def get( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -435,12 +443,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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-gateway/gateways/{id}", + path_template("/accounts/{account_id}/ai-gateway/gateways/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -503,7 +513,7 @@ def with_streaming_response(self) -> AsyncAIGatewayResourceWithStreamingResponse async def create( self, *, - account_id: str, + account_id: str | None = None, id: str, cache_invalidate_on_update: bool, cache_ttl: Optional[int], @@ -551,10 +561,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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-gateway/gateways", + path_template("/accounts/{account_id}/ai-gateway/gateways", account_id=account_id), body=await async_maybe_transform( { "id": id, @@ -591,7 +603,7 @@ async def update( self, id: str, *, - account_id: str, + account_id: str | None = None, cache_invalidate_on_update: bool, cache_ttl: Optional[int], collect_logs: bool, @@ -642,12 +654,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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-gateway/gateways/{id}", + path_template("/accounts/{account_id}/ai-gateway/gateways/{id}", account_id=account_id, id=id), body=await async_maybe_transform( { "cache_invalidate_on_update": cache_invalidate_on_update, @@ -686,7 +700,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -711,10 +725,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/gateways", + path_template("/accounts/{account_id}/ai-gateway/gateways", account_id=account_id), page=AsyncV4PagePaginationArray[AIGatewayListResponse], options=make_request_options( extra_headers=extra_headers, @@ -737,7 +753,7 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -759,12 +775,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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-gateway/gateways/{id}", + path_template("/accounts/{account_id}/ai-gateway/gateways/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -779,7 +797,7 @@ async def get( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -801,12 +819,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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-gateway/gateways/{id}", + path_template("/accounts/{account_id}/ai-gateway/gateways/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ai_gateway/api.md b/src/cloudflare/resources/ai_gateway/api.md new file mode 100644 index 00000000000..7202ceae450 --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/api.md @@ -0,0 +1,149 @@ +# AIGateway + +Types: + +```python +from cloudflare.types.ai_gateway import ( + AIGatewayCreateResponse, + AIGatewayUpdateResponse, + AIGatewayListResponse, + AIGatewayDeleteResponse, + AIGatewayGetResponse, +) +``` + +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 + +## EvaluationTypes + +Types: + +```python +from cloudflare.types.ai_gateway import EvaluationTypeListResponse +``` + +Methods: + +- client.ai_gateway.evaluation_types.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[EvaluationTypeListResponse] + +## Logs + +Types: + +```python +from cloudflare.types.ai_gateway import LogListResponse, LogDeleteResponse, LogGetResponse +``` + +Methods: + +- 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 + +## Datasets + +Types: + +```python +from cloudflare.types.ai_gateway import ( + DatasetCreateResponse, + DatasetUpdateResponse, + DatasetListResponse, + DatasetDeleteResponse, + DatasetGetResponse, +) +``` + +Methods: + +- 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 + +## Evaluations + +Types: + +```python +from cloudflare.types.ai_gateway import ( + EvaluationCreateResponse, + EvaluationListResponse, + EvaluationDeleteResponse, + EvaluationGetResponse, +) +``` + +Methods: + +- 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 + +## DynamicRouting + +Types: + +```python +from cloudflare.types.ai_gateway import ( + DynamicRoutingCreateResponse, + DynamicRoutingUpdateResponse, + DynamicRoutingListResponse, + DynamicRoutingDeleteResponse, + DynamicRoutingCreateDeploymentResponse, + DynamicRoutingCreateVersionResponse, + DynamicRoutingGetResponse, + DynamicRoutingGetVersionResponse, + DynamicRoutingListDeploymentsResponse, + DynamicRoutingListVersionsResponse, +) +``` + +Methods: + +- 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 + +## ProviderConfigs + +Types: + +```python +from cloudflare.types.ai_gateway import ProviderConfigCreateResponse, ProviderConfigListResponse +``` + +Methods: + +- 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] + +## URLs + +Types: + +```python +from cloudflare.types.ai_gateway import URLGetResponse +``` + +Methods: + +- client.ai_gateway.urls.get(provider, \*, account_id, gateway_id) -> str diff --git a/src/cloudflare/resources/ai_gateway/datasets.py b/src/cloudflare/resources/ai_gateway/datasets.py index 91601b7a385..1088fe9c208 100644 --- a/src/cloudflare/resources/ai_gateway/datasets.py +++ b/src/cloudflare/resources/ai_gateway/datasets.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -53,7 +53,7 @@ def create( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, enable: bool, filters: Iterable[dataset_create_params.Filter], name: str, @@ -78,12 +78,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets", + account_id=account_id, + gateway_id=gateway_id, + ), body=maybe_transform( { "enable": enable, @@ -106,7 +112,7 @@ def update( self, id: str, *, - account_id: str, + account_id: str | None = None, gateway_id: str, enable: bool, filters: Iterable[dataset_update_params.Filter], @@ -132,6 +138,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -139,7 +147,12 @@ def update( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), body=maybe_transform( { "enable": enable, @@ -162,7 +175,7 @@ def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, enable: bool | Omit = omit, name: str | Omit = omit, page: int | Omit = omit, @@ -191,12 +204,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets", + account_id=account_id, + gateway_id=gateway_id, + ), page=SyncV4PagePaginationArray[DatasetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -221,7 +240,7 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -244,6 +263,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -251,7 +272,12 @@ def delete( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -266,7 +292,7 @@ def get( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -289,6 +315,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -296,7 +324,12 @@ def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -332,7 +365,7 @@ async def create( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, enable: bool, filters: Iterable[dataset_create_params.Filter], name: str, @@ -357,12 +390,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets", + account_id=account_id, + gateway_id=gateway_id, + ), body=await async_maybe_transform( { "enable": enable, @@ -385,7 +424,7 @@ async def update( self, id: str, *, - account_id: str, + account_id: str | None = None, gateway_id: str, enable: bool, filters: Iterable[dataset_update_params.Filter], @@ -411,6 +450,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -418,7 +459,12 @@ async def update( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), body=await async_maybe_transform( { "enable": enable, @@ -441,7 +487,7 @@ def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, enable: bool | Omit = omit, name: str | Omit = omit, page: int | Omit = omit, @@ -470,12 +516,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets", + account_id=account_id, + gateway_id=gateway_id, + ), page=AsyncV4PagePaginationArray[DatasetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -500,7 +552,7 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -523,6 +575,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -530,7 +584,12 @@ async def delete( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -545,7 +604,7 @@ async def get( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -568,6 +627,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -575,7 +636,12 @@ async def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ai_gateway/dynamic_routing.py b/src/cloudflare/resources/ai_gateway/dynamic_routing.py index d4ad8c97251..3268cf04ed1 100644 --- a/src/cloudflare/resources/ai_gateway/dynamic_routing.py +++ b/src/cloudflare/resources/ai_gateway/dynamic_routing.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -62,7 +62,7 @@ def create( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -84,12 +84,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes", + account_id=account_id, + gateway_id=gateway_id, + ), body=maybe_transform( { "elements": elements, @@ -111,7 +117,7 @@ def update( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -133,6 +139,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -140,7 +148,12 @@ def update( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=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 @@ -152,7 +165,7 @@ def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -172,12 +185,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes", + account_id=account_id, + gateway_id=gateway_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -188,7 +207,7 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -209,6 +228,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -216,7 +237,12 @@ def delete( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -231,7 +257,7 @@ def create_deployment( self, id: str, *, - account_id: str, + account_id: str | None = None, gateway_id: str, version_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -253,6 +279,8 @@ def create_deployment( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -260,7 +288,12 @@ def create_deployment( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), body=maybe_transform( {"version_id": version_id}, dynamic_routing_create_deployment_params.DynamicRoutingCreateDeploymentParams, @@ -281,7 +314,7 @@ def create_version( self, id: str, *, - account_id: str, + account_id: str | None = None, gateway_id: 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. @@ -303,6 +336,8 @@ def create_version( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -310,7 +345,12 @@ def create_version( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), body=maybe_transform( {"elements": elements}, dynamic_routing_create_version_params.DynamicRoutingCreateVersionParams ), @@ -328,7 +368,7 @@ def get( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -349,6 +389,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -356,7 +398,12 @@ def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -371,7 +418,7 @@ def get_version( self, version_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -393,6 +440,8 @@ def get_version( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -402,7 +451,13 @@ def get_version( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions/{version_id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -417,7 +472,7 @@ def list_deployments( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -438,6 +493,8 @@ def list_deployments( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -445,7 +502,12 @@ def list_deployments( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -456,7 +518,7 @@ def list_versions( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -477,6 +539,8 @@ def list_versions( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -484,7 +548,12 @@ def list_versions( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -516,7 +585,7 @@ async def create( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -538,12 +607,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes", + account_id=account_id, + gateway_id=gateway_id, + ), body=await async_maybe_transform( { "elements": elements, @@ -565,7 +640,7 @@ async def update( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -587,6 +662,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -594,7 +671,12 @@ async def update( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=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 @@ -606,7 +688,7 @@ async def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -626,12 +708,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes", + account_id=account_id, + gateway_id=gateway_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -642,7 +730,7 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -663,6 +751,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -670,7 +760,12 @@ async def delete( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -685,7 +780,7 @@ async def create_deployment( self, id: str, *, - account_id: str, + account_id: str | None = None, gateway_id: str, version_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -707,6 +802,8 @@ async def create_deployment( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -714,7 +811,12 @@ async def create_deployment( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), body=await async_maybe_transform( {"version_id": version_id}, dynamic_routing_create_deployment_params.DynamicRoutingCreateDeploymentParams, @@ -735,7 +837,7 @@ async def create_version( self, id: str, *, - account_id: str, + account_id: str | None = None, gateway_id: 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. @@ -757,6 +859,8 @@ async def create_version( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -764,7 +868,12 @@ async def create_version( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), body=await async_maybe_transform( {"elements": elements}, dynamic_routing_create_version_params.DynamicRoutingCreateVersionParams ), @@ -782,7 +891,7 @@ async def get( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -803,6 +912,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -810,7 +921,12 @@ async def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -825,7 +941,7 @@ async def get_version( self, version_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -847,6 +963,8 @@ async def get_version( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -856,7 +974,13 @@ async def get_version( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions/{version_id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -871,7 +995,7 @@ async def list_deployments( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -892,6 +1016,8 @@ async def list_deployments( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -899,7 +1025,12 @@ async def list_deployments( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -910,7 +1041,7 @@ async def list_versions( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -931,6 +1062,8 @@ async def list_versions( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -938,7 +1071,12 @@ async def list_versions( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/ai_gateway/evaluation_types.py b/src/cloudflare/resources/ai_gateway/evaluation_types.py index ed06314835d..17be00d592a 100644 --- a/src/cloudflare/resources/ai_gateway/evaluation_types.py +++ b/src/cloudflare/resources/ai_gateway/evaluation_types.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> EvaluationTypesResourceWithStreamingRespons def list( self, *, - account_id: str, + account_id: str | None = None, order_by: str | Omit = omit, order_by_direction: Literal["asc", "desc"] | Omit = omit, page: int | Omit = omit, @@ -71,10 +71,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-gateway/evaluation-types", account_id=account_id), page=SyncV4PagePaginationArray[EvaluationTypeListResponse], options=make_request_options( extra_headers=extra_headers, @@ -118,7 +120,7 @@ def with_streaming_response(self) -> AsyncEvaluationTypesResourceWithStreamingRe def list( self, *, - account_id: str, + account_id: str | None = None, order_by: str | Omit = omit, order_by_direction: Literal["asc", "desc"] | Omit = omit, page: int | Omit = omit, @@ -142,10 +144,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-gateway/evaluation-types", account_id=account_id), page=AsyncV4PagePaginationArray[EvaluationTypeListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/ai_gateway/evaluations.py b/src/cloudflare/resources/ai_gateway/evaluations.py index b466e084495..26b1497345b 100644 --- a/src/cloudflare/resources/ai_gateway/evaluations.py +++ b/src/cloudflare/resources/ai_gateway/evaluations.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def create( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, dataset_ids: SequenceNotStr[str], evaluation_type_ids: SequenceNotStr[str], name: str, @@ -77,12 +77,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations", + account_id=account_id, + gateway_id=gateway_id, + ), body=maybe_transform( { "dataset_ids": dataset_ids, @@ -105,7 +111,7 @@ def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -134,12 +140,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations", + account_id=account_id, + gateway_id=gateway_id, + ), page=SyncV4PagePaginationArray[EvaluationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -164,7 +176,7 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -187,6 +199,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -194,7 +208,12 @@ def delete( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -209,7 +228,7 @@ def get( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -232,6 +251,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -239,7 +260,12 @@ def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -275,7 +301,7 @@ async def create( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, dataset_ids: SequenceNotStr[str], evaluation_type_ids: SequenceNotStr[str], name: str, @@ -300,12 +326,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations", + account_id=account_id, + gateway_id=gateway_id, + ), body=await async_maybe_transform( { "dataset_ids": dataset_ids, @@ -328,7 +360,7 @@ def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -357,12 +389,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations", + account_id=account_id, + gateway_id=gateway_id, + ), page=AsyncV4PagePaginationArray[EvaluationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -387,7 +425,7 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -410,6 +448,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -417,7 +457,12 @@ async def delete( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -432,7 +477,7 @@ async def get( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -455,6 +500,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -462,7 +509,12 @@ async def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs.py index 0ea6559c96b..32c18a9f5f4 100644 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs.py @@ -9,7 +9,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -53,7 +53,7 @@ def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, cached: bool | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, end_date: Union[str, datetime] | Omit = omit, @@ -103,12 +103,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/logs", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs", + account_id=account_id, + gateway_id=gateway_id, + ), page=SyncV4PagePaginationArray[LogListResponse], options=make_request_options( extra_headers=extra_headers, @@ -156,7 +162,7 @@ def delete( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, filters: Iterable[log_delete_params.Filter] | Omit = omit, limit: int | Omit = omit, order_by: Literal[ @@ -195,12 +201,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs", + account_id=account_id, + gateway_id=gateway_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -223,7 +235,7 @@ def edit( self, id: str, *, - account_id: str, + account_id: str | None = None, gateway_id: str, feedback: Optional[float] | Omit = omit, metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit, @@ -249,6 +261,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -256,7 +270,12 @@ def edit( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), body=maybe_transform( { "feedback": feedback, @@ -279,7 +298,7 @@ def get( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -302,6 +321,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -309,7 +330,12 @@ def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -324,7 +350,7 @@ def request( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -347,6 +373,8 @@ def request( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -354,7 +382,12 @@ def request( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/request", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -365,7 +398,7 @@ def response( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -388,6 +421,8 @@ def response( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -395,7 +430,12 @@ def response( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/response", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -427,7 +467,7 @@ def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, cached: bool | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, end_date: Union[str, datetime] | Omit = omit, @@ -477,12 +517,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/logs", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs", + account_id=account_id, + gateway_id=gateway_id, + ), page=AsyncV4PagePaginationArray[LogListResponse], options=make_request_options( extra_headers=extra_headers, @@ -530,7 +576,7 @@ async def delete( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, filters: Iterable[log_delete_params.Filter] | Omit = omit, limit: int | Omit = omit, order_by: Literal[ @@ -569,12 +615,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs", + account_id=account_id, + gateway_id=gateway_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -597,7 +649,7 @@ async def edit( self, id: str, *, - account_id: str, + account_id: str | None = None, gateway_id: str, feedback: Optional[float] | Omit = omit, metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit, @@ -623,6 +675,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -630,7 +684,12 @@ async def edit( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), body=await async_maybe_transform( { "feedback": feedback, @@ -653,7 +712,7 @@ async def get( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -676,6 +735,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -683,7 +744,12 @@ async def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -698,7 +764,7 @@ async def request( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -721,6 +787,8 @@ async def request( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -728,7 +796,12 @@ async def request( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/request", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -739,7 +812,7 @@ async def response( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -762,6 +835,8 @@ async def response( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -769,7 +844,12 @@ async def response( 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/response", + account_id=account_id, + gateway_id=gateway_id, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/ai_gateway/provider_configs.py b/src/cloudflare/resources/ai_gateway/provider_configs.py index 2e75c14bdc3..c0af4ebe77a 100644 --- a/src/cloudflare/resources/ai_gateway/provider_configs.py +++ b/src/cloudflare/resources/ai_gateway/provider_configs.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def create( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, alias: str, default_config: bool, provider_slug: str, @@ -79,12 +79,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs", + account_id=account_id, + gateway_id=gateway_id, + ), body=maybe_transform( { "alias": alias, @@ -111,7 +117,7 @@ def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -135,12 +141,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs", + account_id=account_id, + gateway_id=gateway_id, + ), page=SyncV4PagePaginationArray[ProviderConfigListResponse], options=make_request_options( extra_headers=extra_headers, @@ -183,7 +195,7 @@ async def create( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, alias: str, default_config: bool, provider_slug: str, @@ -212,12 +224,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs", + account_id=account_id, + gateway_id=gateway_id, + ), body=await async_maybe_transform( { "alias": alias, @@ -244,7 +262,7 @@ def list( self, gateway_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -268,12 +286,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs", + account_id=account_id, + gateway_id=gateway_id, + ), page=AsyncV4PagePaginationArray[ProviderConfigListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/ai_gateway/urls.py b/src/cloudflare/resources/ai_gateway/urls.py index 988e21ecc24..50c6c57c708 100644 --- a/src/cloudflare/resources/ai_gateway/urls.py +++ b/src/cloudflare/resources/ai_gateway/urls.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +47,7 @@ def get( self, provider: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -69,6 +70,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -76,7 +79,12 @@ def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}", + account_id=account_id, + gateway_id=gateway_id, + provider=provider, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -112,7 +120,7 @@ async def get( self, provider: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -135,6 +143,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gateway_id: @@ -142,7 +152,12 @@ async def get( 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}", + path_template( + "/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}", + account_id=account_id, + gateway_id=gateway_id, + provider=provider, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/aisearch/__init__.py b/src/cloudflare/resources/aisearch/__init__.py index e7d15dd59ad..1929faa11e4 100644 --- a/src/cloudflare/resources/aisearch/__init__.py +++ b/src/cloudflare/resources/aisearch/__init__.py @@ -24,8 +24,22 @@ InstancesResourceWithStreamingResponse, AsyncInstancesResourceWithStreamingResponse, ) +from .namespaces import ( + NamespacesResource, + AsyncNamespacesResource, + NamespacesResourceWithRawResponse, + AsyncNamespacesResourceWithRawResponse, + NamespacesResourceWithStreamingResponse, + AsyncNamespacesResourceWithStreamingResponse, +) __all__ = [ + "NamespacesResource", + "AsyncNamespacesResource", + "NamespacesResourceWithRawResponse", + "AsyncNamespacesResourceWithRawResponse", + "NamespacesResourceWithStreamingResponse", + "AsyncNamespacesResourceWithStreamingResponse", "InstancesResource", "AsyncInstancesResource", "InstancesResourceWithRawResponse", diff --git a/src/cloudflare/resources/aisearch/aisearch.py b/src/cloudflare/resources/aisearch/aisearch.py index 483739a1224..a77e3929dbf 100644 --- a/src/cloudflare/resources/aisearch/aisearch.py +++ b/src/cloudflare/resources/aisearch/aisearch.py @@ -20,11 +20,23 @@ InstancesResourceWithStreamingResponse, AsyncInstancesResourceWithStreamingResponse, ) +from .namespaces.namespaces import ( + NamespacesResource, + AsyncNamespacesResource, + NamespacesResourceWithRawResponse, + AsyncNamespacesResourceWithRawResponse, + NamespacesResourceWithStreamingResponse, + AsyncNamespacesResourceWithStreamingResponse, +) __all__ = ["AISearchResource", "AsyncAISearchResource"] class AISearchResource(SyncAPIResource): + @cached_property + def namespaces(self) -> NamespacesResource: + return NamespacesResource(self._client) + @cached_property def instances(self) -> InstancesResource: return InstancesResource(self._client) @@ -54,6 +66,10 @@ def with_streaming_response(self) -> AISearchResourceWithStreamingResponse: class AsyncAISearchResource(AsyncAPIResource): + @cached_property + def namespaces(self) -> AsyncNamespacesResource: + return AsyncNamespacesResource(self._client) + @cached_property def instances(self) -> AsyncInstancesResource: return AsyncInstancesResource(self._client) @@ -86,6 +102,10 @@ class AISearchResourceWithRawResponse: def __init__(self, aisearch: AISearchResource) -> None: self._aisearch = aisearch + @cached_property + def namespaces(self) -> NamespacesResourceWithRawResponse: + return NamespacesResourceWithRawResponse(self._aisearch.namespaces) + @cached_property def instances(self) -> InstancesResourceWithRawResponse: return InstancesResourceWithRawResponse(self._aisearch.instances) @@ -99,6 +119,10 @@ class AsyncAISearchResourceWithRawResponse: def __init__(self, aisearch: AsyncAISearchResource) -> None: self._aisearch = aisearch + @cached_property + def namespaces(self) -> AsyncNamespacesResourceWithRawResponse: + return AsyncNamespacesResourceWithRawResponse(self._aisearch.namespaces) + @cached_property def instances(self) -> AsyncInstancesResourceWithRawResponse: return AsyncInstancesResourceWithRawResponse(self._aisearch.instances) @@ -112,6 +136,10 @@ class AISearchResourceWithStreamingResponse: def __init__(self, aisearch: AISearchResource) -> None: self._aisearch = aisearch + @cached_property + def namespaces(self) -> NamespacesResourceWithStreamingResponse: + return NamespacesResourceWithStreamingResponse(self._aisearch.namespaces) + @cached_property def instances(self) -> InstancesResourceWithStreamingResponse: return InstancesResourceWithStreamingResponse(self._aisearch.instances) @@ -125,6 +153,10 @@ class AsyncAISearchResourceWithStreamingResponse: def __init__(self, aisearch: AsyncAISearchResource) -> None: self._aisearch = aisearch + @cached_property + def namespaces(self) -> AsyncNamespacesResourceWithStreamingResponse: + return AsyncNamespacesResourceWithStreamingResponse(self._aisearch.namespaces) + @cached_property def instances(self) -> AsyncInstancesResourceWithStreamingResponse: return AsyncInstancesResourceWithStreamingResponse(self._aisearch.instances) diff --git a/src/cloudflare/resources/aisearch/api.md b/src/cloudflare/resources/aisearch/api.md new file mode 100644 index 00000000000..f861fd17930 --- /dev/null +++ b/src/cloudflare/resources/aisearch/api.md @@ -0,0 +1,174 @@ +# AISearch + +## Namespaces + +Types: + +```python +from cloudflare.types.aisearch import ( + NamespaceCreateResponse, + NamespaceUpdateResponse, + NamespaceListResponse, + NamespaceChatCompletionsResponse, + NamespaceReadResponse, + NamespaceSearchResponse, +) +``` + +Methods: + +- client.aisearch.namespaces.create(\*, account_id, \*\*params) -> NamespaceCreateResponse +- client.aisearch.namespaces.update(name, \*, account_id, \*\*params) -> NamespaceUpdateResponse +- client.aisearch.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[NamespaceListResponse] +- client.aisearch.namespaces.delete(name, \*, account_id) -> object +- client.aisearch.namespaces.chat_completions(name, \*, account_id, \*\*params) -> NamespaceChatCompletionsResponse +- client.aisearch.namespaces.read(name, \*, account_id) -> NamespaceReadResponse +- client.aisearch.namespaces.search(name, \*, account_id, \*\*params) -> NamespaceSearchResponse + +### Instances + +Types: + +```python +from cloudflare.types.aisearch.namespaces import ( + InstanceCreateResponse, + InstanceUpdateResponse, + InstanceListResponse, + InstanceDeleteResponse, + InstanceChatCompletionsResponse, + InstanceReadResponse, + InstanceSearchResponse, + InstanceStatsResponse, +) +``` + +Methods: + +- client.aisearch.namespaces.instances.create(name, \*, account_id, \*\*params) -> InstanceCreateResponse +- client.aisearch.namespaces.instances.update(id, \*, account_id, name, \*\*params) -> InstanceUpdateResponse +- client.aisearch.namespaces.instances.list(name, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[InstanceListResponse] +- client.aisearch.namespaces.instances.delete(id, \*, account_id, name) -> InstanceDeleteResponse +- client.aisearch.namespaces.instances.chat_completions(id, \*, account_id, name, \*\*params) -> InstanceChatCompletionsResponse +- client.aisearch.namespaces.instances.read(id, \*, account_id, name) -> InstanceReadResponse +- client.aisearch.namespaces.instances.search(id, \*, account_id, name, \*\*params) -> InstanceSearchResponse +- client.aisearch.namespaces.instances.stats(id, \*, account_id, name) -> InstanceStatsResponse + +#### Jobs + +Types: + +```python +from cloudflare.types.aisearch.namespaces.instances import ( + JobCreateResponse, + JobUpdateResponse, + JobListResponse, + JobGetResponse, + JobLogsResponse, +) +``` + +Methods: + +- client.aisearch.namespaces.instances.jobs.create(id, \*, account_id, name, \*\*params) -> JobCreateResponse +- client.aisearch.namespaces.instances.jobs.update(job_id, \*, account_id, name, id, \*\*params) -> JobUpdateResponse +- client.aisearch.namespaces.instances.jobs.list(id, \*, account_id, name, \*\*params) -> SyncV4PagePaginationArray[JobListResponse] +- client.aisearch.namespaces.instances.jobs.get(job_id, \*, account_id, name, id) -> JobGetResponse +- client.aisearch.namespaces.instances.jobs.logs(job_id, \*, account_id, name, id, \*\*params) -> JobLogsResponse + +#### Items + +Types: + +```python +from cloudflare.types.aisearch.namespaces.instances import ( + ItemListResponse, + ItemDeleteResponse, + ItemChunksResponse, + ItemCreateOrUpdateResponse, + ItemGetResponse, + ItemLogsResponse, + ItemSyncResponse, + ItemUploadResponse, +) +``` + +Methods: + +- client.aisearch.namespaces.instances.items.list(id, \*, account_id, name, \*\*params) -> SyncV4PagePaginationArray[ItemListResponse] +- client.aisearch.namespaces.instances.items.delete(item_id, \*, account_id, name, id) -> ItemDeleteResponse +- client.aisearch.namespaces.instances.items.chunks(item_id, \*, account_id, name, id, \*\*params) -> ItemChunksResponse +- client.aisearch.namespaces.instances.items.create_or_update(id, \*, account_id, name, \*\*params) -> ItemCreateOrUpdateResponse +- client.aisearch.namespaces.instances.items.download(item_id, \*, account_id, name, id) -> BinaryAPIResponse +- client.aisearch.namespaces.instances.items.get(item_id, \*, account_id, name, id) -> ItemGetResponse +- client.aisearch.namespaces.instances.items.logs(item_id, \*, account_id, name, id, \*\*params) -> ItemLogsResponse +- client.aisearch.namespaces.instances.items.sync(item_id, \*, account_id, name, id, \*\*params) -> ItemSyncResponse +- client.aisearch.namespaces.instances.items.upload(id, \*, account_id, name, \*\*params) -> ItemUploadResponse + +## Instances + +Types: + +```python +from cloudflare.types.aisearch import ( + InstanceCreateResponse, + InstanceUpdateResponse, + InstanceListResponse, + InstanceDeleteResponse, + InstanceChatCompletionsResponse, + InstanceReadResponse, + InstanceSearchResponse, + InstanceStatsResponse, +) +``` + +Methods: + +- 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 + +### Jobs + +Types: + +```python +from cloudflare.types.aisearch.instances import ( + JobCreateResponse, + JobListResponse, + JobGetResponse, + JobLogsResponse, +) +``` + +Methods: + +- client.aisearch.instances.jobs.create(id, \*, account_id, \*\*params) -> 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 + +## Tokens + +Types: + +```python +from cloudflare.types.aisearch import ( + TokenCreateResponse, + TokenUpdateResponse, + TokenListResponse, + TokenReadResponse, +) +``` + +Methods: + +- 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) -> object +- client.aisearch.tokens.read(id, \*, account_id) -> TokenReadResponse diff --git a/src/cloudflare/resources/aisearch/instances/instances.py b/src/cloudflare/resources/aisearch/instances/instances.py index a555deae5be..1f033a72cbc 100644 --- a/src/cloudflare/resources/aisearch/instances/instances.py +++ b/src/cloudflare/resources/aisearch/instances/instances.py @@ -16,7 +16,7 @@ AsyncJobsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -74,7 +74,7 @@ def with_streaming_response(self) -> InstancesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, id: str, ai_gateway_id: Optional[str] | Omit = omit, aisearch_model: Optional[ @@ -182,7 +182,7 @@ def create( score_threshold: float | Omit = omit, source: Optional[str] | Omit = omit, source_params: Optional[instance_create_params.SourceParams] | Omit = omit, - sync_interval: Literal[3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, token_id: str | Omit = omit, type: Optional[Literal["r2", "web-crawler"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -204,8 +204,8 @@ def create( index_method: Controls which storage backends are used during indexing. Defaults to vector-only. - sync_interval: Interval between automatic syncs, in seconds. Allowed values: 3600 (1h), 7200 - (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). + sync_interval: Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 + (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). extra_headers: Send extra headers @@ -215,10 +215,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances", account_id=account_id), body=maybe_transform( { "id": id, @@ -266,7 +268,7 @@ def update( self, id: str, *, - account_id: str, + account_id: str | None = None, ai_gateway_id: Optional[str] | Omit = omit, aisearch_model: Optional[ Literal[ @@ -408,7 +410,7 @@ def update( ] ] | Omit = omit, - sync_interval: Literal[3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, system_prompt_aisearch: Optional[str] | Omit = omit, system_prompt_index_summarization: Optional[str] | Omit = omit, system_prompt_rewrite_query: Optional[str] | Omit = omit, @@ -430,8 +432,8 @@ def update( index_method: Controls which storage backends are used during indexing. Defaults to vector-only. - sync_interval: Interval between automatic syncs, in seconds. Allowed values: 3600 (1h), 7200 - (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). + sync_interval: Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 + (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). extra_headers: Send extra headers @@ -441,12 +443,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/instances/{id}", account_id=account_id, id=id), body=maybe_transform( { "ai_gateway_id": ai_gateway_id, @@ -495,7 +499,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, namespace: Optional[str] | Omit = omit, order_by: Literal["created_at"] | Omit = omit, order_by_direction: Literal["asc", "desc"] | Omit = omit, @@ -527,10 +531,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances", account_id=account_id), page=SyncV4PagePaginationArray[InstanceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -556,7 +562,7 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -579,12 +585,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/instances/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -599,7 +607,7 @@ def chat_completions( self, id: str, *, - account_id: str, + account_id: str | None = None, messages: Iterable[instance_chat_completions_params.Message], aisearch_options: instance_chat_completions_params.AISearchOptions | Omit = omit, model: Literal[ @@ -658,12 +666,16 @@ def chat_completions( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-search/instances/{id}/chat/completions", account_id=account_id, id=id + ), body=maybe_transform( { "messages": messages, @@ -683,7 +695,7 @@ def read( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -706,12 +718,14 @@ def read( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/instances/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -726,7 +740,7 @@ def search( self, id: str, *, - account_id: str, + account_id: str | None = None, aisearch_options: instance_search_params.AISearchOptions | Omit = omit, messages: Iterable[instance_search_params.Message] | Omit = omit, query: str | Omit = omit, @@ -755,12 +769,14 @@ def search( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances/{id}/search", account_id=account_id, id=id), body=maybe_transform( { "aisearch_options": aisearch_options, @@ -783,7 +799,7 @@ def stats( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -805,12 +821,14 @@ def stats( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances/{id}/stats", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -849,7 +867,7 @@ def with_streaming_response(self) -> AsyncInstancesResourceWithStreamingResponse async def create( self, *, - account_id: str, + account_id: str | None = None, id: str, ai_gateway_id: Optional[str] | Omit = omit, aisearch_model: Optional[ @@ -957,7 +975,7 @@ async def create( score_threshold: float | Omit = omit, source: Optional[str] | Omit = omit, source_params: Optional[instance_create_params.SourceParams] | Omit = omit, - sync_interval: Literal[3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, token_id: str | Omit = omit, type: Optional[Literal["r2", "web-crawler"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -979,8 +997,8 @@ async def create( index_method: Controls which storage backends are used during indexing. Defaults to vector-only. - sync_interval: Interval between automatic syncs, in seconds. Allowed values: 3600 (1h), 7200 - (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). + sync_interval: Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 + (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). extra_headers: Send extra headers @@ -990,10 +1008,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances", account_id=account_id), body=await async_maybe_transform( { "id": id, @@ -1041,7 +1061,7 @@ async def update( self, id: str, *, - account_id: str, + account_id: str | None = None, ai_gateway_id: Optional[str] | Omit = omit, aisearch_model: Optional[ Literal[ @@ -1183,7 +1203,7 @@ async def update( ] ] | Omit = omit, - sync_interval: Literal[3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, system_prompt_aisearch: Optional[str] | Omit = omit, system_prompt_index_summarization: Optional[str] | Omit = omit, system_prompt_rewrite_query: Optional[str] | Omit = omit, @@ -1205,8 +1225,8 @@ async def update( index_method: Controls which storage backends are used during indexing. Defaults to vector-only. - sync_interval: Interval between automatic syncs, in seconds. Allowed values: 3600 (1h), 7200 - (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). + sync_interval: Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 + (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). extra_headers: Send extra headers @@ -1216,12 +1236,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/instances/{id}", account_id=account_id, id=id), body=await async_maybe_transform( { "ai_gateway_id": ai_gateway_id, @@ -1270,7 +1292,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, namespace: Optional[str] | Omit = omit, order_by: Literal["created_at"] | Omit = omit, order_by_direction: Literal["asc", "desc"] | Omit = omit, @@ -1302,10 +1324,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances", account_id=account_id), page=AsyncV4PagePaginationArray[InstanceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -1331,7 +1355,7 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1354,12 +1378,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/instances/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1374,7 +1400,7 @@ async def chat_completions( self, id: str, *, - account_id: str, + account_id: str | None = None, messages: Iterable[instance_chat_completions_params.Message], aisearch_options: instance_chat_completions_params.AISearchOptions | Omit = omit, model: Literal[ @@ -1433,12 +1459,16 @@ async def chat_completions( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/ai-search/instances/{id}/chat/completions", account_id=account_id, id=id + ), body=await async_maybe_transform( { "messages": messages, @@ -1458,7 +1488,7 @@ async def read( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1481,12 +1511,14 @@ async def read( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/instances/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1501,7 +1533,7 @@ async def search( self, id: str, *, - account_id: str, + account_id: str | None = None, aisearch_options: instance_search_params.AISearchOptions | Omit = omit, messages: Iterable[instance_search_params.Message] | Omit = omit, query: str | Omit = omit, @@ -1530,12 +1562,14 @@ async def search( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances/{id}/search", account_id=account_id, id=id), body=await async_maybe_transform( { "aisearch_options": aisearch_options, @@ -1558,7 +1592,7 @@ async def stats( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1580,12 +1614,14 @@ async def stats( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances/{id}/stats", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/aisearch/instances/jobs.py b/src/cloudflare/resources/aisearch/instances/jobs.py index a9bfcf9eb60..f7c31e7d100 100644 --- a/src/cloudflare/resources/aisearch/instances/jobs.py +++ b/src/cloudflare/resources/aisearch/instances/jobs.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def create( self, id: str, *, - account_id: str, + account_id: str | None = None, description: 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. @@ -75,12 +75,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances/{id}/jobs", account_id=account_id, id=id), body=maybe_transform({"description": description}, job_create_params.JobCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -96,7 +98,7 @@ def list( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -120,12 +122,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances/{id}/jobs", account_id=account_id, id=id), page=SyncV4PagePaginationArray[JobListResponse], options=make_request_options( extra_headers=extra_headers, @@ -147,7 +151,7 @@ def get( self, job_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -170,6 +174,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not id: @@ -177,7 +183,12 @@ def get( 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}", + path_template( + "/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}", + account_id=account_id, + id=id, + job_id=job_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -192,7 +203,7 @@ def logs( self, job_id: str, *, - account_id: str, + account_id: str | None = None, id: str, page: int | Omit = omit, per_page: int | Omit = omit, @@ -217,6 +228,8 @@ def logs( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not id: @@ -224,7 +237,12 @@ def logs( 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", + path_template( + "/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}/logs", + account_id=account_id, + id=id, + job_id=job_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -267,7 +285,7 @@ async def create( self, id: str, *, - account_id: str, + account_id: str | None = None, description: 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. @@ -290,12 +308,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances/{id}/jobs", account_id=account_id, id=id), body=await async_maybe_transform({"description": description}, job_create_params.JobCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -311,7 +331,7 @@ def list( self, id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -335,12 +355,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/instances/{id}/jobs", account_id=account_id, id=id), page=AsyncV4PagePaginationArray[JobListResponse], options=make_request_options( extra_headers=extra_headers, @@ -362,7 +384,7 @@ async def get( self, job_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -385,6 +407,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not id: @@ -392,7 +416,12 @@ async def get( 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}", + path_template( + "/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}", + account_id=account_id, + id=id, + job_id=job_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -407,7 +436,7 @@ async def logs( self, job_id: str, *, - account_id: str, + account_id: str | None = None, id: str, page: int | Omit = omit, per_page: int | Omit = omit, @@ -432,6 +461,8 @@ async def logs( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not id: @@ -439,7 +470,12 @@ async def logs( 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", + path_template( + "/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}/logs", + account_id=account_id, + id=id, + job_id=job_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/aisearch/namespaces/__init__.py b/src/cloudflare/resources/aisearch/namespaces/__init__.py new file mode 100644 index 00000000000..de69633eb36 --- /dev/null +++ b/src/cloudflare/resources/aisearch/namespaces/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .instances import ( + InstancesResource, + AsyncInstancesResource, + InstancesResourceWithRawResponse, + AsyncInstancesResourceWithRawResponse, + InstancesResourceWithStreamingResponse, + AsyncInstancesResourceWithStreamingResponse, +) +from .namespaces import ( + NamespacesResource, + AsyncNamespacesResource, + NamespacesResourceWithRawResponse, + AsyncNamespacesResourceWithRawResponse, + NamespacesResourceWithStreamingResponse, + AsyncNamespacesResourceWithStreamingResponse, +) + +__all__ = [ + "InstancesResource", + "AsyncInstancesResource", + "InstancesResourceWithRawResponse", + "AsyncInstancesResourceWithRawResponse", + "InstancesResourceWithStreamingResponse", + "AsyncInstancesResourceWithStreamingResponse", + "NamespacesResource", + "AsyncNamespacesResource", + "NamespacesResourceWithRawResponse", + "AsyncNamespacesResourceWithRawResponse", + "NamespacesResourceWithStreamingResponse", + "AsyncNamespacesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/aisearch/namespaces/instances/__init__.py b/src/cloudflare/resources/aisearch/namespaces/instances/__init__.py new file mode 100644 index 00000000000..258ebff8a28 --- /dev/null +++ b/src/cloudflare/resources/aisearch/namespaces/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__ = [ + "JobsResource", + "AsyncJobsResource", + "JobsResourceWithRawResponse", + "AsyncJobsResourceWithRawResponse", + "JobsResourceWithStreamingResponse", + "AsyncJobsResourceWithStreamingResponse", + "ItemsResource", + "AsyncItemsResource", + "ItemsResourceWithRawResponse", + "AsyncItemsResourceWithRawResponse", + "ItemsResourceWithStreamingResponse", + "AsyncItemsResourceWithStreamingResponse", + "InstancesResource", + "AsyncInstancesResource", + "InstancesResourceWithRawResponse", + "AsyncInstancesResourceWithRawResponse", + "InstancesResourceWithStreamingResponse", + "AsyncInstancesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/aisearch/namespaces/instances/instances.py b/src/cloudflare/resources/aisearch/namespaces/instances/instances.py new file mode 100644 index 00000000000..3a08044deed --- /dev/null +++ b/src/cloudflare/resources/aisearch/namespaces/instances/instances.py @@ -0,0 +1,1913 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, Optional, 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 path_template, 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.namespaces import ( + instance_list_params, + instance_create_params, + instance_search_params, + instance_update_params, + instance_chat_completions_params, +) +from .....types.aisearch.namespaces.instance_list_response import InstanceListResponse +from .....types.aisearch.namespaces.instance_read_response import InstanceReadResponse +from .....types.aisearch.namespaces.instance_stats_response import InstanceStatsResponse +from .....types.aisearch.namespaces.instance_create_response import InstanceCreateResponse +from .....types.aisearch.namespaces.instance_delete_response import InstanceDeleteResponse +from .....types.aisearch.namespaces.instance_search_response import InstanceSearchResponse +from .....types.aisearch.namespaces.instance_update_response import InstanceUpdateResponse +from .....types.aisearch.namespaces.instance_chat_completions_response import InstanceChatCompletionsResponse + +__all__ = ["InstancesResource", "AsyncInstancesResource"] + + +class InstancesResource(SyncAPIResource): + @cached_property + def jobs(self) -> JobsResource: + return JobsResource(self._client) + + @cached_property + def items(self) -> ItemsResource: + return ItemsResource(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, + name: str, + *, + account_id: str | None = None, + id: str, + ai_gateway_id: Optional[str] | Omit = omit, + aisearch_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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_create_params.CustomMetadata] | Omit = omit, + embedding_model: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] + | Omit = omit, + fusion_method: Literal["max", "rrf"] | Omit = omit, + hybrid_search_enabled: bool | Omit = omit, + index_method: instance_create_params.IndexMethod | Omit = omit, + indexing_options: Optional[instance_create_params.IndexingOptions] | 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: Optional[Literal["@cf/baai/bge-reranker-base", ""]] | Omit = omit, + retrieval_options: Optional[instance_create_params.RetrievalOptions] | Omit = omit, + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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: Optional[str] | Omit = omit, + source_params: Optional[instance_create_params.SourceParams] | Omit = omit, + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, + token_id: str | Omit = omit, + type: Optional[Literal["r2", "web-crawler"]] | 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 a new instances. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + hybrid_search_enabled: Deprecated — use index_method instead. + + index_method: Controls which storage backends are used during indexing. Defaults to + vector-only. + + sync_interval: Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 + (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances", account_id=account_id, name=name + ), + body=maybe_transform( + { + "id": id, + "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, + "fusion_method": fusion_method, + "hybrid_search_enabled": hybrid_search_enabled, + "index_method": index_method, + "indexing_options": indexing_options, + "max_num_results": max_num_results, + "metadata": metadata, + "public_endpoint_params": public_endpoint_params, + "reranking": reranking, + "reranking_model": reranking_model, + "retrieval_options": retrieval_options, + "rewrite_model": rewrite_model, + "rewrite_query": rewrite_query, + "score_threshold": score_threshold, + "source": source, + "source_params": source_params, + "sync_interval": sync_interval, + "token_id": token_id, + "type": type, + }, + 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 | None = None, + name: str, + ai_gateway_id: Optional[str] | Omit = omit, + aisearch_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] + | Omit = omit, + fusion_method: Literal["max", "rrf"] | Omit = omit, + index_method: instance_update_params.IndexMethod | Omit = omit, + indexing_options: Optional[instance_update_params.IndexingOptions] | 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: Optional[Literal["@cf/baai/bge-reranker-base", ""]] | Omit = omit, + retrieval_options: Optional[instance_update_params.RetrievalOptions] | Omit = omit, + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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: Optional[instance_update_params.SourceParams] | Omit = omit, + summarization: bool | Omit = omit, + summarization_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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, + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, + system_prompt_aisearch: Optional[str] | Omit = omit, + system_prompt_index_summarization: Optional[str] | Omit = omit, + system_prompt_rewrite_query: Optional[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: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + index_method: Controls which storage backends are used during indexing. Defaults to + vector-only. + + sync_interval: Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 + (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._put( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}", + account_id=account_id, + name=name, + id=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, + "fusion_method": fusion_method, + "index_method": index_method, + "indexing_options": indexing_options, + "max_num_results": max_num_results, + "metadata": metadata, + "paused": paused, + "public_endpoint_params": public_endpoint_params, + "reranking": reranking, + "reranking_model": reranking_model, + "retrieval_options": retrieval_options, + "rewrite_model": rewrite_model, + "rewrite_query": rewrite_query, + "score_threshold": score_threshold, + "source_params": source_params, + "summarization": summarization, + "summarization_model": summarization_model, + "sync_interval": sync_interval, + "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, + name: str, + *, + account_id: str | None = None, + namespace: Optional[str] | Omit = omit, + order_by: Literal["created_at"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | 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[InstanceListResponse]: + """ + List instances. + + Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return self._get_api_list( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances", account_id=account_id, name=name + ), + page=SyncV4PagePaginationArray[InstanceListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "namespace": namespace, + "order_by": order_by, + "order_by_direction": order_by_direction, + "page": page, + "per_page": per_page, + "search": search, + }, + instance_list_params.InstanceListParams, + ), + ), + model=InstanceListResponse, + ) + + def delete( + self, + id: str, + *, + account_id: str | None = None, + 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, + ) -> InstanceDeleteResponse: + """Delete instances. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}", + account_id=account_id, + name=name, + id=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 | None = None, + name: 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/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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: + """ + Performs a chat completion request against an AI Search instance, using indexed + content as context for generating responses. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/chat/completions", + account_id=account_id, + name=name, + id=id, + ), + 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 | None = None, + 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, + ) -> InstanceReadResponse: + """Read instances. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}", + account_id=account_id, + name=name, + id=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 | None = None, + name: str, + aisearch_options: instance_search_params.AISearchOptions | Omit = omit, + messages: Iterable[instance_search_params.Message] | Omit = omit, + query: 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, + ) -> InstanceSearchResponse: + """ + Executes a semantic search query against an AI Search instance to find relevant + indexed content. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + query: A simple text query string. Alternative to 'messages' — provide either this or + 'messages', not both. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/search", + account_id=account_id, + name=name, + id=id, + ), + body=maybe_transform( + { + "aisearch_options": aisearch_options, + "messages": messages, + "query": query, + }, + 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 | None = None, + 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, + ) -> InstanceStatsResponse: + """ + Retrieves usage statistics for AI Search instances. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/stats", + account_id=account_id, + name=name, + id=id, + ), + 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 jobs(self) -> AsyncJobsResource: + return AsyncJobsResource(self._client) + + @cached_property + def items(self) -> AsyncItemsResource: + return AsyncItemsResource(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, + name: str, + *, + account_id: str | None = None, + id: str, + ai_gateway_id: Optional[str] | Omit = omit, + aisearch_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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_create_params.CustomMetadata] | Omit = omit, + embedding_model: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] + | Omit = omit, + fusion_method: Literal["max", "rrf"] | Omit = omit, + hybrid_search_enabled: bool | Omit = omit, + index_method: instance_create_params.IndexMethod | Omit = omit, + indexing_options: Optional[instance_create_params.IndexingOptions] | 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: Optional[Literal["@cf/baai/bge-reranker-base", ""]] | Omit = omit, + retrieval_options: Optional[instance_create_params.RetrievalOptions] | Omit = omit, + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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: Optional[str] | Omit = omit, + source_params: Optional[instance_create_params.SourceParams] | Omit = omit, + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, + token_id: str | Omit = omit, + type: Optional[Literal["r2", "web-crawler"]] | 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 a new instances. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + hybrid_search_enabled: Deprecated — use index_method instead. + + index_method: Controls which storage backends are used during indexing. Defaults to + vector-only. + + sync_interval: Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 + (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return await self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances", account_id=account_id, name=name + ), + body=await async_maybe_transform( + { + "id": id, + "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, + "fusion_method": fusion_method, + "hybrid_search_enabled": hybrid_search_enabled, + "index_method": index_method, + "indexing_options": indexing_options, + "max_num_results": max_num_results, + "metadata": metadata, + "public_endpoint_params": public_endpoint_params, + "reranking": reranking, + "reranking_model": reranking_model, + "retrieval_options": retrieval_options, + "rewrite_model": rewrite_model, + "rewrite_query": rewrite_query, + "score_threshold": score_threshold, + "source": source, + "source_params": source_params, + "sync_interval": sync_interval, + "token_id": token_id, + "type": type, + }, + 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 | None = None, + name: str, + ai_gateway_id: Optional[str] | Omit = omit, + aisearch_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] + | Omit = omit, + fusion_method: Literal["max", "rrf"] | Omit = omit, + index_method: instance_update_params.IndexMethod | Omit = omit, + indexing_options: Optional[instance_update_params.IndexingOptions] | 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: Optional[Literal["@cf/baai/bge-reranker-base", ""]] | Omit = omit, + retrieval_options: Optional[instance_update_params.RetrievalOptions] | Omit = omit, + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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: Optional[instance_update_params.SourceParams] | Omit = omit, + summarization: bool | Omit = omit, + summarization_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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, + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] | Omit = omit, + system_prompt_aisearch: Optional[str] | Omit = omit, + system_prompt_index_summarization: Optional[str] | Omit = omit, + system_prompt_rewrite_query: Optional[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: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + index_method: Controls which storage backends are used during indexing. Defaults to + vector-only. + + sync_interval: Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 + (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._put( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}", + account_id=account_id, + name=name, + id=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, + "fusion_method": fusion_method, + "index_method": index_method, + "indexing_options": indexing_options, + "max_num_results": max_num_results, + "metadata": metadata, + "paused": paused, + "public_endpoint_params": public_endpoint_params, + "reranking": reranking, + "reranking_model": reranking_model, + "retrieval_options": retrieval_options, + "rewrite_model": rewrite_model, + "rewrite_query": rewrite_query, + "score_threshold": score_threshold, + "source_params": source_params, + "summarization": summarization, + "summarization_model": summarization_model, + "sync_interval": sync_interval, + "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, + name: str, + *, + account_id: str | None = None, + namespace: Optional[str] | Omit = omit, + order_by: Literal["created_at"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | 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[InstanceListResponse, AsyncV4PagePaginationArray[InstanceListResponse]]: + """ + List instances. + + Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return self._get_api_list( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances", account_id=account_id, name=name + ), + page=AsyncV4PagePaginationArray[InstanceListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "namespace": namespace, + "order_by": order_by, + "order_by_direction": order_by_direction, + "page": page, + "per_page": per_page, + "search": search, + }, + instance_list_params.InstanceListParams, + ), + ), + model=InstanceListResponse, + ) + + async def delete( + self, + id: str, + *, + account_id: str | None = None, + 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, + ) -> InstanceDeleteResponse: + """Delete instances. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}", + account_id=account_id, + name=name, + id=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 | None = None, + name: 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/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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: + """ + Performs a chat completion request against an AI Search instance, using indexed + content as context for generating responses. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/chat/completions", + account_id=account_id, + name=name, + id=id, + ), + 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 | None = None, + 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, + ) -> InstanceReadResponse: + """Read instances. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}", + account_id=account_id, + name=name, + id=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 | None = None, + name: str, + aisearch_options: instance_search_params.AISearchOptions | Omit = omit, + messages: Iterable[instance_search_params.Message] | Omit = omit, + query: 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, + ) -> InstanceSearchResponse: + """ + Executes a semantic search query against an AI Search instance to find relevant + indexed content. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + query: A simple text query string. Alternative to 'messages' — provide either this or + 'messages', not both. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/search", + account_id=account_id, + name=name, + id=id, + ), + body=await async_maybe_transform( + { + "aisearch_options": aisearch_options, + "messages": messages, + "query": query, + }, + 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 | None = None, + 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, + ) -> InstanceStatsResponse: + """ + Retrieves usage statistics for AI Search instances. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/stats", + account_id=account_id, + name=name, + id=id, + ), + 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 jobs(self) -> JobsResourceWithRawResponse: + return JobsResourceWithRawResponse(self._instances.jobs) + + @cached_property + def items(self) -> ItemsResourceWithRawResponse: + return ItemsResourceWithRawResponse(self._instances.items) + + +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 jobs(self) -> AsyncJobsResourceWithRawResponse: + return AsyncJobsResourceWithRawResponse(self._instances.jobs) + + @cached_property + def items(self) -> AsyncItemsResourceWithRawResponse: + return AsyncItemsResourceWithRawResponse(self._instances.items) + + +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 jobs(self) -> JobsResourceWithStreamingResponse: + return JobsResourceWithStreamingResponse(self._instances.jobs) + + @cached_property + def items(self) -> ItemsResourceWithStreamingResponse: + return ItemsResourceWithStreamingResponse(self._instances.items) + + +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 jobs(self) -> AsyncJobsResourceWithStreamingResponse: + return AsyncJobsResourceWithStreamingResponse(self._instances.jobs) + + @cached_property + def items(self) -> AsyncItemsResourceWithStreamingResponse: + return AsyncItemsResourceWithStreamingResponse(self._instances.items) diff --git a/src/cloudflare/resources/aisearch/namespaces/instances/items.py b/src/cloudflare/resources/aisearch/namespaces/instances/items.py new file mode 100644 index 00000000000..1fecc1e6539 --- /dev/null +++ b/src/cloudflare/resources/aisearch/namespaces/instances/items.py @@ -0,0 +1,1364 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Mapping, cast +from typing_extensions import Literal + +import httpx + +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import extract_files, path_template, maybe_transform, deepcopy_minimal, 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 .....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ....._base_client import AsyncPaginator, make_request_options +from .....types.aisearch.namespaces.instances import ( + item_list_params, + item_logs_params, + item_sync_params, + item_chunks_params, + item_upload_params, + item_create_or_update_params, +) +from .....types.aisearch.namespaces.instances.item_get_response import ItemGetResponse +from .....types.aisearch.namespaces.instances.item_list_response import ItemListResponse +from .....types.aisearch.namespaces.instances.item_logs_response import ItemLogsResponse +from .....types.aisearch.namespaces.instances.item_sync_response import ItemSyncResponse +from .....types.aisearch.namespaces.instances.item_chunks_response import ItemChunksResponse +from .....types.aisearch.namespaces.instances.item_delete_response import ItemDeleteResponse +from .....types.aisearch.namespaces.instances.item_upload_response import ItemUploadResponse +from .....types.aisearch.namespaces.instances.item_create_or_update_response import ItemCreateOrUpdateResponse + +__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 | None = None, + name: str, + item_id: str | Omit = omit, + metadata_filter: str | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + sort_by: Literal["status", "modified_at"] | Omit = omit, + source: str | Omit = omit, + status: Literal["queued", "running", "completed", "error", "skipped", "outdated"] | 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]: + """Lists indexed items in an AI Search instance. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + item_id: Filter items by their unique ID. Returns at most one item. + + metadata_filter: + JSON-encoded metadata filter using Vectorize filter syntax. Examples: + {"folder":"reports/"}, + {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}} + + sort_by: Sort order for items. "status" (default) sorts by status priority then + last_seen_at. "modified_at" sorts by file modification time (most recent first), + falling back to created_at. + + source: Filter items by source_id. Use "builtin" for uploaded files, or a source + identifier like "web-crawler:https://example.com". + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items", + account_id=account_id, + name=name, + id=id, + ), + page=SyncV4PagePaginationArray[ItemListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "item_id": item_id, + "metadata_filter": metadata_filter, + "page": page, + "per_page": per_page, + "search": search, + "sort_by": sort_by, + "source": source, + "status": status, + }, + item_list_params.ItemListParams, + ), + ), + model=ItemListResponse, + ) + + def delete( + self, + item_id: str, + *, + account_id: str | None = None, + name: 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, + ) -> ItemDeleteResponse: + """ + Deletes a file from a managed AI Search instance and triggers a reindex. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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._delete( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[ItemDeleteResponse], ResultWrapper[ItemDeleteResponse]), + ) + + def chunks( + self, + item_id: str, + *, + account_id: str | None = None, + name: str, + id: str, + 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, + ) -> ItemChunksResponse: + """ + Lists chunks for a specific item in an AI Search instance, including their text + content. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}/chunks", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + 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, + }, + item_chunks_params.ItemChunksParams, + ), + post_parser=ResultWrapper[ItemChunksResponse]._unwrapper, + ), + cast_to=cast(Type[ItemChunksResponse], ResultWrapper[ItemChunksResponse]), + ) + + def create_or_update( + self, + id: str, + *, + account_id: str | None = None, + name: str, + key: str, + next_action: Literal["INDEX"], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemCreateOrUpdateResponse: + """ + Creates or updates an indexed item in an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + key: Item key / filename. Must not exceed 128 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 + """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._put( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items", + account_id=account_id, + name=name, + id=id, + ), + body=maybe_transform( + { + "key": key, + "next_action": next_action, + }, + item_create_or_update_params.ItemCreateOrUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemCreateOrUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[ItemCreateOrUpdateResponse], ResultWrapper[ItemCreateOrUpdateResponse]), + ) + + def download( + self, + item_id: str, + *, + account_id: str | None = None, + name: 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, + ) -> BinaryAPIResponse: + """ + Downloads the raw file content for a specific item from the managed AI Search + instance storage. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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}") + extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} + return self._get( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}/download", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BinaryAPIResponse, + ) + + def get( + self, + item_id: str, + *, + account_id: str | None = None, + name: 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: + """ + Retrieves a specific indexed item from an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}", + account_id=account_id, + name=name, + id=id, + item_id=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]), + ) + + def logs( + self, + item_id: str, + *, + account_id: str | None = None, + name: str, + id: str, + cursor: str | Omit = omit, + limit: 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, + ) -> ItemLogsResponse: + """ + Lists processing logs for a specific item in an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}/logs", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "limit": limit, + }, + item_logs_params.ItemLogsParams, + ), + post_parser=ResultWrapper[ItemLogsResponse]._unwrapper, + ), + cast_to=cast(Type[ItemLogsResponse], ResultWrapper[ItemLogsResponse]), + ) + + def sync( + self, + item_id: str, + *, + account_id: str | None = None, + name: str, + id: str, + next_action: Literal["INDEX"], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemSyncResponse: + """Syncs an item to an AI Search instance index. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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._patch( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + body=maybe_transform({"next_action": next_action}, item_sync_params.ItemSyncParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemSyncResponse]._unwrapper, + ), + cast_to=cast(Type[ItemSyncResponse], ResultWrapper[ItemSyncResponse]), + ) + + def upload( + self, + id: str, + *, + account_id: str | None = None, + name: str, + file: item_upload_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, + ) -> ItemUploadResponse: + """ + Uploads a file to a managed AI Search instance via multipart/form-data (max + 4MB). + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + body = deepcopy_minimal(file) + 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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items", + account_id=account_id, + name=name, + id=id, + ), + body=maybe_transform(body, item_upload_params.ItemUploadParams), + files=files, + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemUploadResponse]._unwrapper, + ), + cast_to=cast(Type[ItemUploadResponse], ResultWrapper[ItemUploadResponse]), + ) + + +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 | None = None, + name: str, + item_id: str | Omit = omit, + metadata_filter: str | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + sort_by: Literal["status", "modified_at"] | Omit = omit, + source: str | Omit = omit, + status: Literal["queued", "running", "completed", "error", "skipped", "outdated"] | 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]]: + """Lists indexed items in an AI Search instance. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + item_id: Filter items by their unique ID. Returns at most one item. + + metadata_filter: + JSON-encoded metadata filter using Vectorize filter syntax. Examples: + {"folder":"reports/"}, + {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}} + + sort_by: Sort order for items. "status" (default) sorts by status priority then + last_seen_at. "modified_at" sorts by file modification time (most recent first), + falling back to created_at. + + source: Filter items by source_id. Use "builtin" for uploaded files, or a source + identifier like "web-crawler:https://example.com". + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items", + account_id=account_id, + name=name, + id=id, + ), + page=AsyncV4PagePaginationArray[ItemListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "item_id": item_id, + "metadata_filter": metadata_filter, + "page": page, + "per_page": per_page, + "search": search, + "sort_by": sort_by, + "source": source, + "status": status, + }, + item_list_params.ItemListParams, + ), + ), + model=ItemListResponse, + ) + + async def delete( + self, + item_id: str, + *, + account_id: str | None = None, + name: 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, + ) -> ItemDeleteResponse: + """ + Deletes a file from a managed AI Search instance and triggers a reindex. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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._delete( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[ItemDeleteResponse], ResultWrapper[ItemDeleteResponse]), + ) + + async def chunks( + self, + item_id: str, + *, + account_id: str | None = None, + name: str, + id: str, + 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, + ) -> ItemChunksResponse: + """ + Lists chunks for a specific item in an AI Search instance, including their text + content. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}/chunks", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + 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, + "offset": offset, + }, + item_chunks_params.ItemChunksParams, + ), + post_parser=ResultWrapper[ItemChunksResponse]._unwrapper, + ), + cast_to=cast(Type[ItemChunksResponse], ResultWrapper[ItemChunksResponse]), + ) + + async def create_or_update( + self, + id: str, + *, + account_id: str | None = None, + name: str, + key: str, + next_action: Literal["INDEX"], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemCreateOrUpdateResponse: + """ + Creates or updates an indexed item in an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + key: Item key / filename. Must not exceed 128 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 + """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._put( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items", + account_id=account_id, + name=name, + id=id, + ), + body=await async_maybe_transform( + { + "key": key, + "next_action": next_action, + }, + item_create_or_update_params.ItemCreateOrUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemCreateOrUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[ItemCreateOrUpdateResponse], ResultWrapper[ItemCreateOrUpdateResponse]), + ) + + async def download( + self, + item_id: str, + *, + account_id: str | None = None, + name: 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, + ) -> AsyncBinaryAPIResponse: + """ + Downloads the raw file content for a specific item from the managed AI Search + instance storage. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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}") + extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} + return await self._get( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}/download", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AsyncBinaryAPIResponse, + ) + + async def get( + self, + item_id: str, + *, + account_id: str | None = None, + name: 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: + """ + Retrieves a specific indexed item from an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}", + account_id=account_id, + name=name, + id=id, + item_id=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]), + ) + + async def logs( + self, + item_id: str, + *, + account_id: str | None = None, + name: str, + id: str, + cursor: str | Omit = omit, + limit: 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, + ) -> ItemLogsResponse: + """ + Lists processing logs for a specific item in an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}/logs", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "cursor": cursor, + "limit": limit, + }, + item_logs_params.ItemLogsParams, + ), + post_parser=ResultWrapper[ItemLogsResponse]._unwrapper, + ), + cast_to=cast(Type[ItemLogsResponse], ResultWrapper[ItemLogsResponse]), + ) + + async def sync( + self, + item_id: str, + *, + account_id: str | None = None, + name: str, + id: str, + next_action: Literal["INDEX"], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemSyncResponse: + """Syncs an item to an AI Search instance index. + + Args: + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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._patch( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items/{item_id}", + account_id=account_id, + name=name, + id=id, + item_id=item_id, + ), + body=await async_maybe_transform({"next_action": next_action}, item_sync_params.ItemSyncParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemSyncResponse]._unwrapper, + ), + cast_to=cast(Type[ItemSyncResponse], ResultWrapper[ItemSyncResponse]), + ) + + async def upload( + self, + id: str, + *, + account_id: str | None = None, + name: str, + file: item_upload_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, + ) -> ItemUploadResponse: + """ + Uploads a file to a managed AI Search instance via multipart/form-data (max + 4MB). + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + body = deepcopy_minimal(file) + 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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items", + account_id=account_id, + name=name, + id=id, + ), + body=await async_maybe_transform(body, item_upload_params.ItemUploadParams), + files=files, + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemUploadResponse]._unwrapper, + ), + cast_to=cast(Type[ItemUploadResponse], ResultWrapper[ItemUploadResponse]), + ) + + +class ItemsResourceWithRawResponse: + def __init__(self, items: ItemsResource) -> None: + self._items = items + + self.list = to_raw_response_wrapper( + items.list, + ) + self.delete = to_raw_response_wrapper( + items.delete, + ) + self.chunks = to_raw_response_wrapper( + items.chunks, + ) + self.create_or_update = to_raw_response_wrapper( + items.create_or_update, + ) + self.download = to_custom_raw_response_wrapper( + items.download, + BinaryAPIResponse, + ) + self.get = to_raw_response_wrapper( + items.get, + ) + self.logs = to_raw_response_wrapper( + items.logs, + ) + self.sync = to_raw_response_wrapper( + items.sync, + ) + self.upload = to_raw_response_wrapper( + items.upload, + ) + + +class AsyncItemsResourceWithRawResponse: + def __init__(self, items: AsyncItemsResource) -> None: + self._items = items + + self.list = async_to_raw_response_wrapper( + items.list, + ) + self.delete = async_to_raw_response_wrapper( + items.delete, + ) + self.chunks = async_to_raw_response_wrapper( + items.chunks, + ) + self.create_or_update = async_to_raw_response_wrapper( + items.create_or_update, + ) + self.download = async_to_custom_raw_response_wrapper( + items.download, + AsyncBinaryAPIResponse, + ) + self.get = async_to_raw_response_wrapper( + items.get, + ) + self.logs = async_to_raw_response_wrapper( + items.logs, + ) + self.sync = async_to_raw_response_wrapper( + items.sync, + ) + self.upload = async_to_raw_response_wrapper( + items.upload, + ) + + +class ItemsResourceWithStreamingResponse: + def __init__(self, items: ItemsResource) -> None: + self._items = items + + self.list = to_streamed_response_wrapper( + items.list, + ) + self.delete = to_streamed_response_wrapper( + items.delete, + ) + self.chunks = to_streamed_response_wrapper( + items.chunks, + ) + self.create_or_update = to_streamed_response_wrapper( + items.create_or_update, + ) + self.download = to_custom_streamed_response_wrapper( + items.download, + StreamedBinaryAPIResponse, + ) + self.get = to_streamed_response_wrapper( + items.get, + ) + self.logs = to_streamed_response_wrapper( + items.logs, + ) + self.sync = to_streamed_response_wrapper( + items.sync, + ) + self.upload = to_streamed_response_wrapper( + items.upload, + ) + + +class AsyncItemsResourceWithStreamingResponse: + def __init__(self, items: AsyncItemsResource) -> None: + self._items = items + + self.list = async_to_streamed_response_wrapper( + items.list, + ) + self.delete = async_to_streamed_response_wrapper( + items.delete, + ) + self.chunks = async_to_streamed_response_wrapper( + items.chunks, + ) + self.create_or_update = async_to_streamed_response_wrapper( + items.create_or_update, + ) + self.download = async_to_custom_streamed_response_wrapper( + items.download, + AsyncStreamedBinaryAPIResponse, + ) + self.get = async_to_streamed_response_wrapper( + items.get, + ) + self.logs = async_to_streamed_response_wrapper( + items.logs, + ) + self.sync = async_to_streamed_response_wrapper( + items.sync, + ) + self.upload = async_to_streamed_response_wrapper( + items.upload, + ) diff --git a/src/cloudflare/resources/aisearch/namespaces/instances/jobs.py b/src/cloudflare/resources/aisearch/namespaces/instances/jobs.py new file mode 100644 index 00000000000..a6e4af5bdbf --- /dev/null +++ b/src/cloudflare/resources/aisearch/namespaces/instances/jobs.py @@ -0,0 +1,749 @@ +# 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 path_template, 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.namespaces.instances import ( + job_list_params, + job_logs_params, + job_create_params, + job_update_params, +) +from .....types.aisearch.namespaces.instances.job_get_response import JobGetResponse +from .....types.aisearch.namespaces.instances.job_list_response import JobListResponse +from .....types.aisearch.namespaces.instances.job_logs_response import JobLogsResponse +from .....types.aisearch.namespaces.instances.job_create_response import JobCreateResponse +from .....types.aisearch.namespaces.instances.job_update_response import JobUpdateResponse + +__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 | None = None, + name: str, + description: 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, + ) -> JobCreateResponse: + """ + Creates a new indexing job for an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs", + account_id=account_id, + name=name, + id=id, + ), + body=maybe_transform({"description": description}, job_create_params.JobCreateParams), + 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 update( + self, + job_id: str, + *, + account_id: str | None = None, + name: str, + id: str, + action: Literal["cancel"], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> JobUpdateResponse: + """ + Updates the status of an AI Search indexing job. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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._patch( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}", + account_id=account_id, + name=name, + id=id, + job_id=job_id, + ), + body=maybe_transform({"action": action}, job_update_params.JobUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[JobUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[JobUpdateResponse], ResultWrapper[JobUpdateResponse]), + ) + + def list( + self, + id: str, + *, + account_id: str | None = None, + name: 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]: + """ + Lists indexing jobs for an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs", + account_id=account_id, + name=name, + id=id, + ), + 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 | None = None, + name: 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: + """ + Retrieves details for a specific AI Search indexing job. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}", + account_id=account_id, + name=name, + id=id, + job_id=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 | None = None, + name: 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: + """ + Lists log entries for an AI Search indexing job. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}/logs", + account_id=account_id, + name=name, + id=id, + job_id=job_id, + ), + 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 | None = None, + name: str, + description: 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, + ) -> JobCreateResponse: + """ + Creates a new indexing job for an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs", + account_id=account_id, + name=name, + id=id, + ), + body=await async_maybe_transform({"description": description}, job_create_params.JobCreateParams), + 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]), + ) + + async def update( + self, + job_id: str, + *, + account_id: str | None = None, + name: str, + id: str, + action: Literal["cancel"], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> JobUpdateResponse: + """ + Updates the status of an AI Search indexing job. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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._patch( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}", + account_id=account_id, + name=name, + id=id, + job_id=job_id, + ), + body=await async_maybe_transform({"action": action}, job_update_params.JobUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[JobUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[JobUpdateResponse], ResultWrapper[JobUpdateResponse]), + ) + + def list( + self, + id: str, + *, + account_id: str | None = None, + name: 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]]: + """ + Lists indexing jobs for an AI Search instance. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs", + account_id=account_id, + name=name, + id=id, + ), + 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 | None = None, + name: 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: + """ + Retrieves details for a specific AI Search indexing job. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}", + account_id=account_id, + name=name, + id=id, + job_id=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 | None = None, + name: 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: + """ + Lists log entries for an AI Search indexing job. + + Args: + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!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( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs/{job_id}/logs", + account_id=account_id, + name=name, + id=id, + job_id=job_id, + ), + 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.update = to_raw_response_wrapper( + jobs.update, + ) + 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.update = async_to_raw_response_wrapper( + jobs.update, + ) + 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.update = to_streamed_response_wrapper( + jobs.update, + ) + 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.update = async_to_streamed_response_wrapper( + jobs.update, + ) + 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/namespaces/namespaces.py b/src/cloudflare/resources/aisearch/namespaces/namespaces.py new file mode 100644 index 00000000000..152664c1ecc --- /dev/null +++ b/src/cloudflare/resources/aisearch/namespaces/namespaces.py @@ -0,0 +1,987 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, Optional, cast +from typing_extensions import Literal + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import path_template, 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 ( + namespace_list_params, + namespace_create_params, + namespace_search_params, + namespace_update_params, + namespace_chat_completions_params, +) +from .instances.instances import ( + InstancesResource, + AsyncInstancesResource, + InstancesResourceWithRawResponse, + AsyncInstancesResourceWithRawResponse, + InstancesResourceWithStreamingResponse, + AsyncInstancesResourceWithStreamingResponse, +) +from ....types.aisearch.namespace_list_response import NamespaceListResponse +from ....types.aisearch.namespace_read_response import NamespaceReadResponse +from ....types.aisearch.namespace_create_response import NamespaceCreateResponse +from ....types.aisearch.namespace_search_response import NamespaceSearchResponse +from ....types.aisearch.namespace_update_response import NamespaceUpdateResponse +from ....types.aisearch.namespace_chat_completions_response import NamespaceChatCompletionsResponse + +__all__ = ["NamespacesResource", "AsyncNamespacesResource"] + + +class NamespacesResource(SyncAPIResource): + @cached_property + def instances(self) -> InstancesResource: + return InstancesResource(self._client) + + @cached_property + def with_raw_response(self) -> NamespacesResourceWithRawResponse: + """ + 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 NamespacesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> NamespacesResourceWithStreamingResponse: + """ + 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 NamespacesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str | None = None, + name: str, + description: 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, + ) -> NamespaceCreateResponse: + """ + Create a new namespace. + + Args: + description: Optional description for the namespace. Max 256 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 + """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + path_template("/accounts/{account_id}/ai-search/namespaces", account_id=account_id), + body=maybe_transform( + { + "name": name, + "description": description, + }, + namespace_create_params.NamespaceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[NamespaceCreateResponse]._unwrapper, + ), + cast_to=cast(Type[NamespaceCreateResponse], ResultWrapper[NamespaceCreateResponse]), + ) + + def update( + self, + name: str, + *, + account_id: str | None = None, + description: 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, + ) -> NamespaceUpdateResponse: + """Update namespace. + + Args: + description: Optional description for the namespace. + + Max 256 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 + """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return self._put( + path_template("/accounts/{account_id}/ai-search/namespaces/{name}", account_id=account_id, name=name), + body=maybe_transform({"description": description}, namespace_update_params.NamespaceUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[NamespaceUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[NamespaceUpdateResponse], ResultWrapper[NamespaceUpdateResponse]), + ) + + def list( + self, + *, + account_id: str | None = None, + 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[NamespaceListResponse]: + """ + List namespaces. + + Args: + page: Page number (1-indexed). + + per_page: Number of results per page. + + search: Filter namespaces whose name or description contains this string + (case-insensitive). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + 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( + path_template("/accounts/{account_id}/ai-search/namespaces", account_id=account_id), + page=SyncV4PagePaginationArray[NamespaceListResponse], + 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, + }, + namespace_list_params.NamespaceListParams, + ), + ), + model=NamespaceListResponse, + ) + + def delete( + self, + name: str, + *, + account_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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: + """ + Delete namespace. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return self._delete( + path_template("/accounts/{account_id}/ai-search/namespaces/{name}", account_id=account_id, name=name), + 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 chat_completions( + self, + name: str, + *, + account_id: str | None = None, + aisearch_options: namespace_chat_completions_params.AISearchOptions, + messages: Iterable[namespace_chat_completions_params.Message], + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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, + ) -> NamespaceChatCompletionsResponse: + """ + Performs a chat completion request against multiple AI Search instances in + parallel, merging retrieved content as context for generating a response. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/chat/completions", account_id=account_id, name=name + ), + body=maybe_transform( + { + "aisearch_options": aisearch_options, + "messages": messages, + "model": model, + "stream": stream, + }, + namespace_chat_completions_params.NamespaceChatCompletionsParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NamespaceChatCompletionsResponse, + ) + + def read( + self, + name: str, + *, + account_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> NamespaceReadResponse: + """ + Read namespace. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return self._get( + path_template("/accounts/{account_id}/ai-search/namespaces/{name}", account_id=account_id, name=name), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[NamespaceReadResponse]._unwrapper, + ), + cast_to=cast(Type[NamespaceReadResponse], ResultWrapper[NamespaceReadResponse]), + ) + + def search( + self, + name: str, + *, + account_id: str | None = None, + aisearch_options: namespace_search_params.AISearchOptions, + messages: Iterable[namespace_search_params.Message] | Omit = omit, + query: 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, + ) -> NamespaceSearchResponse: + """Multi-Instance Search + + Args: + query: A simple text query string. + + Alternative to 'messages' — provide either this or + 'messages', not both. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/search", account_id=account_id, name=name + ), + body=maybe_transform( + { + "aisearch_options": aisearch_options, + "messages": messages, + "query": query, + }, + namespace_search_params.NamespaceSearchParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[NamespaceSearchResponse]._unwrapper, + ), + cast_to=cast(Type[NamespaceSearchResponse], ResultWrapper[NamespaceSearchResponse]), + ) + + +class AsyncNamespacesResource(AsyncAPIResource): + @cached_property + def instances(self) -> AsyncInstancesResource: + return AsyncInstancesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncNamespacesResourceWithRawResponse: + """ + 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 AsyncNamespacesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncNamespacesResourceWithStreamingResponse: + """ + 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 AsyncNamespacesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str | None = None, + name: str, + description: 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, + ) -> NamespaceCreateResponse: + """ + Create a new namespace. + + Args: + description: Optional description for the namespace. Max 256 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 + """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + path_template("/accounts/{account_id}/ai-search/namespaces", account_id=account_id), + body=await async_maybe_transform( + { + "name": name, + "description": description, + }, + namespace_create_params.NamespaceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[NamespaceCreateResponse]._unwrapper, + ), + cast_to=cast(Type[NamespaceCreateResponse], ResultWrapper[NamespaceCreateResponse]), + ) + + async def update( + self, + name: str, + *, + account_id: str | None = None, + description: 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, + ) -> NamespaceUpdateResponse: + """Update namespace. + + Args: + description: Optional description for the namespace. + + Max 256 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 + """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return await self._put( + path_template("/accounts/{account_id}/ai-search/namespaces/{name}", account_id=account_id, name=name), + body=await async_maybe_transform( + {"description": description}, namespace_update_params.NamespaceUpdateParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[NamespaceUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[NamespaceUpdateResponse], ResultWrapper[NamespaceUpdateResponse]), + ) + + def list( + self, + *, + account_id: str | None = None, + 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[NamespaceListResponse, AsyncV4PagePaginationArray[NamespaceListResponse]]: + """ + List namespaces. + + Args: + page: Page number (1-indexed). + + per_page: Number of results per page. + + search: Filter namespaces whose name or description contains this string + (case-insensitive). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + 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( + path_template("/accounts/{account_id}/ai-search/namespaces", account_id=account_id), + page=AsyncV4PagePaginationArray[NamespaceListResponse], + 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, + }, + namespace_list_params.NamespaceListParams, + ), + ), + model=NamespaceListResponse, + ) + + async def delete( + self, + name: str, + *, + account_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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: + """ + Delete namespace. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return await self._delete( + path_template("/accounts/{account_id}/ai-search/namespaces/{name}", account_id=account_id, name=name), + 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 chat_completions( + self, + name: str, + *, + account_id: str | None = None, + aisearch_options: namespace_chat_completions_params.AISearchOptions, + messages: Iterable[namespace_chat_completions_params.Message], + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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, + ) -> NamespaceChatCompletionsResponse: + """ + Performs a chat completion request against multiple AI Search instances in + parallel, merging retrieved content as context for generating a response. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return await self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/chat/completions", account_id=account_id, name=name + ), + body=await async_maybe_transform( + { + "aisearch_options": aisearch_options, + "messages": messages, + "model": model, + "stream": stream, + }, + namespace_chat_completions_params.NamespaceChatCompletionsParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NamespaceChatCompletionsResponse, + ) + + async def read( + self, + name: str, + *, + account_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> NamespaceReadResponse: + """ + Read namespace. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return await self._get( + path_template("/accounts/{account_id}/ai-search/namespaces/{name}", account_id=account_id, name=name), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[NamespaceReadResponse]._unwrapper, + ), + cast_to=cast(Type[NamespaceReadResponse], ResultWrapper[NamespaceReadResponse]), + ) + + async def search( + self, + name: str, + *, + account_id: str | None = None, + aisearch_options: namespace_search_params.AISearchOptions, + messages: Iterable[namespace_search_params.Message] | Omit = omit, + query: 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, + ) -> NamespaceSearchResponse: + """Multi-Instance Search + + Args: + query: A simple text query string. + + Alternative to 'messages' — provide either this or + 'messages', not both. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not name: + raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + return await self._post( + path_template( + "/accounts/{account_id}/ai-search/namespaces/{name}/search", account_id=account_id, name=name + ), + body=await async_maybe_transform( + { + "aisearch_options": aisearch_options, + "messages": messages, + "query": query, + }, + namespace_search_params.NamespaceSearchParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[NamespaceSearchResponse]._unwrapper, + ), + cast_to=cast(Type[NamespaceSearchResponse], ResultWrapper[NamespaceSearchResponse]), + ) + + +class NamespacesResourceWithRawResponse: + def __init__(self, namespaces: NamespacesResource) -> None: + self._namespaces = namespaces + + self.create = to_raw_response_wrapper( + namespaces.create, + ) + self.update = to_raw_response_wrapper( + namespaces.update, + ) + self.list = to_raw_response_wrapper( + namespaces.list, + ) + self.delete = to_raw_response_wrapper( + namespaces.delete, + ) + self.chat_completions = to_raw_response_wrapper( + namespaces.chat_completions, + ) + self.read = to_raw_response_wrapper( + namespaces.read, + ) + self.search = to_raw_response_wrapper( + namespaces.search, + ) + + @cached_property + def instances(self) -> InstancesResourceWithRawResponse: + return InstancesResourceWithRawResponse(self._namespaces.instances) + + +class AsyncNamespacesResourceWithRawResponse: + def __init__(self, namespaces: AsyncNamespacesResource) -> None: + self._namespaces = namespaces + + self.create = async_to_raw_response_wrapper( + namespaces.create, + ) + self.update = async_to_raw_response_wrapper( + namespaces.update, + ) + self.list = async_to_raw_response_wrapper( + namespaces.list, + ) + self.delete = async_to_raw_response_wrapper( + namespaces.delete, + ) + self.chat_completions = async_to_raw_response_wrapper( + namespaces.chat_completions, + ) + self.read = async_to_raw_response_wrapper( + namespaces.read, + ) + self.search = async_to_raw_response_wrapper( + namespaces.search, + ) + + @cached_property + def instances(self) -> AsyncInstancesResourceWithRawResponse: + return AsyncInstancesResourceWithRawResponse(self._namespaces.instances) + + +class NamespacesResourceWithStreamingResponse: + def __init__(self, namespaces: NamespacesResource) -> None: + self._namespaces = namespaces + + self.create = to_streamed_response_wrapper( + namespaces.create, + ) + self.update = to_streamed_response_wrapper( + namespaces.update, + ) + self.list = to_streamed_response_wrapper( + namespaces.list, + ) + self.delete = to_streamed_response_wrapper( + namespaces.delete, + ) + self.chat_completions = to_streamed_response_wrapper( + namespaces.chat_completions, + ) + self.read = to_streamed_response_wrapper( + namespaces.read, + ) + self.search = to_streamed_response_wrapper( + namespaces.search, + ) + + @cached_property + def instances(self) -> InstancesResourceWithStreamingResponse: + return InstancesResourceWithStreamingResponse(self._namespaces.instances) + + +class AsyncNamespacesResourceWithStreamingResponse: + def __init__(self, namespaces: AsyncNamespacesResource) -> None: + self._namespaces = namespaces + + self.create = async_to_streamed_response_wrapper( + namespaces.create, + ) + self.update = async_to_streamed_response_wrapper( + namespaces.update, + ) + self.list = async_to_streamed_response_wrapper( + namespaces.list, + ) + self.delete = async_to_streamed_response_wrapper( + namespaces.delete, + ) + self.chat_completions = async_to_streamed_response_wrapper( + namespaces.chat_completions, + ) + self.read = async_to_streamed_response_wrapper( + namespaces.read, + ) + self.search = async_to_streamed_response_wrapper( + namespaces.search, + ) + + @cached_property + def instances(self) -> AsyncInstancesResourceWithStreamingResponse: + return AsyncInstancesResourceWithStreamingResponse(self._namespaces.instances) diff --git a/src/cloudflare/resources/aisearch/tokens.py b/src/cloudflare/resources/aisearch/tokens.py index 94654a58c85..d0e62908a9e 100644 --- a/src/cloudflare/resources/aisearch/tokens.py +++ b/src/cloudflare/resources/aisearch/tokens.py @@ -3,12 +3,11 @@ 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 ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -24,7 +23,6 @@ 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"] @@ -53,10 +51,11 @@ def with_streaming_response(self) -> TokensResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, cf_api_id: str, cf_api_key: str, name: str, + legacy: 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, @@ -65,7 +64,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TokenCreateResponse: """ - Create a new tokens. + Create a new token. Args: extra_headers: Send extra headers @@ -76,15 +75,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/tokens", account_id=account_id), body=maybe_transform( { "cf_api_id": cf_api_id, "cf_api_key": cf_api_key, "name": name, + "legacy": legacy, }, token_create_params.TokenCreateParams, ), @@ -102,10 +104,11 @@ def update( self, id: str, *, - account_id: str, + account_id: str | None = None, cf_api_id: str, cf_api_key: str, name: str, + legacy: 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, @@ -114,7 +117,7 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TokenUpdateResponse: """ - Update tokens. + Update token. Args: extra_headers: Send extra headers @@ -125,17 +128,20 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/tokens/{id}", account_id=account_id, id=id), body=maybe_transform( { "cf_api_id": cf_api_id, "cf_api_key": cf_api_key, "name": name, + "legacy": legacy, }, token_update_params.TokenUpdateParams, ), @@ -152,11 +158,10 @@ def update( def list( self, *, - account_id: str, - order_by: Literal["created_at"] | Omit = omit, - order_by_direction: Literal["asc", "desc"] | Omit = omit, + account_id: str | None = None, 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, @@ -168,9 +173,11 @@ def list( List tokens. Args: - order_by: Order By Column Name + page: Page number (1-indexed). - order_by_direction: Order By Direction + per_page: Number of results per page. + + search: Filter tokens whose name contains this string (case-insensitive). extra_headers: Send extra headers @@ -180,10 +187,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/tokens", account_id=account_id), page=SyncV4PagePaginationArray[TokenListResponse], options=make_request_options( extra_headers=extra_headers, @@ -192,10 +201,9 @@ def list( timeout=timeout, query=maybe_transform( { - "order_by": order_by, - "order_by_direction": order_by_direction, "page": page, "per_page": per_page, + "search": search, }, token_list_params.TokenListParams, ), @@ -207,16 +215,16 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this 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: + ) -> object: """ - Delete tokens. + Delete token. Args: extra_headers: Send extra headers @@ -227,27 +235,29 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/tokens/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TokenDeleteResponse]._unwrapper, + post_parser=ResultWrapper[object]._unwrapper, ), - cast_to=cast(Type[TokenDeleteResponse], ResultWrapper[TokenDeleteResponse]), + cast_to=cast(Type[object], ResultWrapper[object]), ) def read( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -256,7 +266,7 @@ def read( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TokenReadResponse: """ - Read tokens. + Read token. Args: extra_headers: Send extra headers @@ -267,12 +277,14 @@ def read( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/tokens/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -307,10 +319,11 @@ def with_streaming_response(self) -> AsyncTokensResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, cf_api_id: str, cf_api_key: str, name: str, + legacy: 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, @@ -319,7 +332,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TokenCreateResponse: """ - Create a new tokens. + Create a new token. Args: extra_headers: Send extra headers @@ -330,15 +343,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/tokens", account_id=account_id), body=await async_maybe_transform( { "cf_api_id": cf_api_id, "cf_api_key": cf_api_key, "name": name, + "legacy": legacy, }, token_create_params.TokenCreateParams, ), @@ -356,10 +372,11 @@ async def update( self, id: str, *, - account_id: str, + account_id: str | None = None, cf_api_id: str, cf_api_key: str, name: str, + legacy: 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, @@ -368,7 +385,7 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TokenUpdateResponse: """ - Update tokens. + Update token. Args: extra_headers: Send extra headers @@ -379,17 +396,20 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/tokens/{id}", account_id=account_id, id=id), body=await async_maybe_transform( { "cf_api_id": cf_api_id, "cf_api_key": cf_api_key, "name": name, + "legacy": legacy, }, token_update_params.TokenUpdateParams, ), @@ -406,11 +426,10 @@ async def update( def list( self, *, - account_id: str, - order_by: Literal["created_at"] | Omit = omit, - order_by_direction: Literal["asc", "desc"] | Omit = omit, + account_id: str | None = None, 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, @@ -422,9 +441,11 @@ def list( List tokens. Args: - order_by: Order By Column Name + page: Page number (1-indexed). + + per_page: Number of results per page. - order_by_direction: Order By Direction + search: Filter tokens whose name contains this string (case-insensitive). extra_headers: Send extra headers @@ -434,10 +455,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/ai-search/tokens", account_id=account_id), page=AsyncV4PagePaginationArray[TokenListResponse], options=make_request_options( extra_headers=extra_headers, @@ -446,10 +469,9 @@ def list( timeout=timeout, query=maybe_transform( { - "order_by": order_by, - "order_by_direction": order_by_direction, "page": page, "per_page": per_page, + "search": search, }, token_list_params.TokenListParams, ), @@ -461,16 +483,16 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this 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: + ) -> object: """ - Delete tokens. + Delete token. Args: extra_headers: Send extra headers @@ -481,27 +503,29 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/tokens/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TokenDeleteResponse]._unwrapper, + post_parser=ResultWrapper[object]._unwrapper, ), - cast_to=cast(Type[TokenDeleteResponse], ResultWrapper[TokenDeleteResponse]), + cast_to=cast(Type[object], ResultWrapper[object]), ) async def read( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -510,7 +534,7 @@ async def read( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TokenReadResponse: """ - Read tokens. + Read token. Args: extra_headers: Send extra headers @@ -521,12 +545,14 @@ async def read( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template("/accounts/{account_id}/ai-search/tokens/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/alerting/api.md b/src/cloudflare/resources/alerting/api.md new file mode 100644 index 00000000000..6c8ac0c1b0e --- /dev/null +++ b/src/cloudflare/resources/alerting/api.md @@ -0,0 +1,125 @@ +# Alerting + +## AvailableAlerts + +Types: + +```python +from cloudflare.types.alerting import AvailableAlertListResponse +``` + +Methods: + +- client.alerting.available_alerts.list(\*, account_id) -> Optional[AvailableAlertListResponse] + +## Destinations + +### Eligible + +Types: + +```python +from cloudflare.types.alerting.destinations import EligibleGetResponse +``` + +Methods: + +- client.alerting.destinations.eligible.get(\*, account_id) -> Optional[EligibleGetResponse] + +### Pagerduty + +Types: + +```python +from cloudflare.types.alerting.destinations import ( + Pagerduty, + PagerdutyCreateResponse, + PagerdutyDeleteResponse, + PagerdutyLinkResponse, +) +``` + +Methods: + +- client.alerting.destinations.pagerduty.create(\*, account_id) -> Optional[PagerdutyCreateResponse] +- client.alerting.destinations.pagerduty.delete(\*, account_id) -> PagerdutyDeleteResponse +- client.alerting.destinations.pagerduty.get(\*, account_id) -> SyncSinglePage[Pagerduty] +- client.alerting.destinations.pagerduty.link(token_id, \*, account_id) -> Optional[PagerdutyLinkResponse] + +### Webhooks + +Types: + +```python +from cloudflare.types.alerting.destinations import ( + Webhooks, + WebhookCreateResponse, + WebhookUpdateResponse, + WebhookDeleteResponse, +) +``` + +Methods: + +- 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[Webhooks] + +## History + +Types: + +```python +from cloudflare.types.alerting import History +``` + +Methods: + +- client.alerting.history.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[History] + +## Policies + +Types: + +```python +from cloudflare.types.alerting import ( + Mechanism, + Policy, + PolicyFilter, + PolicyCreateResponse, + PolicyUpdateResponse, + PolicyDeleteResponse, +) +``` + +Methods: + +- 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[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] diff --git a/src/cloudflare/resources/alerting/available_alerts.py b/src/cloudflare/resources/alerting/available_alerts.py index 1286d27f1e6..d22e4276984 100644 --- a/src/cloudflare/resources/alerting/available_alerts.py +++ b/src/cloudflare/resources/alerting/available_alerts.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> AvailableAlertsResourceWithStreamingRespons def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/alerting/v3/available_alerts", + path_template("/accounts/{account_id}/alerting/v3/available_alerts", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -105,7 +108,7 @@ def with_streaming_response(self) -> AsyncAvailableAlertsResourceWithStreamingRe async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,10 +130,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/alerting/v3/available_alerts", + path_template("/accounts/{account_id}/alerting/v3/available_alerts", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/alerting/destinations/eligible.py b/src/cloudflare/resources/alerting/destinations/eligible.py index 76a61c05f51..e558be8c41b 100644 --- a/src/cloudflare/resources/alerting/destinations/eligible.py +++ b/src/cloudflare/resources/alerting/destinations/eligible.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> EligibleResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/alerting/v3/destinations/eligible", + path_template("/accounts/{account_id}/alerting/v3/destinations/eligible", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -105,7 +108,7 @@ def with_streaming_response(self) -> AsyncEligibleResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,10 +130,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/alerting/v3/destinations/eligible", + path_template("/accounts/{account_id}/alerting/v3/destinations/eligible", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/alerting/destinations/pagerduty.py b/src/cloudflare/resources/alerting/destinations/pagerduty.py index 223dfead7a8..5b3f7ee970d 100644 --- a/src/cloudflare/resources/alerting/destinations/pagerduty.py +++ b/src/cloudflare/resources/alerting/destinations/pagerduty.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +50,7 @@ def with_streaming_response(self) -> PagerdutyResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -71,10 +72,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/destinations/pagerduty/connect", + path_template("/accounts/{account_id}/alerting/v3/destinations/pagerduty/connect", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -88,7 +91,7 @@ def create( def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -110,10 +113,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/alerting/v3/destinations/pagerduty", + path_template("/accounts/{account_id}/alerting/v3/destinations/pagerduty", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -123,7 +128,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -145,10 +150,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/destinations/pagerduty", + path_template("/accounts/{account_id}/alerting/v3/destinations/pagerduty", account_id=account_id), page=SyncSinglePage[Pagerduty], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -160,7 +167,7 @@ def link( self, token_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -184,12 +191,18 @@ def link( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/alerting/v3/destinations/pagerduty/connect/{token_id}", + path_template( + "/accounts/{account_id}/alerting/v3/destinations/pagerduty/connect/{token_id}", + account_id=account_id, + token_id=token_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -224,7 +237,7 @@ def with_streaming_response(self) -> AsyncPagerdutyResourceWithStreamingResponse async def create( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -246,10 +259,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/destinations/pagerduty/connect", + path_template("/accounts/{account_id}/alerting/v3/destinations/pagerduty/connect", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -263,7 +278,7 @@ async def create( async def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -285,10 +300,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/alerting/v3/destinations/pagerduty", + path_template("/accounts/{account_id}/alerting/v3/destinations/pagerduty", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -298,7 +315,7 @@ async def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -320,10 +337,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/destinations/pagerduty", + path_template("/accounts/{account_id}/alerting/v3/destinations/pagerduty", account_id=account_id), page=AsyncSinglePage[Pagerduty], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -335,7 +354,7 @@ async def link( self, token_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -359,12 +378,18 @@ async def link( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/alerting/v3/destinations/pagerduty/connect/{token_id}", + path_template( + "/accounts/{account_id}/alerting/v3/destinations/pagerduty/connect/{token_id}", + account_id=account_id, + token_id=token_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/alerting/destinations/webhooks.py b/src/cloudflare/resources/alerting/destinations/webhooks.py index 9a83705a4fd..e17a3c8f40c 100644 --- a/src/cloudflare/resources/alerting/destinations/webhooks.py +++ b/src/cloudflare/resources/alerting/destinations/webhooks.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> WebhooksResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, url: str, secret: str | Omit = omit, @@ -85,10 +85,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/destinations/webhooks", + path_template("/accounts/{account_id}/alerting/v3/destinations/webhooks", account_id=account_id), body=maybe_transform( { "name": name, @@ -111,7 +113,7 @@ def update( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, name: str, url: str, secret: str | Omit = omit, @@ -147,12 +149,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return self._put( - f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + account_id=account_id, + webhook_id=webhook_id, + ), body=maybe_transform( { "name": name, @@ -174,7 +182,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -196,10 +204,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/destinations/webhooks", + path_template("/accounts/{account_id}/alerting/v3/destinations/webhooks", account_id=account_id), page=SyncSinglePage[Webhooks], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -211,7 +221,7 @@ def delete( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -235,12 +245,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return self._delete( - f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + account_id=account_id, + webhook_id=webhook_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -251,7 +267,7 @@ def get( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -275,12 +291,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return self._get( - f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + account_id=account_id, + webhook_id=webhook_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -315,7 +337,7 @@ def with_streaming_response(self) -> AsyncWebhooksResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, url: str, secret: str | Omit = omit, @@ -349,10 +371,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/destinations/webhooks", + path_template("/accounts/{account_id}/alerting/v3/destinations/webhooks", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -375,7 +399,7 @@ async def update( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, name: str, url: str, secret: str | Omit = omit, @@ -411,12 +435,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return await self._put( - f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + account_id=account_id, + webhook_id=webhook_id, + ), body=await async_maybe_transform( { "name": name, @@ -438,7 +468,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -460,10 +490,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/destinations/webhooks", + path_template("/accounts/{account_id}/alerting/v3/destinations/webhooks", account_id=account_id), page=AsyncSinglePage[Webhooks], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -475,7 +507,7 @@ async def delete( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -499,12 +531,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return await self._delete( - f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + account_id=account_id, + webhook_id=webhook_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -515,7 +553,7 @@ async def get( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -539,12 +577,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return await self._get( - f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + account_id=account_id, + webhook_id=webhook_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/alerting/history.py b/src/cloudflare/resources/alerting/history.py index 8eee416174e..a62916b993d 100644 --- a/src/cloudflare/resources/alerting/history.py +++ b/src/cloudflare/resources/alerting/history.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> HistoryResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, before: Union[str, datetime] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -87,10 +87,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/history", + path_template("/accounts/{account_id}/alerting/v3/history", account_id=account_id), page=SyncV4PagePaginationArray[History], options=make_request_options( extra_headers=extra_headers, @@ -134,7 +136,7 @@ def with_streaming_response(self) -> AsyncHistoryResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, before: Union[str, datetime] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -173,10 +175,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/history", + path_template("/accounts/{account_id}/alerting/v3/history", account_id=account_id), page=AsyncV4PagePaginationArray[History], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/alerting/policies.py b/src/cloudflare/resources/alerting/policies.py index 64b96549788..28e50d93869 100644 --- a/src/cloudflare/resources/alerting/policies.py +++ b/src/cloudflare/resources/alerting/policies.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -54,7 +54,7 @@ def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, alert_type: Literal[ "abuse_report_alert", "access_custom_certificate_expiration_type", @@ -173,10 +173,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/policies", + path_template("/accounts/{account_id}/alerting/v3/policies", account_id=account_id), body=maybe_transform( { "alert_type": alert_type, @@ -203,7 +205,7 @@ def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, alert_interval: str | Omit = omit, alert_type: Literal[ "abuse_report_alert", @@ -325,12 +327,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._put( - f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", + path_template( + "/accounts/{account_id}/alerting/v3/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), body=maybe_transform( { "alert_interval": alert_interval, @@ -356,7 +362,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -378,10 +384,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/policies", + path_template("/accounts/{account_id}/alerting/v3/policies", account_id=account_id), page=SyncSinglePage[Policy], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -393,7 +401,7 @@ def delete( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -417,12 +425,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._delete( - f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", + path_template( + "/accounts/{account_id}/alerting/v3/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -433,7 +445,7 @@ def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -457,12 +469,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get( - f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", + path_template( + "/accounts/{account_id}/alerting/v3/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -497,7 +513,7 @@ def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, alert_type: Literal[ "abuse_report_alert", "access_custom_certificate_expiration_type", @@ -616,10 +632,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/policies", + path_template("/accounts/{account_id}/alerting/v3/policies", account_id=account_id), body=await async_maybe_transform( { "alert_type": alert_type, @@ -646,7 +664,7 @@ async def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, alert_interval: str | Omit = omit, alert_type: Literal[ "abuse_report_alert", @@ -768,12 +786,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._put( - f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", + path_template( + "/accounts/{account_id}/alerting/v3/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), body=await async_maybe_transform( { "alert_interval": alert_interval, @@ -799,7 +821,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -821,10 +843,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/policies", + path_template("/accounts/{account_id}/alerting/v3/policies", account_id=account_id), page=AsyncSinglePage[Policy], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -836,7 +860,7 @@ async def delete( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -860,12 +884,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._delete( - f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", + path_template( + "/accounts/{account_id}/alerting/v3/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -876,7 +904,7 @@ async def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -900,12 +928,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._get( - f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", + path_template( + "/accounts/{account_id}/alerting/v3/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/alerting/silences.py b/src/cloudflare/resources/alerting/silences.py index a024012b058..34f364ab0a4 100644 --- a/src/cloudflare/resources/alerting/silences.py +++ b/src/cloudflare/resources/alerting/silences.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> SilencesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -75,10 +75,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/alerting/v3/silences", account_id=account_id), 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 @@ -89,7 +91,7 @@ def create( def update( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -112,10 +114,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/alerting/v3/silences", account_id=account_id), page=SyncSinglePage[SilenceUpdateResponse], body=maybe_transform(body, Iterable[silence_update_params.Body]), options=make_request_options( @@ -128,7 +132,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -150,10 +154,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/alerting/v3/silences", account_id=account_id), page=SyncSinglePage[SilenceListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -165,7 +171,7 @@ def delete( self, silence_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -189,12 +195,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/alerting/v3/silences/{silence_id}", account_id=account_id, silence_id=silence_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -205,7 +215,7 @@ def get( self, silence_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -229,12 +239,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/alerting/v3/silences/{silence_id}", account_id=account_id, silence_id=silence_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -269,7 +283,7 @@ def with_streaming_response(self) -> AsyncSilencesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -292,10 +306,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/alerting/v3/silences", account_id=account_id), 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 @@ -306,7 +322,7 @@ async def create( def update( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -329,10 +345,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/alerting/v3/silences", account_id=account_id), page=AsyncSinglePage[SilenceUpdateResponse], body=maybe_transform(body, Iterable[silence_update_params.Body]), options=make_request_options( @@ -345,7 +363,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -367,10 +385,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/alerting/v3/silences", account_id=account_id), page=AsyncSinglePage[SilenceListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -382,7 +402,7 @@ async def delete( self, silence_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -406,12 +426,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/alerting/v3/silences/{silence_id}", account_id=account_id, silence_id=silence_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -422,7 +446,7 @@ async def get( self, silence_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -446,12 +470,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/alerting/v3/silences/{silence_id}", account_id=account_id, silence_id=silence_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/api_gateway/api.md b/src/cloudflare/resources/api_gateway/api.md new file mode 100644 index 00000000000..6634bf894b0 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/api.md @@ -0,0 +1,270 @@ +# APIGateway + +## Configurations + +Types: + +```python +from cloudflare.types.api_gateway import Configuration +``` + +Methods: + +- client.api_gateway.configurations.update(\*, zone_id, \*\*params) -> Configuration +- client.api_gateway.configurations.get(\*, zone_id, \*\*params) -> Configuration + +## Discovery + +Types: + +```python +from cloudflare.types.api_gateway import DiscoveryOperation, DiscoveryGetResponse +``` + +Methods: + +- client.api_gateway.discovery.get(\*, zone_id) -> DiscoveryGetResponse + +### Operations + +Types: + +```python +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 + +## Labels + +Types: + +```python +from cloudflare.types.api_gateway import LabelListResponse +``` + +Methods: + +- client.api_gateway.labels.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[LabelListResponse] + +### User + +Types: + +```python +from cloudflare.types.api_gateway.labels import ( + UserUpdateResponse, + UserDeleteResponse, + UserBulkCreateResponse, + UserBulkDeleteResponse, + UserEditResponse, + UserGetResponse, +) +``` + +Methods: + +- client.api_gateway.labels.user.update(name, \*, zone_id, \*\*params) -> UserUpdateResponse +- client.api_gateway.labels.user.delete(name, \*, zone_id) -> UserDeleteResponse +- client.api_gateway.labels.user.bulk_create(\*, zone_id, \*\*params) -> SyncSinglePage[UserBulkCreateResponse] +- client.api_gateway.labels.user.bulk_delete(\*, zone_id) -> SyncSinglePage[UserBulkDeleteResponse] +- client.api_gateway.labels.user.edit(name, \*, zone_id, \*\*params) -> UserEditResponse +- client.api_gateway.labels.user.get(name, \*, zone_id, \*\*params) -> UserGetResponse + +#### Resources + +##### Operation + +Types: + +```python +from cloudflare.types.api_gateway.labels.user.resources import OperationUpdateResponse +``` + +Methods: + +- client.api_gateway.labels.user.resources.operation.update(name, \*, zone_id, \*\*params) -> OperationUpdateResponse + +### Managed + +Types: + +```python +from cloudflare.types.api_gateway.labels import ManagedGetResponse +``` + +Methods: + +- client.api_gateway.labels.managed.get(name, \*, zone_id, \*\*params) -> ManagedGetResponse + +#### Resources + +##### Operation + +Types: + +```python +from cloudflare.types.api_gateway.labels.managed.resources import OperationUpdateResponse +``` + +Methods: + +- client.api_gateway.labels.managed.resources.operation.update(name, \*, zone_id, \*\*params) -> OperationUpdateResponse + +## Operations + +Types: + +```python +from cloudflare.types.api_gateway import ( + APIShield, + OperationCreateResponse, + OperationListResponse, + OperationDeleteResponse, + OperationBulkCreateResponse, + OperationBulkDeleteResponse, + OperationGetResponse, +) +``` + +Methods: + +- 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 + +### Labels + +Types: + +```python +from cloudflare.types.api_gateway.operations import ( + LabelCreateResponse, + LabelUpdateResponse, + LabelDeleteResponse, + LabelBulkCreateResponse, + LabelBulkDeleteResponse, + LabelBulkUpdateResponse, +) +``` + +Methods: + +- client.api_gateway.operations.labels.create(operation_id, \*, zone_id, \*\*params) -> LabelCreateResponse +- client.api_gateway.operations.labels.update(operation_id, \*, zone_id, \*\*params) -> LabelUpdateResponse +- client.api_gateway.operations.labels.delete(operation_id, \*, zone_id) -> LabelDeleteResponse +- client.api_gateway.operations.labels.bulk_create(\*, zone_id, \*\*params) -> SyncSinglePage[LabelBulkCreateResponse] +- client.api_gateway.operations.labels.bulk_delete(\*, zone_id) -> SyncSinglePage[LabelBulkDeleteResponse] +- client.api_gateway.operations.labels.bulk_update(\*, zone_id, \*\*params) -> SyncSinglePage[LabelBulkUpdateResponse] + +### SchemaValidation + +Types: + +```python +from cloudflare.types.api_gateway.operations import ( + SettingsMultipleRequest, + SchemaValidationUpdateResponse, + SchemaValidationGetResponse, +) +``` + +Methods: + +- client.api_gateway.operations.schema_validation.update(operation_id, \*, zone_id, \*\*params) -> SchemaValidationUpdateResponse +- client.api_gateway.operations.schema_validation.edit(\*, zone_id, \*\*params) -> SettingsMultipleRequest +- client.api_gateway.operations.schema_validation.get(operation_id, \*, zone_id) -> SchemaValidationGetResponse + +## Schemas + +Types: + +```python +from cloudflare.types.api_gateway import SchemaListResponse +``` + +Methods: + +- client.api_gateway.schemas.list(\*, zone_id, \*\*params) -> SchemaListResponse + +## Settings + +Types: + +```python +from cloudflare.types.api_gateway import Settings +``` + +### SchemaValidation + +Methods: + +- client.api_gateway.settings.schema_validation.update(\*, zone_id, \*\*params) -> Settings +- client.api_gateway.settings.schema_validation.edit(\*, zone_id, \*\*params) -> Settings +- client.api_gateway.settings.schema_validation.get(\*, zone_id) -> Settings + +## UserSchemas + +Types: + +```python +from cloudflare.types.api_gateway import ( + Message, + OldPublicSchema, + UserSchemaCreateResponse, + UserSchemaDeleteResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.api_gateway.user_schemas import OperationListResponse +``` + +Methods: + +- client.api_gateway.user_schemas.operations.list(schema_id, \*, zone_id, \*\*params) -> SyncV4PagePaginationArray[OperationListResponse] + +### 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 diff --git a/src/cloudflare/resources/api_gateway/configurations.py b/src/cloudflare/resources/api_gateway/configurations.py index bd62e5e568b..c79d9f3fc16 100644 --- a/src/cloudflare/resources/api_gateway/configurations.py +++ b/src/cloudflare/resources/api_gateway/configurations.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> ConfigurationsResourceWithStreamingResponse def update( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -75,10 +75,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/api_gateway/configuration", + path_template("/zones/{zone_id}/api_gateway/configuration", zone_id=zone_id), body=maybe_transform( {"auth_id_characteristics": auth_id_characteristics}, configuration_update_params.ConfigurationUpdateParams, @@ -97,7 +99,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -123,10 +125,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/api_gateway/configuration", + path_template("/zones/{zone_id}/api_gateway/configuration", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -162,7 +166,7 @@ def with_streaming_response(self) -> AsyncConfigurationsResourceWithStreamingRes async def update( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -190,10 +194,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/api_gateway/configuration", + path_template("/zones/{zone_id}/api_gateway/configuration", zone_id=zone_id), body=await async_maybe_transform( {"auth_id_characteristics": auth_id_characteristics}, configuration_update_params.ConfigurationUpdateParams, @@ -214,7 +220,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -240,10 +246,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/api_gateway/configuration", + path_template("/zones/{zone_id}/api_gateway/configuration", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/api_gateway/discovery/discovery.py b/src/cloudflare/resources/api_gateway/discovery/discovery.py index a465c6fc4a9..4e20f1bc08e 100644 --- a/src/cloudflare/resources/api_gateway/discovery/discovery.py +++ b/src/cloudflare/resources/api_gateway/discovery/discovery.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from .operations import ( OperationsResource, @@ -57,7 +58,7 @@ def with_streaming_response(self) -> DiscoveryResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -80,10 +81,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/api_gateway/discovery", + path_template("/zones/{zone_id}/api_gateway/discovery", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -122,7 +125,7 @@ def with_streaming_response(self) -> AsyncDiscoveryResourceWithStreamingResponse async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -145,10 +148,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/api_gateway/discovery", + path_template("/zones/{zone_id}/api_gateway/discovery", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/api_gateway/discovery/operations.py b/src/cloudflare/resources/api_gateway/discovery/operations.py index 76aeb31fde9..f7f224726c4 100644 --- a/src/cloudflare/resources/api_gateway/discovery/operations.py +++ b/src/cloudflare/resources/api_gateway/discovery/operations.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> OperationsResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, diff: bool | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, endpoint: str | Omit = omit, @@ -117,10 +117,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/discovery/operations", + path_template("/zones/{zone_id}/api_gateway/discovery/operations", zone_id=zone_id), page=SyncV4PagePaginationArray[DiscoveryOperation], options=make_request_options( extra_headers=extra_headers, @@ -149,7 +151,7 @@ def list( def bulk_edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -172,10 +174,12 @@ def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/discovery/operations", zone_id=zone_id), body=maybe_transform(body, operation_bulk_edit_params.OperationBulkEditParams), options=make_request_options( extra_headers=extra_headers, @@ -191,7 +195,7 @@ def edit( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -221,12 +225,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._patch( - f"/zones/{zone_id}/api_gateway/discovery/operations/{operation_id}", + path_template( + "/zones/{zone_id}/api_gateway/discovery/operations/{operation_id}", + zone_id=zone_id, + operation_id=operation_id, + ), body=maybe_transform({"state": state}, operation_edit_params.OperationEditParams), options=make_request_options( extra_headers=extra_headers, @@ -262,7 +272,7 @@ def with_streaming_response(self) -> AsyncOperationsResourceWithStreamingRespons def list( self, *, - zone_id: str, + zone_id: str | None = None, diff: bool | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, endpoint: str | Omit = omit, @@ -328,10 +338,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/discovery/operations", + path_template("/zones/{zone_id}/api_gateway/discovery/operations", zone_id=zone_id), page=AsyncV4PagePaginationArray[DiscoveryOperation], options=make_request_options( extra_headers=extra_headers, @@ -360,7 +372,7 @@ def list( async def bulk_edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -383,10 +395,12 @@ async def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/discovery/operations", zone_id=zone_id), body=await async_maybe_transform(body, operation_bulk_edit_params.OperationBulkEditParams), options=make_request_options( extra_headers=extra_headers, @@ -402,7 +416,7 @@ async def edit( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -432,12 +446,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._patch( - f"/zones/{zone_id}/api_gateway/discovery/operations/{operation_id}", + path_template( + "/zones/{zone_id}/api_gateway/discovery/operations/{operation_id}", + zone_id=zone_id, + operation_id=operation_id, + ), body=await async_maybe_transform({"state": state}, operation_edit_params.OperationEditParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py b/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py index 8f4d2735cd0..ad850206763 100644 --- a/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py +++ b/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> FallthroughResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -74,10 +74,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/expression-template/fallthrough", zone_id=zone_id), body=maybe_transform({"hosts": hosts}, fallthrough_create_params.FallthroughCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -113,7 +115,7 @@ def with_streaming_response(self) -> AsyncFallthroughResourceWithStreamingRespon async def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -140,10 +142,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/expression-template/fallthrough", zone_id=zone_id), body=await async_maybe_transform({"hosts": hosts}, fallthrough_create_params.FallthroughCreateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/api_gateway/labels/labels.py b/src/cloudflare/resources/api_gateway/labels/labels.py index 4f2280b9c56..0072827b371 100644 --- a/src/cloudflare/resources/api_gateway/labels/labels.py +++ b/src/cloudflare/resources/api_gateway/labels/labels.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from .user.user import ( UserResource, AsyncUserResource, @@ -71,7 +71,7 @@ def with_streaming_response(self) -> LabelsResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, filter: str | Omit = omit, order: Literal["name", "description", "created_at", "last_updated", "mapped_resources.operations"] @@ -115,10 +115,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels", + path_template("/zones/{zone_id}/api_gateway/labels", zone_id=zone_id), page=SyncV4PagePaginationArray[LabelListResponse], options=make_request_options( extra_headers=extra_headers, @@ -173,7 +175,7 @@ def with_streaming_response(self) -> AsyncLabelsResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, filter: str | Omit = omit, order: Literal["name", "description", "created_at", "last_updated", "mapped_resources.operations"] @@ -217,10 +219,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels", + path_template("/zones/{zone_id}/api_gateway/labels", zone_id=zone_id), page=AsyncV4PagePaginationArray[LabelListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/api_gateway/labels/managed/managed.py b/src/cloudflare/resources/api_gateway/labels/managed/managed.py index fef15b370e5..9a1c9a7dc32 100644 --- a/src/cloudflare/resources/api_gateway/labels/managed/managed.py +++ b/src/cloudflare/resources/api_gateway/labels/managed/managed.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -60,7 +60,7 @@ def get( self, name: str, *, - zone_id: str, + zone_id: str | None = None, with_mapped_resource_counts: 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. @@ -87,12 +87,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return self._get( - f"/zones/{zone_id}/api_gateway/labels/managed/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/managed/{name}", zone_id=zone_id, name=name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -135,7 +137,7 @@ async def get( self, name: str, *, - zone_id: str, + zone_id: str | None = None, with_mapped_resource_counts: 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. @@ -162,12 +164,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return await self._get( - f"/zones/{zone_id}/api_gateway/labels/managed/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/managed/{name}", zone_id=zone_id, name=name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/api_gateway/labels/managed/resources/operation.py b/src/cloudflare/resources/api_gateway/labels/managed/resources/operation.py index edf21582d99..632bc9392db 100644 --- a/src/cloudflare/resources/api_gateway/labels/managed/resources/operation.py +++ b/src/cloudflare/resources/api_gateway/labels/managed/resources/operation.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -48,7 +48,7 @@ def update( self, name: str, *, - zone_id: str, + zone_id: str | None = None, selector: operation_update_params.Selector, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -75,12 +75,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return self._put( - f"/zones/{zone_id}/api_gateway/labels/managed/{name}/resources/operation", + path_template( + "/zones/{zone_id}/api_gateway/labels/managed/{name}/resources/operation", zone_id=zone_id, name=name + ), body=maybe_transform({"selector": selector}, operation_update_params.OperationUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -117,7 +121,7 @@ async def update( self, name: str, *, - zone_id: str, + zone_id: str | None = None, selector: operation_update_params.Selector, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -144,12 +148,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return await self._put( - f"/zones/{zone_id}/api_gateway/labels/managed/{name}/resources/operation", + path_template( + "/zones/{zone_id}/api_gateway/labels/managed/{name}/resources/operation", zone_id=zone_id, name=name + ), body=await async_maybe_transform({"selector": selector}, operation_update_params.OperationUpdateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/api_gateway/labels/user/resources/operation.py b/src/cloudflare/resources/api_gateway/labels/user/resources/operation.py index 57532ca8f3a..dc4cbc01ea5 100644 --- a/src/cloudflare/resources/api_gateway/labels/user/resources/operation.py +++ b/src/cloudflare/resources/api_gateway/labels/user/resources/operation.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -48,7 +48,7 @@ def update( self, name: str, *, - zone_id: str, + zone_id: str | None = None, selector: operation_update_params.Selector, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -75,12 +75,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return self._put( - f"/zones/{zone_id}/api_gateway/labels/user/{name}/resources/operation", + path_template( + "/zones/{zone_id}/api_gateway/labels/user/{name}/resources/operation", zone_id=zone_id, name=name + ), body=maybe_transform({"selector": selector}, operation_update_params.OperationUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -117,7 +121,7 @@ async def update( self, name: str, *, - zone_id: str, + zone_id: str | None = None, selector: operation_update_params.Selector, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -144,12 +148,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return await self._put( - f"/zones/{zone_id}/api_gateway/labels/user/{name}/resources/operation", + path_template( + "/zones/{zone_id}/api_gateway/labels/user/{name}/resources/operation", zone_id=zone_id, name=name + ), body=await async_maybe_transform({"selector": selector}, operation_update_params.OperationUpdateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/api_gateway/labels/user/user.py b/src/cloudflare/resources/api_gateway/labels/user/user.py index ee4a303db37..ac3693f85f4 100644 --- a/src/cloudflare/resources/api_gateway/labels/user/user.py +++ b/src/cloudflare/resources/api_gateway/labels/user/user.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -66,7 +66,7 @@ def update( self, name: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, metadata: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -96,12 +96,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return self._put( - f"/zones/{zone_id}/api_gateway/labels/user/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/user/{name}", zone_id=zone_id, name=name), body=maybe_transform( { "description": description, @@ -123,7 +125,7 @@ def delete( self, name: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -147,12 +149,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return self._delete( - f"/zones/{zone_id}/api_gateway/labels/user/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/user/{name}", zone_id=zone_id, name=name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -166,7 +170,7 @@ def delete( def bulk_create( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[user_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. @@ -189,10 +193,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels/user", + path_template("/zones/{zone_id}/api_gateway/labels/user", zone_id=zone_id), page=SyncSinglePage[UserBulkCreateResponse], body=maybe_transform(body, Iterable[user_bulk_create_params.Body]), options=make_request_options( @@ -205,7 +211,7 @@ def bulk_create( def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -227,10 +233,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels/user", + path_template("/zones/{zone_id}/api_gateway/labels/user", zone_id=zone_id), page=SyncSinglePage[UserBulkDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -243,7 +251,7 @@ def edit( self, name: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, metadata: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -273,12 +281,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return self._patch( - f"/zones/{zone_id}/api_gateway/labels/user/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/user/{name}", zone_id=zone_id, name=name), body=maybe_transform( { "description": description, @@ -300,7 +310,7 @@ def get( self, name: str, *, - zone_id: str, + zone_id: str | None = None, with_mapped_resource_counts: 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. @@ -327,12 +337,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return self._get( - f"/zones/{zone_id}/api_gateway/labels/user/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/user/{name}", zone_id=zone_id, name=name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -375,7 +387,7 @@ async def update( self, name: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, metadata: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -405,12 +417,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return await self._put( - f"/zones/{zone_id}/api_gateway/labels/user/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/user/{name}", zone_id=zone_id, name=name), body=await async_maybe_transform( { "description": description, @@ -432,7 +446,7 @@ async def delete( self, name: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -456,12 +470,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return await self._delete( - f"/zones/{zone_id}/api_gateway/labels/user/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/user/{name}", zone_id=zone_id, name=name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -475,7 +491,7 @@ async def delete( def bulk_create( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[user_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. @@ -498,10 +514,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels/user", + path_template("/zones/{zone_id}/api_gateway/labels/user", zone_id=zone_id), page=AsyncSinglePage[UserBulkCreateResponse], body=maybe_transform(body, Iterable[user_bulk_create_params.Body]), options=make_request_options( @@ -514,7 +532,7 @@ def bulk_create( def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -536,10 +554,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels/user", + path_template("/zones/{zone_id}/api_gateway/labels/user", zone_id=zone_id), page=AsyncSinglePage[UserBulkDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -552,7 +572,7 @@ async def edit( self, name: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, metadata: object | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -582,12 +602,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return await self._patch( - f"/zones/{zone_id}/api_gateway/labels/user/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/user/{name}", zone_id=zone_id, name=name), body=await async_maybe_transform( { "description": description, @@ -609,7 +631,7 @@ async def get( self, name: str, *, - zone_id: str, + zone_id: str | None = None, with_mapped_resource_counts: 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. @@ -636,12 +658,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not name: raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") return await self._get( - f"/zones/{zone_id}/api_gateway/labels/user/{name}", + path_template("/zones/{zone_id}/api_gateway/labels/user/{name}", zone_id=zone_id, name=name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/api_gateway/operations/labels.py b/src/cloudflare/resources/api_gateway/operations/labels.py index 8ad2bb6e87c..9191bf97b8b 100644 --- a/src/cloudflare/resources/api_gateway/operations/labels.py +++ b/src/cloudflare/resources/api_gateway/operations/labels.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -59,7 +59,7 @@ def create( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, managed: SequenceNotStr[str] | Omit = omit, user: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -89,12 +89,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._post( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + zone_id=zone_id, + operation_id=operation_id, + ), body=maybe_transform( { "managed": managed, @@ -116,7 +122,7 @@ def update( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, managed: SequenceNotStr[str] | Omit = omit, user: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -148,12 +154,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._put( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + zone_id=zone_id, + operation_id=operation_id, + ), body=maybe_transform( { "managed": managed, @@ -175,7 +187,7 @@ def delete( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -199,12 +211,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._delete( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + zone_id=zone_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -218,7 +236,7 @@ def delete( def bulk_create( self, *, - zone_id: str, + zone_id: str | None = None, selector: label_bulk_create_params.Selector, managed: label_bulk_create_params.Managed | Omit = omit, user: label_bulk_create_params.User | Omit = omit, @@ -245,10 +263,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels", + path_template("/zones/{zone_id}/api_gateway/operations/labels", zone_id=zone_id), page=SyncSinglePage[LabelBulkCreateResponse], body=maybe_transform( { @@ -268,7 +288,7 @@ def bulk_create( def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -290,10 +310,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels", + path_template("/zones/{zone_id}/api_gateway/operations/labels", zone_id=zone_id), page=SyncSinglePage[LabelBulkDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -305,7 +327,7 @@ def bulk_delete( def bulk_update( self, *, - zone_id: str, + zone_id: str | None = None, managed: label_bulk_update_params.Managed, selector: label_bulk_update_params.Selector, user: label_bulk_update_params.User, @@ -336,10 +358,12 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels", + path_template("/zones/{zone_id}/api_gateway/operations/labels", zone_id=zone_id), page=SyncSinglePage[LabelBulkUpdateResponse], body=maybe_transform( { @@ -381,7 +405,7 @@ async def create( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, managed: SequenceNotStr[str] | Omit = omit, user: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -411,12 +435,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._post( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + zone_id=zone_id, + operation_id=operation_id, + ), body=await async_maybe_transform( { "managed": managed, @@ -438,7 +468,7 @@ async def update( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, managed: SequenceNotStr[str] | Omit = omit, user: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -470,12 +500,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._put( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + zone_id=zone_id, + operation_id=operation_id, + ), body=await async_maybe_transform( { "managed": managed, @@ -497,7 +533,7 @@ async def delete( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -521,12 +557,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._delete( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/labels", + zone_id=zone_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -540,7 +582,7 @@ async def delete( def bulk_create( self, *, - zone_id: str, + zone_id: str | None = None, selector: label_bulk_create_params.Selector, managed: label_bulk_create_params.Managed | Omit = omit, user: label_bulk_create_params.User | Omit = omit, @@ -567,10 +609,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels", + path_template("/zones/{zone_id}/api_gateway/operations/labels", zone_id=zone_id), page=AsyncSinglePage[LabelBulkCreateResponse], body=maybe_transform( { @@ -590,7 +634,7 @@ def bulk_create( def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -612,10 +656,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels", + path_template("/zones/{zone_id}/api_gateway/operations/labels", zone_id=zone_id), page=AsyncSinglePage[LabelBulkDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -627,7 +673,7 @@ def bulk_delete( def bulk_update( self, *, - zone_id: str, + zone_id: str | None = None, managed: label_bulk_update_params.Managed, selector: label_bulk_update_params.Selector, user: label_bulk_update_params.User, @@ -658,10 +704,12 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/labels", + path_template("/zones/{zone_id}/api_gateway/operations/labels", zone_id=zone_id), page=AsyncSinglePage[LabelBulkUpdateResponse], body=maybe_transform( { diff --git a/src/cloudflare/resources/api_gateway/operations/operations.py b/src/cloudflare/resources/api_gateway/operations/operations.py index 31189308551..9b90cb22f15 100644 --- a/src/cloudflare/resources/api_gateway/operations/operations.py +++ b/src/cloudflare/resources/api_gateway/operations/operations.py @@ -16,7 +16,7 @@ AsyncLabelsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -83,7 +83,7 @@ def with_streaming_response(self) -> OperationsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, endpoint: str, host: str, method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"], @@ -122,10 +122,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/item", + path_template("/zones/{zone_id}/api_gateway/operations/item", zone_id=zone_id), body=maybe_transform( { "endpoint": endpoint, @@ -147,7 +149,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, endpoint: str | Omit = omit, feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, @@ -197,10 +199,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/operations", zone_id=zone_id), page=SyncV4PagePaginationArray[OperationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -228,7 +232,7 @@ def delete( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -254,12 +258,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._delete( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}", zone_id=zone_id, operation_id=operation_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -269,7 +277,7 @@ def delete( def bulk_create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -297,10 +305,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/operations", zone_id=zone_id), page=SyncSinglePage[OperationBulkCreateResponse], body=maybe_transform(body, Iterable[operation_bulk_create_params.Body]), options=make_request_options( @@ -313,7 +323,7 @@ def bulk_create( def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -336,10 +346,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/operations", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -350,7 +362,7 @@ def get( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -380,12 +392,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._get( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}", zone_id=zone_id, operation_id=operation_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -429,7 +445,7 @@ def with_streaming_response(self) -> AsyncOperationsResourceWithStreamingRespons async def create( self, *, - zone_id: str, + zone_id: str | None = None, endpoint: str, host: str, method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"], @@ -468,10 +484,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/item", + path_template("/zones/{zone_id}/api_gateway/operations/item", zone_id=zone_id), body=await async_maybe_transform( { "endpoint": endpoint, @@ -493,7 +511,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, endpoint: str | Omit = omit, feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, @@ -543,10 +561,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/operations", zone_id=zone_id), page=AsyncV4PagePaginationArray[OperationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -574,7 +594,7 @@ async def delete( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -600,12 +620,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._delete( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}", zone_id=zone_id, operation_id=operation_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -615,7 +639,7 @@ async def delete( def bulk_create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -643,10 +667,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/operations", zone_id=zone_id), page=AsyncSinglePage[OperationBulkCreateResponse], body=maybe_transform(body, Iterable[operation_bulk_create_params.Body]), options=make_request_options( @@ -659,7 +685,7 @@ def bulk_create( async def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -682,10 +708,12 @@ async def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/operations", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -696,7 +724,7 @@ async def get( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -726,12 +754,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._get( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}", zone_id=zone_id, operation_id=operation_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/api_gateway/operations/schema_validation.py b/src/cloudflare/resources/api_gateway/operations/schema_validation.py index 5b526d920a8..dd93f97c5e6 100644 --- a/src/cloudflare/resources/api_gateway/operations/schema_validation.py +++ b/src/cloudflare/resources/api_gateway/operations/schema_validation.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -60,7 +60,7 @@ def update( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -94,12 +94,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._put( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + zone_id=zone_id, + operation_id=operation_id, + ), body=maybe_transform( {"mitigation_action": mitigation_action}, schema_validation_update_params.SchemaValidationUpdateParams ), @@ -115,7 +121,7 @@ def update( def edit( self, *, - zone_id: str, + zone_id: str | None = None, settings_multiple_request: SettingsMultipleRequestParam, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -138,10 +144,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/operations/schema_validation", + path_template("/zones/{zone_id}/api_gateway/operations/schema_validation", zone_id=zone_id), body=maybe_transform(settings_multiple_request, schema_validation_edit_params.SchemaValidationEditParams), options=make_request_options( extra_headers=extra_headers, @@ -160,7 +168,7 @@ def get( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -184,12 +192,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._get( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + zone_id=zone_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -224,7 +238,7 @@ async def update( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -258,12 +272,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._put( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + zone_id=zone_id, + operation_id=operation_id, + ), body=await async_maybe_transform( {"mitigation_action": mitigation_action}, schema_validation_update_params.SchemaValidationUpdateParams ), @@ -279,7 +299,7 @@ async def update( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, settings_multiple_request: SettingsMultipleRequestParam, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -302,10 +322,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/operations/schema_validation", + path_template("/zones/{zone_id}/api_gateway/operations/schema_validation", zone_id=zone_id), body=await async_maybe_transform( settings_multiple_request, schema_validation_edit_params.SchemaValidationEditParams ), @@ -326,7 +348,7 @@ async def get( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -350,12 +372,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._get( - f"/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + path_template( + "/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + zone_id=zone_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/api_gateway/schemas.py b/src/cloudflare/resources/api_gateway/schemas.py index 2559e6e21c2..aa754506f6d 100644 --- a/src/cloudflare/resources/api_gateway/schemas.py +++ b/src/cloudflare/resources/api_gateway/schemas.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> SchemasResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -78,10 +78,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/api_gateway/schemas", + path_template("/zones/{zone_id}/api_gateway/schemas", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -123,7 +125,7 @@ def with_streaming_response(self) -> AsyncSchemasResourceWithStreamingResponse: async def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -153,10 +155,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/api_gateway/schemas", + path_template("/zones/{zone_id}/api_gateway/schemas", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/api_gateway/settings/schema_validation.py b/src/cloudflare/resources/api_gateway/settings/schema_validation.py index edc6f969c00..0f2995bbc91 100644 --- a/src/cloudflare/resources/api_gateway/settings/schema_validation.py +++ b/src/cloudflare/resources/api_gateway/settings/schema_validation.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> SchemaValidationResourceWithStreamingRespon def update( self, *, - zone_id: str, + zone_id: str | None = None, validation_default_mitigation_action: Literal["none", "log", "block"], 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. @@ -93,10 +93,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/api_gateway/settings/schema_validation", + path_template("/zones/{zone_id}/api_gateway/settings/schema_validation", zone_id=zone_id), body=maybe_transform( { "validation_default_mitigation_action": validation_default_mitigation_action, @@ -116,7 +118,7 @@ def update( def edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -159,10 +161,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/settings/schema_validation", + path_template("/zones/{zone_id}/api_gateway/settings/schema_validation", zone_id=zone_id), body=maybe_transform( { "validation_default_mitigation_action": validation_default_mitigation_action, @@ -182,7 +186,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -204,10 +208,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/api_gateway/settings/schema_validation", + path_template("/zones/{zone_id}/api_gateway/settings/schema_validation", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -241,7 +247,7 @@ def with_streaming_response(self) -> AsyncSchemaValidationResourceWithStreamingR async def update( self, *, - zone_id: str, + zone_id: str | None = None, validation_default_mitigation_action: Literal["none", "log", "block"], 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. @@ -283,10 +289,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/api_gateway/settings/schema_validation", + path_template("/zones/{zone_id}/api_gateway/settings/schema_validation", zone_id=zone_id), body=await async_maybe_transform( { "validation_default_mitigation_action": validation_default_mitigation_action, @@ -306,7 +314,7 @@ async def update( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -349,10 +357,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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/settings/schema_validation", + path_template("/zones/{zone_id}/api_gateway/settings/schema_validation", zone_id=zone_id), body=await async_maybe_transform( { "validation_default_mitigation_action": validation_default_mitigation_action, @@ -372,7 +382,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -394,10 +404,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/api_gateway/settings/schema_validation", + path_template("/zones/{zone_id}/api_gateway/settings/schema_validation", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/api_gateway/user_schemas/hosts.py b/src/cloudflare/resources/api_gateway/user_schemas/hosts.py index d193678ec7d..f3b2531c3d2 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/hosts.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/hosts.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> HostsResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -80,10 +80,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/user_schemas/hosts", zone_id=zone_id), page=SyncV4PagePaginationArray[HostListResponse], options=make_request_options( extra_headers=extra_headers, @@ -128,7 +130,7 @@ def with_streaming_response(self) -> AsyncHostsResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -158,10 +160,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/user_schemas/hosts", zone_id=zone_id), page=AsyncV4PagePaginationArray[HostListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/api_gateway/user_schemas/operations.py b/src/cloudflare/resources/api_gateway/user_schemas/operations.py index d5a04f5f875..59d6e6cce79 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/operations.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/operations.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -53,7 +53,7 @@ def list( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, endpoint: str | Omit = omit, feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, host: SequenceNotStr[str] | Omit = omit, @@ -103,12 +103,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 self._get_api_list( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations", + path_template( + "/zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations", zone_id=zone_id, schema_id=schema_id + ), page=SyncV4PagePaginationArray[OperationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -159,7 +163,7 @@ def list( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, endpoint: str | Omit = omit, feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, host: SequenceNotStr[str] | Omit = omit, @@ -209,12 +213,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 self._get_api_list( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations", + path_template( + "/zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations", zone_id=zone_id, schema_id=schema_id + ), page=AsyncV4PagePaginationArray[OperationListResponse], options=make_request_options( extra_headers=extra_headers, 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 346db5396d5..946cdc27aba 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py @@ -17,7 +17,7 @@ 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 ...._utils import extract_files, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform from ...._compat import cached_property from .operations import ( OperationsResource, @@ -84,7 +84,7 @@ def with_streaming_response(self) -> UserSchemasResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, file: FileTypes, kind: Literal["openapi_v3"], name: str | Omit = omit, @@ -118,6 +118,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") body = deepcopy_minimal( @@ -134,7 +136,7 @@ def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( - f"/zones/{zone_id}/api_gateway/user_schemas", + path_template("/zones/{zone_id}/api_gateway/user_schemas", zone_id=zone_id), body=maybe_transform(body, user_schema_create_params.UserSchemaCreateParams), files=files, options=make_request_options( @@ -153,7 +155,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, omit_source: bool | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -188,10 +190,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/user_schemas", zone_id=zone_id), page=SyncV4PagePaginationArray[OldPublicSchema], options=make_request_options( extra_headers=extra_headers, @@ -218,7 +222,7 @@ def delete( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -242,12 +246,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 self._delete( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + path_template( + "/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -261,7 +269,7 @@ def edit( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -288,12 +296,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 self._patch( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + path_template( + "/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), body=maybe_transform( {"validation_enabled": validation_enabled}, user_schema_edit_params.UserSchemaEditParams ), @@ -314,7 +326,7 @@ def get( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -340,12 +352,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 self._get( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + path_template( + "/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -392,7 +408,7 @@ def with_streaming_response(self) -> AsyncUserSchemasResourceWithStreamingRespon async def create( self, *, - zone_id: str, + zone_id: str | None = None, file: FileTypes, kind: Literal["openapi_v3"], name: str | Omit = omit, @@ -426,6 +442,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") body = deepcopy_minimal( @@ -442,7 +460,7 @@ async def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( - f"/zones/{zone_id}/api_gateway/user_schemas", + path_template("/zones/{zone_id}/api_gateway/user_schemas", zone_id=zone_id), body=await async_maybe_transform(body, user_schema_create_params.UserSchemaCreateParams), files=files, options=make_request_options( @@ -461,7 +479,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, omit_source: bool | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -496,10 +514,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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", + path_template("/zones/{zone_id}/api_gateway/user_schemas", zone_id=zone_id), page=AsyncV4PagePaginationArray[OldPublicSchema], options=make_request_options( extra_headers=extra_headers, @@ -526,7 +546,7 @@ async def delete( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -550,12 +570,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 await self._delete( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + path_template( + "/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -569,7 +593,7 @@ async def edit( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -596,12 +620,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 await self._patch( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + path_template( + "/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), body=await async_maybe_transform( {"validation_enabled": validation_enabled}, user_schema_edit_params.UserSchemaEditParams ), @@ -622,7 +650,7 @@ async def get( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -648,12 +676,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 await self._get( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + path_template( + "/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/argo/api.md b/src/cloudflare/resources/argo/api.md new file mode 100644 index 00000000000..8f14d7c8ff4 --- /dev/null +++ b/src/cloudflare/resources/argo/api.md @@ -0,0 +1,27 @@ +# Argo + +## SmartRouting + +Types: + +```python +from cloudflare.types.argo import SmartRoutingEditResponse, SmartRoutingGetResponse +``` + +Methods: + +- client.argo.smart_routing.edit(\*, zone_id, \*\*params) -> SmartRoutingEditResponse +- client.argo.smart_routing.get(\*, zone_id) -> SmartRoutingGetResponse + +## TieredCaching + +Types: + +```python +from cloudflare.types.argo import TieredCachingEditResponse, TieredCachingGetResponse +``` + +Methods: + +- client.argo.tiered_caching.edit(\*, zone_id, \*\*params) -> Optional[TieredCachingEditResponse] +- client.argo.tiered_caching.get(\*, zone_id) -> Optional[TieredCachingGetResponse] diff --git a/src/cloudflare/resources/argo/smart_routing.py b/src/cloudflare/resources/argo/smart_routing.py index d45d9be9c4d..81eedc11d47 100644 --- a/src/cloudflare/resources/argo/smart_routing.py +++ b/src/cloudflare/resources/argo/smart_routing.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> SmartRoutingResourceWithStreamingResponse: def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -74,10 +74,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/argo/smart_routing", + path_template("/zones/{zone_id}/argo/smart_routing", zone_id=zone_id), body=maybe_transform({"value": value}, smart_routing_edit_params.SmartRoutingEditParams), options=make_request_options( extra_headers=extra_headers, @@ -92,7 +94,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -114,10 +116,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/argo/smart_routing", + path_template("/zones/{zone_id}/argo/smart_routing", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -152,7 +156,7 @@ def with_streaming_response(self) -> AsyncSmartRoutingResourceWithStreamingRespo async def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -177,10 +181,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/argo/smart_routing", + path_template("/zones/{zone_id}/argo/smart_routing", zone_id=zone_id), body=await async_maybe_transform({"value": value}, smart_routing_edit_params.SmartRoutingEditParams), options=make_request_options( extra_headers=extra_headers, @@ -195,7 +201,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -217,10 +223,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/argo/smart_routing", + path_template("/zones/{zone_id}/argo/smart_routing", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/argo/tiered_caching.py b/src/cloudflare/resources/argo/tiered_caching.py index 9662940b73c..ccdecb2b9f4 100644 --- a/src/cloudflare/resources/argo/tiered_caching.py +++ b/src/cloudflare/resources/argo/tiered_caching.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> TieredCachingResourceWithStreamingResponse: def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -84,10 +84,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/argo/tiered_caching", + path_template("/zones/{zone_id}/argo/tiered_caching", zone_id=zone_id), body=maybe_transform({"value": value}, tiered_caching_edit_params.TieredCachingEditParams), options=make_request_options( extra_headers=extra_headers, @@ -102,7 +104,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -134,10 +136,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/argo/tiered_caching", + path_template("/zones/{zone_id}/argo/tiered_caching", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -172,7 +176,7 @@ def with_streaming_response(self) -> AsyncTieredCachingResourceWithStreamingResp async def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -207,10 +211,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/argo/tiered_caching", + path_template("/zones/{zone_id}/argo/tiered_caching", zone_id=zone_id), body=await async_maybe_transform({"value": value}, tiered_caching_edit_params.TieredCachingEditParams), options=make_request_options( extra_headers=extra_headers, @@ -225,7 +231,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -257,10 +263,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/argo/tiered_caching", + path_template("/zones/{zone_id}/argo/tiered_caching", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/audit_logs/__init__.py b/src/cloudflare/resources/audit_logs/__init__.py new file mode 100644 index 00000000000..5b68ef05434 --- /dev/null +++ b/src/cloudflare/resources/audit_logs/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .audit_logs import ( + AuditLogsResource, + AsyncAuditLogsResource, + AuditLogsResourceWithRawResponse, + AsyncAuditLogsResourceWithRawResponse, + AuditLogsResourceWithStreamingResponse, + AsyncAuditLogsResourceWithStreamingResponse, +) + +__all__ = [ + "AuditLogsResource", + "AsyncAuditLogsResource", + "AuditLogsResourceWithRawResponse", + "AsyncAuditLogsResourceWithRawResponse", + "AuditLogsResourceWithStreamingResponse", + "AsyncAuditLogsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/audit_logs/api.md b/src/cloudflare/resources/audit_logs/api.md new file mode 100644 index 00000000000..bc35bf17c55 --- /dev/null +++ b/src/cloudflare/resources/audit_logs/api.md @@ -0,0 +1,5 @@ +# AuditLogs + +Methods: + +- client.audit_logs.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[AuditLog] diff --git a/src/cloudflare/resources/audit_logs.py b/src/cloudflare/resources/audit_logs/audit_logs.py similarity index 91% rename from src/cloudflare/resources/audit_logs.py rename to src/cloudflare/resources/audit_logs/audit_logs.py index 1a682f5ac0e..dc718943528 100644 --- a/src/cloudflare/resources/audit_logs.py +++ b/src/cloudflare/resources/audit_logs/audit_logs.py @@ -8,20 +8,20 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, 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.audit_logs import audit_log_list_params -from ..types.shared.audit_log import AuditLog +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.audit_logs import audit_log_list_params +from ...types.shared.audit_log import AuditLog __all__ = ["AuditLogsResource", "AsyncAuditLogsResource"] @@ -49,7 +49,7 @@ def with_streaming_response(self) -> AuditLogsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, action: audit_log_list_params.Action | Omit = omit, actor: audit_log_list_params.Actor | Omit = omit, @@ -102,10 +102,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/audit_logs", + path_template("/accounts/{account_id}/audit_logs", account_id=account_id), page=SyncV4PagePaginationArray[AuditLog], options=make_request_options( extra_headers=extra_headers, @@ -156,7 +158,7 @@ def with_streaming_response(self) -> AsyncAuditLogsResourceWithStreamingResponse def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, action: audit_log_list_params.Action | Omit = omit, actor: audit_log_list_params.Actor | Omit = omit, @@ -209,10 +211,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/audit_logs", + path_template("/accounts/{account_id}/audit_logs", account_id=account_id), page=AsyncV4PagePaginationArray[AuditLog], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/billing/api.md b/src/cloudflare/resources/billing/api.md new file mode 100644 index 00000000000..1580ce478f0 --- /dev/null +++ b/src/cloudflare/resources/billing/api.md @@ -0,0 +1,25 @@ +# Billing + +## Profiles + +Types: + +```python +from cloudflare.types.billing import ProfileGetResponse +``` + +Methods: + +- client.billing.profiles.get(\*, account_id) -> ProfileGetResponse + +## Usage + +Types: + +```python +from cloudflare.types.billing import UsagePaygoResponse +``` + +Methods: + +- client.billing.usage.paygo(\*, account_id, \*\*params) -> UsagePaygoResponse diff --git a/src/cloudflare/resources/billing/profiles.py b/src/cloudflare/resources/billing/profiles.py index f3272600105..54fe1721609 100644 --- a/src/cloudflare/resources/billing/profiles.py +++ b/src/cloudflare/resources/billing/profiles.py @@ -8,6 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +48,7 @@ def with_streaming_response(self) -> ProfilesResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -69,10 +70,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/billing/profile", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -108,7 +111,7 @@ def with_streaming_response(self) -> AsyncProfilesResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -130,10 +133,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/billing/profile", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/billing/usage.py b/src/cloudflare/resources/billing/usage.py index d9841c26684..1b3636edb18 100644 --- a/src/cloudflare/resources/billing/usage.py +++ b/src/cloudflare/resources/billing/usage.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> UsageResourceWithStreamingResponse: def paygo( self, *, - account_id: str, + account_id: str | None = None, from_: Union[str, date] | Omit = omit, to: Union[str, date] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -79,10 +79,12 @@ def paygo( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/usage/paygo", + path_template("/accounts/{account_id}/billing/usage/paygo", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -124,7 +126,7 @@ def with_streaming_response(self) -> AsyncUsageResourceWithStreamingResponse: async def paygo( self, *, - account_id: str, + account_id: str | None = None, from_: Union[str, date] | Omit = omit, to: Union[str, date] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -155,10 +157,12 @@ async def paygo( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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/usage/paygo", + path_template("/accounts/{account_id}/billing/usage/paygo", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/bot_management/__init__.py b/src/cloudflare/resources/bot_management/__init__.py new file mode 100644 index 00000000000..2a4e95b54b3 --- /dev/null +++ b/src/cloudflare/resources/bot_management/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .bot_management import ( + BotManagementResource, + AsyncBotManagementResource, + BotManagementResourceWithRawResponse, + AsyncBotManagementResourceWithRawResponse, + BotManagementResourceWithStreamingResponse, + AsyncBotManagementResourceWithStreamingResponse, +) + +__all__ = [ + "BotManagementResource", + "AsyncBotManagementResource", + "BotManagementResourceWithRawResponse", + "AsyncBotManagementResourceWithRawResponse", + "BotManagementResourceWithStreamingResponse", + "AsyncBotManagementResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/bot_management/api.md b/src/cloudflare/resources/bot_management/api.md new file mode 100644 index 00000000000..906f8dfd9b6 --- /dev/null +++ b/src/cloudflare/resources/bot_management/api.md @@ -0,0 +1,19 @@ +# BotManagement + +Types: + +```python +from cloudflare.types.bot_management import ( + BotFightModeConfiguration, + SubscriptionConfiguration, + SuperBotFightModeDefinitelyConfiguration, + SuperBotFightModeLikelyConfiguration, + BotManagementUpdateResponse, + BotManagementGetResponse, +) +``` + +Methods: + +- client.bot_management.update(\*, zone_id, \*\*params) -> Optional[BotManagementUpdateResponse] +- client.bot_management.get(\*, zone_id) -> Optional[BotManagementGetResponse] diff --git a/src/cloudflare/resources/bot_management.py b/src/cloudflare/resources/bot_management/bot_management.py similarity index 96% rename from src/cloudflare/resources/bot_management.py rename to src/cloudflare/resources/bot_management/bot_management.py index 07b76763411..dfa0e3cf12a 100644 --- a/src/cloudflare/resources/bot_management.py +++ b/src/cloudflare/resources/bot_management/bot_management.py @@ -7,21 +7,21 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, 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.bot_management import bot_management_update_params -from ..types.bot_management.bot_management_get_response import BotManagementGetResponse -from ..types.bot_management.bot_management_update_response import BotManagementUpdateResponse +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.bot_management import bot_management_update_params +from ...types.bot_management.bot_management_get_response import BotManagementGetResponse +from ...types.bot_management.bot_management_update_response import BotManagementUpdateResponse __all__ = ["BotManagementResource", "AsyncBotManagementResource"] @@ -50,7 +50,7 @@ def with_streaming_response(self) -> BotManagementResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, 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, @@ -159,7 +159,7 @@ def update( def update( self, *, - zone_id: str, + zone_id: str | None = None, 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, @@ -279,7 +279,7 @@ def update( def update( self, *, - zone_id: str, + zone_id: str | None = None, 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, @@ -402,7 +402,7 @@ def update( def update( self, *, - zone_id: str, + zone_id: str | None = None, ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, auto_update_model: bool | Omit = omit, bm_cookie_enabled: bool | Omit = omit, @@ -517,11 +517,10 @@ def update( """ ... - @required_args(["zone_id"]) def update( self, *, - zone_id: str, + zone_id: str | None = None, 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, @@ -543,12 +542,14 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[BotManagementUpdateResponse], self._put( - f"/zones/{zone_id}/bot_management", + path_template("/zones/{zone_id}/bot_management", zone_id=zone_id), body=maybe_transform( { "ai_bots_protection": ai_bots_protection, @@ -584,7 +585,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -606,12 +607,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[BotManagementGetResponse], self._get( - f"/zones/{zone_id}/bot_management", + path_template("/zones/{zone_id}/bot_management", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -650,7 +653,7 @@ def with_streaming_response(self) -> AsyncBotManagementResourceWithStreamingResp async def update( self, *, - zone_id: str, + zone_id: str | None = None, 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, @@ -759,7 +762,7 @@ async def update( async def update( self, *, - zone_id: str, + zone_id: str | None = None, 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, @@ -879,7 +882,7 @@ async def update( async def update( self, *, - zone_id: str, + zone_id: str | None = None, 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, @@ -1002,7 +1005,7 @@ async def update( async def update( self, *, - zone_id: str, + zone_id: str | None = None, ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, auto_update_model: bool | Omit = omit, bm_cookie_enabled: bool | Omit = omit, @@ -1117,11 +1120,10 @@ async def update( """ ... - @required_args(["zone_id"]) async def update( self, *, - zone_id: str, + zone_id: str | None = None, 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, @@ -1143,12 +1145,14 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[BotManagementUpdateResponse], await self._put( - f"/zones/{zone_id}/bot_management", + path_template("/zones/{zone_id}/bot_management", zone_id=zone_id), body=await async_maybe_transform( { "ai_bots_protection": ai_bots_protection, @@ -1184,7 +1188,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1206,12 +1210,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[BotManagementGetResponse], await self._get( - f"/zones/{zone_id}/bot_management", + path_template("/zones/{zone_id}/bot_management", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/botnet_feed/api.md b/src/cloudflare/resources/botnet_feed/api.md new file mode 100644 index 00000000000..97232c05424 --- /dev/null +++ b/src/cloudflare/resources/botnet_feed/api.md @@ -0,0 +1,29 @@ +# BotnetFeed + +## ASN + +Types: + +```python +from cloudflare.types.botnet_feed import ASNDayReportResponse, ASNFullReportResponse +``` + +Methods: + +- 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] + +## Configs + +### ASN + +Types: + +```python +from cloudflare.types.botnet_feed.configs import ASNDeleteResponse, ASNGetResponse +``` + +Methods: + +- client.botnet_feed.configs.asn.delete(asn_id, \*, account_id) -> Optional[ASNDeleteResponse] +- client.botnet_feed.configs.asn.get(\*, account_id) -> Optional[ASNGetResponse] diff --git a/src/cloudflare/resources/botnet_feed/asn.py b/src/cloudflare/resources/botnet_feed/asn.py index 285845ee622..d5f9b3a3cbf 100755 --- a/src/cloudflare/resources/botnet_feed/asn.py +++ b/src/cloudflare/resources/botnet_feed/asn.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def day_report( self, asn_id: int, *, - account_id: str, + account_id: str | None = None, 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. @@ -75,10 +75,14 @@ def day_report( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/botnet_feed/asn/{asn_id}/day_report", account_id=account_id, asn_id=asn_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -94,7 +98,7 @@ def full_report( self, asn_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -117,10 +121,14 @@ def full_report( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/botnet_feed/asn/{asn_id}/full_report", account_id=account_id, asn_id=asn_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -156,7 +164,7 @@ async def day_report( self, asn_id: int, *, - account_id: str, + account_id: str | None = None, 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. @@ -181,10 +189,14 @@ async def day_report( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/botnet_feed/asn/{asn_id}/day_report", account_id=account_id, asn_id=asn_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -200,7 +212,7 @@ async def full_report( self, asn_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -223,10 +235,14 @@ async def full_report( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template( + "/accounts/{account_id}/botnet_feed/asn/{asn_id}/full_report", account_id=account_id, asn_id=asn_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/botnet_feed/configs/asn.py b/src/cloudflare/resources/botnet_feed/configs/asn.py index e8cf0754eb4..5313cf8499c 100755 --- a/src/cloudflare/resources/botnet_feed/configs/asn.py +++ b/src/cloudflare/resources/botnet_feed/configs/asn.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +48,7 @@ def delete( self, asn_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -69,10 +70,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/botnet_feed/configs/asn/{asn_id}", account_id=account_id, asn_id=asn_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -86,7 +91,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -108,10 +113,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/botnet_feed/configs/asn", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -147,7 +154,7 @@ async def delete( self, asn_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -169,10 +176,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/botnet_feed/configs/asn/{asn_id}", account_id=account_id, asn_id=asn_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -186,7 +197,7 @@ async def delete( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -208,10 +219,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/botnet_feed/configs/asn", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/brand_protection/api.md b/src/cloudflare/resources/brand_protection/api.md new file mode 100644 index 00000000000..e2be15da0f0 --- /dev/null +++ b/src/cloudflare/resources/brand_protection/api.md @@ -0,0 +1,120 @@ +# BrandProtection + +Types: + +```python +from cloudflare.types.brand_protection import ( + Info, + Submit, + BrandProtectionSubmitResponse, + BrandProtectionURLInfoResponse, +) +``` + +Methods: + +- 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 + +## V2 + +### Queries + +Types: + +```python +from cloudflare.types.brand_protection.v2 import QueryGetResponse +``` + +Methods: + +- client.brand_protection.v2.queries.get(\*, account_id, \*\*params) -> QueryGetResponse + +### Matches + +Types: + +```python +from cloudflare.types.brand_protection.v2 import MatchGetResponse +``` + +Methods: + +- client.brand_protection.v2.matches.get(\*, account_id, \*\*params) -> MatchGetResponse + +### Logos + +Types: + +```python +from cloudflare.types.brand_protection.v2 import ( + LogoCreateResponse, + LogoDeleteResponse, + LogoGetResponse, +) +``` + +Methods: + +- client.brand_protection.v2.logos.create(\*, account_id, \*\*params) -> LogoCreateResponse +- client.brand_protection.v2.logos.delete(query_id, \*, account_id) -> LogoDeleteResponse +- client.brand_protection.v2.logos.get(\*, account_id, \*\*params) -> LogoGetResponse + +### LogoMatches + +Types: + +```python +from cloudflare.types.brand_protection.v2 import LogoMatchGetResponse +``` + +Methods: + +- client.brand_protection.v2.logo_matches.get(\*, account_id, \*\*params) -> LogoMatchGetResponse diff --git a/src/cloudflare/resources/brand_protection/brand_protection.py b/src/cloudflare/resources/brand_protection/brand_protection.py index c28e5602df7..624e5d3ad79 100644 --- a/src/cloudflare/resources/brand_protection/brand_protection.py +++ b/src/cloudflare/resources/brand_protection/brand_protection.py @@ -37,6 +37,7 @@ AsyncQueriesResourceWithStreamingResponse, ) from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -104,7 +105,7 @@ def with_streaming_response(self) -> BrandProtectionResourceWithStreamingRespons def submit( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -124,10 +125,12 @@ def submit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/submit", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -137,7 +140,7 @@ def submit( def url_info( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -157,10 +160,12 @@ def url_info( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/url-info", account_id=account_id), page=SyncSinglePage[BrandProtectionURLInfoResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -212,7 +217,7 @@ def with_streaming_response(self) -> AsyncBrandProtectionResourceWithStreamingRe async def submit( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -232,10 +237,12 @@ async def submit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/submit", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -245,7 +252,7 @@ async def submit( def url_info( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -265,10 +272,12 @@ def url_info( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/url-info", account_id=account_id), page=AsyncSinglePage[BrandProtectionURLInfoResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/brand_protection/logo_matches.py b/src/cloudflare/resources/brand_protection/logo_matches.py index abe100862e5..e8219c56bdd 100644 --- a/src/cloudflare/resources/brand_protection/logo_matches.py +++ b/src/cloudflare/resources/brand_protection/logo_matches.py @@ -5,7 +5,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +45,7 @@ def with_streaming_response(self) -> LogoMatchesResourceWithStreamingResponse: def download( self, *, - account_id: str, + account_id: str | None = None, limit: str | Omit = omit, logo_id: SequenceNotStr[str] | Omit = omit, offset: str | Omit = omit, @@ -68,10 +68,12 @@ def download( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/logo-matches/download", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -92,7 +94,7 @@ def download( def get( self, *, - account_id: str, + account_id: str | None = None, limit: str | Omit = omit, logo_id: SequenceNotStr[str] | Omit = omit, offset: str | Omit = omit, @@ -115,10 +117,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/logo-matches", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -160,7 +164,7 @@ def with_streaming_response(self) -> AsyncLogoMatchesResourceWithStreamingRespon async def download( self, *, - account_id: str, + account_id: str | None = None, limit: str | Omit = omit, logo_id: SequenceNotStr[str] | Omit = omit, offset: str | Omit = omit, @@ -183,10 +187,12 @@ async def download( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/logo-matches/download", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -207,7 +213,7 @@ async def download( async def get( self, *, - account_id: str, + account_id: str | None = None, limit: str | Omit = omit, logo_id: SequenceNotStr[str] | Omit = omit, offset: str | Omit = omit, @@ -230,10 +236,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/logo-matches", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/brand_protection/logos.py b/src/cloudflare/resources/brand_protection/logos.py index fb55402f7e7..a432d1e0fc3 100644 --- a/src/cloudflare/resources/brand_protection/logos.py +++ b/src/cloudflare/resources/brand_protection/logos.py @@ -5,7 +5,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, FileTypes, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -44,7 +44,7 @@ def with_streaming_response(self) -> LogosResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, match_type: str | Omit = omit, tag: str | Omit = omit, threshold: float | Omit = omit, @@ -68,10 +68,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/logos", account_id=account_id), body=maybe_transform({"image": image}, logo_create_params.LogoCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -94,7 +96,7 @@ def delete( self, logo_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -114,13 +116,17 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/brand-protection/logos/{logo_id}", account_id=account_id, logo_id=logo_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -151,7 +157,7 @@ def with_streaming_response(self) -> AsyncLogosResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, match_type: str | Omit = omit, tag: str | Omit = omit, threshold: float | Omit = omit, @@ -175,10 +181,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/logos", account_id=account_id), body=await async_maybe_transform({"image": image}, logo_create_params.LogoCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -201,7 +209,7 @@ async def delete( self, logo_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -221,13 +229,17 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}", + path_template( + "/accounts/{account_id}/brand-protection/logos/{logo_id}", account_id=account_id, logo_id=logo_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/brand_protection/matches.py b/src/cloudflare/resources/brand_protection/matches.py index cf18f113e32..2ab27a7022f 100644 --- a/src/cloudflare/resources/brand_protection/matches.py +++ b/src/cloudflare/resources/brand_protection/matches.py @@ -5,7 +5,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +45,7 @@ def with_streaming_response(self) -> MatchesResourceWithStreamingResponse: def download( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, include_domain_id: bool | Omit = omit, limit: int | Omit = omit, @@ -69,10 +69,12 @@ def download( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/matches/download", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -94,7 +96,7 @@ def download( def get( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, include_domain_id: bool | Omit = omit, limit: int | Omit = omit, @@ -118,10 +120,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/matches", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -164,7 +168,7 @@ def with_streaming_response(self) -> AsyncMatchesResourceWithStreamingResponse: async def download( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, include_domain_id: bool | Omit = omit, limit: int | Omit = omit, @@ -188,10 +192,12 @@ async def download( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/matches/download", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -213,7 +219,7 @@ async def download( async def get( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, include_domain_id: bool | Omit = omit, limit: int | Omit = omit, @@ -237,10 +243,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/matches", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/brand_protection/queries.py b/src/cloudflare/resources/brand_protection/queries.py index 4b7ead75a1c..6d1cbab77d1 100644 --- a/src/cloudflare/resources/brand_protection/queries.py +++ b/src/cloudflare/resources/brand_protection/queries.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +46,7 @@ def with_streaming_response(self) -> QueriesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, query_scan: bool | Omit = omit, query_tag: str | Omit = omit, @@ -74,11 +74,13 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/queries", account_id=account_id), body=maybe_transform( { "max_time": max_time, @@ -109,7 +111,7 @@ def create( def delete( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, scan: bool | Omit = omit, tag: str | Omit = omit, @@ -132,11 +134,13 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/queries", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -157,7 +161,7 @@ def delete( def bulk( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -178,11 +182,13 @@ def bulk( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/queries/bulk", account_id=account_id), 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 @@ -214,7 +220,7 @@ def with_streaming_response(self) -> AsyncQueriesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, query_scan: bool | Omit = omit, query_tag: str | Omit = omit, @@ -242,11 +248,13 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/queries", account_id=account_id), body=await async_maybe_transform( { "max_time": max_time, @@ -277,7 +285,7 @@ async def create( async def delete( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, scan: bool | Omit = omit, tag: str | Omit = omit, @@ -300,11 +308,13 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/queries", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -325,7 +335,7 @@ async def delete( async def bulk( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -346,11 +356,13 @@ async def bulk( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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", + path_template("/accounts/{account_id}/brand-protection/queries/bulk", account_id=account_id), 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 diff --git a/src/cloudflare/resources/brand_protection/v2/logo_matches.py b/src/cloudflare/resources/brand_protection/v2/logo_matches.py index d980660ebdd..ae58cf9010e 100644 --- a/src/cloudflare/resources/brand_protection/v2/logo_matches.py +++ b/src/cloudflare/resources/brand_protection/v2/logo_matches.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +46,7 @@ def with_streaming_response(self) -> LogoMatchesResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, query_id: str, download: str | Omit = omit, limit: str | Omit = omit, @@ -77,10 +77,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/logo/matches", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/matches", account_id=account_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -125,7 +129,7 @@ def with_streaming_response(self) -> AsyncLogoMatchesResourceWithStreamingRespon async def get( self, *, - account_id: str, + account_id: str | None = None, query_id: str, download: str | Omit = omit, limit: str | Omit = omit, @@ -156,10 +160,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/logo/matches", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/matches", account_id=account_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/brand_protection/v2/logos.py b/src/cloudflare/resources/brand_protection/v2/logos.py index 5787bf1bed6..2472996be7e 100644 --- a/src/cloudflare/resources/brand_protection/v2/logos.py +++ b/src/cloudflare/resources/brand_protection/v2/logos.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +46,7 @@ def with_streaming_response(self) -> LogosResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, image_data: str, similarity_threshold: float, tag: str, @@ -80,10 +80,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/logo/queries", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries", account_id=account_id + ), body=maybe_transform( { "image_data": image_data, @@ -103,7 +107,7 @@ def delete( self, query_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -125,12 +129,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not query_id: raise ValueError(f"Expected a non-empty value for `query_id` but received {query_id!r}") return self._delete( - f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries/{query_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries/{query_id}", + account_id=account_id, + query_id=query_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -140,7 +150,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, download: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -169,10 +179,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/logo/queries", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries", account_id=account_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -213,7 +227,7 @@ def with_streaming_response(self) -> AsyncLogosResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, image_data: str, similarity_threshold: float, tag: str, @@ -247,10 +261,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/logo/queries", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries", account_id=account_id + ), body=await async_maybe_transform( { "image_data": image_data, @@ -270,7 +288,7 @@ async def delete( self, query_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -292,12 +310,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not query_id: raise ValueError(f"Expected a non-empty value for `query_id` but received {query_id!r}") return await self._delete( - f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries/{query_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries/{query_id}", + account_id=account_id, + query_id=query_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -307,7 +331,7 @@ async def delete( async def get( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, download: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -336,10 +360,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/logo/queries", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries", account_id=account_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/brand_protection/v2/matches.py b/src/cloudflare/resources/brand_protection/v2/matches.py index 8222b0ec167..aecd7fca0f9 100644 --- a/src/cloudflare/resources/brand_protection/v2/matches.py +++ b/src/cloudflare/resources/brand_protection/v2/matches.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +46,7 @@ def with_streaming_response(self) -> MatchesResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, query_id: SequenceNotStr[str], domain_search: str | Omit = omit, include_dismissed: str | Omit = omit, @@ -86,10 +86,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/domain/matches", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/matches", account_id=account_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -136,7 +140,7 @@ def with_streaming_response(self) -> AsyncMatchesResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, query_id: SequenceNotStr[str], domain_search: str | Omit = omit, include_dismissed: str | Omit = omit, @@ -176,10 +180,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/domain/matches", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/matches", account_id=account_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/brand_protection/v2/queries.py b/src/cloudflare/resources/brand_protection/v2/queries.py index a632d5e3e35..78c84a29b3b 100644 --- a/src/cloudflare/resources/brand_protection/v2/queries.py +++ b/src/cloudflare/resources/brand_protection/v2/queries.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,7 +44,7 @@ def with_streaming_response(self) -> QueriesResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -65,10 +65,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/domain/queries", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/queries", account_id=account_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -103,7 +107,7 @@ def with_streaming_response(self) -> AsyncQueriesResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -124,10 +128,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/v2/brand-protection/domain/queries", + path_template( + "/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/queries", account_id=account_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/browser_rendering/api.md b/src/cloudflare/resources/browser_rendering/api.md new file mode 100644 index 00000000000..c384cdcb32d --- /dev/null +++ b/src/cloudflare/resources/browser_rendering/api.md @@ -0,0 +1,172 @@ +# BrowserRendering + +## Content + +Types: + +```python +from cloudflare.types.browser_rendering import ContentCreateResponse +``` + +Methods: + +- client.browser_rendering.content.create(\*, account_id, \*\*params) -> str + +## PDF + +Methods: + +- client.browser_rendering.pdf.create(\*, account_id, \*\*params) -> BinaryAPIResponse + +## Scrape + +Types: + +```python +from cloudflare.types.browser_rendering import ScrapeCreateResponse +``` + +Methods: + +- client.browser_rendering.scrape.create(\*, account_id, \*\*params) -> ScrapeCreateResponse + +## Screenshot + +Types: + +```python +from cloudflare.types.browser_rendering import ScreenshotCreateResponse +``` + +Methods: + +- client.browser_rendering.screenshot.create(\*, account_id, \*\*params) -> ScreenshotCreateResponse + +## Snapshot + +Types: + +```python +from cloudflare.types.browser_rendering import SnapshotCreateResponse +``` + +Methods: + +- client.browser_rendering.snapshot.create(\*, account_id, \*\*params) -> Optional[SnapshotCreateResponse] + +## Json + +Types: + +```python +from cloudflare.types.browser_rendering import JsonCreateResponse +``` + +Methods: + +- client.browser_rendering.json.create(\*, account_id, \*\*params) -> JsonCreateResponse + +## Links + +Types: + +```python +from cloudflare.types.browser_rendering import LinkCreateResponse +``` + +Methods: + +- client.browser_rendering.links.create(\*, account_id, \*\*params) -> LinkCreateResponse + +## Markdown + +Types: + +```python +from cloudflare.types.browser_rendering import MarkdownCreateResponse +``` + +Methods: + +- client.browser_rendering.markdown.create(\*, account_id, \*\*params) -> str + +## Crawl + +Types: + +```python +from cloudflare.types.browser_rendering import ( + CrawlCreateResponse, + CrawlDeleteResponse, + CrawlGetResponse, +) +``` + +Methods: + +- client.browser_rendering.crawl.create(\*, account_id, \*\*params) -> str +- client.browser_rendering.crawl.delete(job_id, \*, account_id) -> CrawlDeleteResponse +- client.browser_rendering.crawl.get(job_id, \*, account_id, \*\*params) -> CrawlGetResponse + +## Devtools + +### Session + +Types: + +```python +from cloudflare.types.browser_rendering.devtools import SessionListResponse, SessionGetResponse +``` + +Methods: + +- client.browser_rendering.devtools.session.list(\*, account_id, \*\*params) -> SessionListResponse +- client.browser_rendering.devtools.session.get(session_id, \*, account_id) -> Optional[SessionGetResponse] + +### Browser + +Types: + +```python +from cloudflare.types.browser_rendering.devtools import ( + BrowserCreateResponse, + BrowserDeleteResponse, + BrowserProtocolResponse, + BrowserVersionResponse, +) +``` + +Methods: + +- client.browser_rendering.devtools.browser.create(\*, account_id, \*\*params) -> BrowserCreateResponse +- client.browser_rendering.devtools.browser.delete(session_id, \*, account_id) -> BrowserDeleteResponse +- client.browser_rendering.devtools.browser.connect(session_id, \*, account_id, \*\*params) -> None +- client.browser_rendering.devtools.browser.launch(\*, account_id, \*\*params) -> None +- client.browser_rendering.devtools.browser.protocol(session_id, \*, account_id) -> BrowserProtocolResponse +- client.browser_rendering.devtools.browser.version(session_id, \*, account_id) -> BrowserVersionResponse + +#### Page + +Methods: + +- client.browser_rendering.devtools.browser.page.get(target_id, \*, account_id, session_id) -> None + +#### Targets + +Types: + +```python +from cloudflare.types.browser_rendering.devtools.browser import ( + TargetCreateResponse, + TargetListResponse, + TargetActivateResponse, + TargetGetResponse, +) +``` + +Methods: + +- client.browser_rendering.devtools.browser.targets.create(session_id, \*, account_id, \*\*params) -> TargetCreateResponse +- client.browser_rendering.devtools.browser.targets.list(session_id, \*, account_id) -> TargetListResponse +- client.browser_rendering.devtools.browser.targets.activate(target_id, \*, account_id, session_id) -> TargetActivateResponse +- client.browser_rendering.devtools.browser.targets.get(target_id, \*, account_id, session_id) -> TargetGetResponse diff --git a/src/cloudflare/resources/browser_rendering/content.py b/src/cloudflare/resources/browser_rendering/content.py index a70abd0583b..f20bd6e729e 100644 --- a/src/cloudflare/resources/browser_rendering/content.py +++ b/src/cloudflare/resources/browser_rendering/content.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> ContentResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -182,7 +182,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -312,11 +312,11 @@ def create( """ ... - @required_args(["account_id", "url"], ["account_id", "html"]) + @required_args(["url"], ["html"]) def create( self, *, - account_id: str, + account_id: str | None = None, url: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -401,10 +401,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/content", + path_template("/accounts/{account_id}/browser-rendering/content", account_id=account_id), body=maybe_transform( { "url": url, @@ -466,7 +468,7 @@ def with_streaming_response(self) -> AsyncContentResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -599,7 +601,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -729,11 +731,11 @@ async def create( """ ... - @required_args(["account_id", "url"], ["account_id", "html"]) + @required_args(["url"], ["html"]) async def create( self, *, - account_id: str, + account_id: str | None = None, url: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -818,10 +820,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/content", + path_template("/accounts/{account_id}/browser-rendering/content", account_id=account_id), body=await async_maybe_transform( { "url": url, diff --git a/src/cloudflare/resources/browser_rendering/crawl.py b/src/cloudflare/resources/browser_rendering/crawl.py index 1429915bd07..434b45d4b6e 100644 --- a/src/cloudflare/resources/browser_rendering/crawl.py +++ b/src/cloudflare/resources/browser_rendering/crawl.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> CrawlResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -224,7 +224,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, render: Literal[False], url: str, cache_ttl: float | Omit = omit, @@ -297,11 +297,11 @@ def create( """ ... - @required_args(["account_id", "url"], ["account_id", "render", "url"]) + @required_args(["url"], ["render", "url"]) def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -382,10 +382,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/crawl", + path_template("/accounts/{account_id}/browser-rendering/crawl", account_id=account_id), body=maybe_transform( { "url": url, @@ -434,7 +436,7 @@ def delete( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -459,12 +461,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return self._delete( - f"/accounts/{account_id}/browser-rendering/crawl/{job_id}", + path_template( + "/accounts/{account_id}/browser-rendering/crawl/{job_id}", account_id=account_id, job_id=job_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -479,7 +485,7 @@ def get( self, job_id: str, *, - account_id: str, + account_id: str | None = None, cache_ttl: float | Omit = omit, cursor: float | Omit = omit, limit: float | Omit = omit, @@ -515,12 +521,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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}/browser-rendering/crawl/{job_id}", + path_template( + "/accounts/{account_id}/browser-rendering/crawl/{job_id}", account_id=account_id, job_id=job_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -565,7 +575,7 @@ def with_streaming_response(self) -> AsyncCrawlResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -738,7 +748,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, render: Literal[False], url: str, cache_ttl: float | Omit = omit, @@ -811,11 +821,11 @@ async def create( """ ... - @required_args(["account_id", "url"], ["account_id", "render", "url"]) + @required_args(["url"], ["render", "url"]) async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -896,10 +906,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/crawl", + path_template("/accounts/{account_id}/browser-rendering/crawl", account_id=account_id), body=await async_maybe_transform( { "url": url, @@ -948,7 +960,7 @@ async def delete( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -973,12 +985,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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._delete( - f"/accounts/{account_id}/browser-rendering/crawl/{job_id}", + path_template( + "/accounts/{account_id}/browser-rendering/crawl/{job_id}", account_id=account_id, job_id=job_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -993,7 +1009,7 @@ async def get( self, job_id: str, *, - account_id: str, + account_id: str | None = None, cache_ttl: float | Omit = omit, cursor: float | Omit = omit, limit: float | Omit = omit, @@ -1029,12 +1045,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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}/browser-rendering/crawl/{job_id}", + path_template( + "/accounts/{account_id}/browser-rendering/crawl/{job_id}", account_id=account_id, job_id=job_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/browser_rendering/devtools/browser/browser.py b/src/cloudflare/resources/browser_rendering/devtools/browser/browser.py index 9d1d313f4db..923aa11e68c 100644 --- a/src/cloudflare/resources/browser_rendering/devtools/browser/browser.py +++ b/src/cloudflare/resources/browser_rendering/devtools/browser/browser.py @@ -21,7 +21,7 @@ AsyncTargetsResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -71,7 +71,7 @@ def with_streaming_response(self) -> BrowserResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, keep_alive: float | Omit = omit, lab: bool | Omit = omit, recording: bool | Omit = omit, @@ -103,10 +103,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/devtools/browser", + path_template("/accounts/{account_id}/browser-rendering/devtools/browser", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -129,7 +131,7 @@ def delete( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -153,12 +155,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._delete( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -169,7 +177,7 @@ def connect( self, session_id: str, *, - account_id: str, + account_id: str | None = None, keep_alive: float | Omit = omit, lab: bool | Omit = omit, recording: bool | Omit = omit, @@ -200,13 +208,19 @@ def connect( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -227,7 +241,7 @@ def connect( def launch( self, *, - account_id: str, + account_id: str | None = None, keep_alive: float | Omit = omit, lab: bool | Omit = omit, recording: bool | Omit = omit, @@ -256,11 +270,13 @@ def launch( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser", + path_template("/accounts/{account_id}/browser-rendering/devtools/browser", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -282,7 +298,7 @@ def protocol( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -307,12 +323,18 @@ def protocol( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/protocol", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/protocol", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -323,7 +345,7 @@ def version( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -347,12 +369,18 @@ def version( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/version", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/version", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -391,7 +419,7 @@ def with_streaming_response(self) -> AsyncBrowserResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, keep_alive: float | Omit = omit, lab: bool | Omit = omit, recording: bool | Omit = omit, @@ -423,10 +451,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/devtools/browser", + path_template("/accounts/{account_id}/browser-rendering/devtools/browser", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -449,7 +479,7 @@ async def delete( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -473,12 +503,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._delete( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -489,7 +525,7 @@ async def connect( self, session_id: str, *, - account_id: str, + account_id: str | None = None, keep_alive: float | Omit = omit, lab: bool | Omit = omit, recording: bool | Omit = omit, @@ -520,13 +556,19 @@ async def connect( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -547,7 +589,7 @@ async def connect( async def launch( self, *, - account_id: str, + account_id: str | None = None, keep_alive: float | Omit = omit, lab: bool | Omit = omit, recording: bool | Omit = omit, @@ -576,11 +618,13 @@ async def launch( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser", + path_template("/accounts/{account_id}/browser-rendering/devtools/browser", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -602,7 +646,7 @@ async def protocol( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -627,12 +671,18 @@ async def protocol( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/protocol", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/protocol", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -643,7 +693,7 @@ async def version( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -667,12 +717,18 @@ async def version( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/version", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/version", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/browser_rendering/devtools/browser/page.py b/src/cloudflare/resources/browser_rendering/devtools/browser/page.py index 00a89b3c25b..3720014b6c2 100644 --- a/src/cloudflare/resources/browser_rendering/devtools/browser/page.py +++ b/src/cloudflare/resources/browser_rendering/devtools/browser/page.py @@ -5,6 +5,7 @@ import httpx from ....._types import Body, Query, Headers, NoneType, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -42,7 +43,7 @@ def get( self, target_id: str, *, - account_id: str, + account_id: str | None = None, session_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. @@ -69,6 +70,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: @@ -77,7 +80,12 @@ def get( raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/page/{target_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/page/{target_id}", + account_id=account_id, + session_id=session_id, + target_id=target_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -109,7 +117,7 @@ async def get( self, target_id: str, *, - account_id: str, + account_id: str | None = None, session_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. @@ -136,6 +144,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: @@ -144,7 +154,12 @@ async def get( raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/page/{target_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/page/{target_id}", + account_id=account_id, + session_id=session_id, + target_id=target_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/browser_rendering/devtools/browser/targets.py b/src/cloudflare/resources/browser_rendering/devtools/browser/targets.py index 5f3c50e6581..b35af4ac91d 100644 --- a/src/cloudflare/resources/browser_rendering/devtools/browser/targets.py +++ b/src/cloudflare/resources/browser_rendering/devtools/browser/targets.py @@ -5,7 +5,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,7 +48,7 @@ def create( self, session_id: str, *, - account_id: str, + account_id: str | None = None, url: 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. @@ -74,12 +74,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._put( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/new", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/new", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -94,7 +100,7 @@ def list( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -119,12 +125,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -135,7 +147,7 @@ def activate( self, target_id: str, *, - account_id: str, + account_id: str | None = None, session_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. @@ -162,6 +174,8 @@ def activate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: @@ -169,7 +183,12 @@ def activate( if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") return self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/activate/{target_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/activate/{target_id}", + account_id=account_id, + session_id=session_id, + target_id=target_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -180,7 +199,7 @@ def get( self, target_id: str, *, - account_id: str, + account_id: str | None = None, session_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. @@ -207,6 +226,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: @@ -214,7 +235,12 @@ def get( if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") return self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list/{target_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list/{target_id}", + account_id=account_id, + session_id=session_id, + target_id=target_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -246,7 +272,7 @@ async def create( self, session_id: str, *, - account_id: str, + account_id: str | None = None, url: 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. @@ -272,12 +298,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._put( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/new", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/new", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -292,7 +324,7 @@ async def list( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -317,12 +349,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -333,7 +371,7 @@ async def activate( self, target_id: str, *, - account_id: str, + account_id: str | None = None, session_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. @@ -360,6 +398,8 @@ async def activate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: @@ -367,7 +407,12 @@ async def activate( if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") return await self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/activate/{target_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/activate/{target_id}", + account_id=account_id, + session_id=session_id, + target_id=target_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -378,7 +423,7 @@ async def get( self, target_id: str, *, - account_id: str, + account_id: str | None = None, session_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. @@ -405,6 +450,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: @@ -412,7 +459,12 @@ async def get( if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") return await self._get( - f"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list/{target_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list/{target_id}", + account_id=account_id, + session_id=session_id, + target_id=target_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/browser_rendering/devtools/session.py b/src/cloudflare/resources/browser_rendering/devtools/session.py index 55a2143a8e2..143c06efdc2 100644 --- a/src/cloudflare/resources/browser_rendering/devtools/session.py +++ b/src/cloudflare/resources/browser_rendering/devtools/session.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> SessionResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, limit: float | Omit = omit, offset: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -71,10 +71,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/devtools/session", + path_template("/accounts/{account_id}/browser-rendering/devtools/session", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -95,7 +97,7 @@ def get( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -119,12 +121,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._get( - f"/accounts/{account_id}/browser-rendering/devtools/session/{session_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/session/{session_id}", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -155,7 +163,7 @@ def with_streaming_response(self) -> AsyncSessionResourceWithStreamingResponse: async def list( self, *, - account_id: str, + account_id: str | None = None, limit: float | Omit = omit, offset: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -179,10 +187,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/devtools/session", + path_template("/accounts/{account_id}/browser-rendering/devtools/session", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -203,7 +213,7 @@ async def get( self, session_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -227,12 +237,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._get( - f"/accounts/{account_id}/browser-rendering/devtools/session/{session_id}", + path_template( + "/accounts/{account_id}/browser-rendering/devtools/session/{session_id}", + account_id=account_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/browser_rendering/json.py b/src/cloudflare/resources/browser_rendering/json.py index 4b3a53903f5..8c6999290d3 100644 --- a/src/cloudflare/resources/browser_rendering/json.py +++ b/src/cloudflare/resources/browser_rendering/json.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> JsonResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -190,7 +190,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -326,11 +326,11 @@ def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -418,10 +418,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JsonCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/json", + path_template("/accounts/{account_id}/browser-rendering/json", account_id=account_id), body=maybe_transform( { "html": html, @@ -486,7 +488,7 @@ def with_streaming_response(self) -> AsyncJsonResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -627,7 +629,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -763,11 +765,11 @@ async def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) async def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -855,10 +857,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JsonCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/json", + path_template("/accounts/{account_id}/browser-rendering/json", account_id=account_id), body=await async_maybe_transform( { "html": html, diff --git a/src/cloudflare/resources/browser_rendering/links.py b/src/cloudflare/resources/browser_rendering/links.py index 29c43034e29..886765f77df 100644 --- a/src/cloudflare/resources/browser_rendering/links.py +++ b/src/cloudflare/resources/browser_rendering/links.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> LinksResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -183,7 +183,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -312,11 +312,11 @@ def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -399,10 +399,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> LinkCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/links", + path_template("/accounts/{account_id}/browser-rendering/links", account_id=account_id), body=maybe_transform( { "html": html, @@ -466,7 +468,7 @@ def with_streaming_response(self) -> AsyncLinksResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -600,7 +602,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -729,11 +731,11 @@ async def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) async def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -816,10 +818,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> LinkCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/links", + path_template("/accounts/{account_id}/browser-rendering/links", account_id=account_id), body=await async_maybe_transform( { "html": html, diff --git a/src/cloudflare/resources/browser_rendering/markdown.py b/src/cloudflare/resources/browser_rendering/markdown.py index ff7768753ca..b3c9acffbf9 100644 --- a/src/cloudflare/resources/browser_rendering/markdown.py +++ b/src/cloudflare/resources/browser_rendering/markdown.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> MarkdownResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -182,7 +182,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -312,11 +312,11 @@ def create( """ ... - @required_args(["account_id", "url"], ["account_id", "html"]) + @required_args(["url"], ["html"]) def create( self, *, - account_id: str, + account_id: str | None = None, url: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -401,10 +401,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/markdown", + path_template("/accounts/{account_id}/browser-rendering/markdown", account_id=account_id), body=maybe_transform( { "url": url, @@ -466,7 +468,7 @@ def with_streaming_response(self) -> AsyncMarkdownResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -599,7 +601,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -729,11 +731,11 @@ async def create( """ ... - @required_args(["account_id", "url"], ["account_id", "html"]) + @required_args(["url"], ["html"]) async def create( self, *, - account_id: str, + account_id: str | None = None, url: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -818,10 +820,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/markdown", + path_template("/accounts/{account_id}/browser-rendering/markdown", account_id=account_id), body=await async_maybe_transform( { "url": url, diff --git a/src/cloudflare/resources/browser_rendering/pdf.py b/src/cloudflare/resources/browser_rendering/pdf.py index 4ecf823abd4..94b10940a88 100644 --- a/src/cloudflare/resources/browser_rendering/pdf.py +++ b/src/cloudflare/resources/browser_rendering/pdf.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> PDFResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -188,7 +188,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -320,11 +320,11 @@ def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -404,11 +404,13 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BinaryAPIResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {"Accept": "application/pdf", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/browser-rendering/pdf", + path_template("/accounts/{account_id}/browser-rendering/pdf", account_id=account_id), body=maybe_transform( { "html": html, @@ -470,7 +472,7 @@ def with_streaming_response(self) -> AsyncPDFResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -607,7 +609,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -739,11 +741,11 @@ async def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) async def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -823,11 +825,13 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncBinaryAPIResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {"Accept": "application/pdf", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/browser-rendering/pdf", + path_template("/accounts/{account_id}/browser-rendering/pdf", account_id=account_id), body=await async_maybe_transform( { "html": html, diff --git a/src/cloudflare/resources/browser_rendering/scrape.py b/src/cloudflare/resources/browser_rendering/scrape.py index 05c5e3f1bc6..1447254c86e 100644 --- a/src/cloudflare/resources/browser_rendering/scrape.py +++ b/src/cloudflare/resources/browser_rendering/scrape.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> ScrapeResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, elements: Iterable[scrape_create_params.Variant0Element], html: str, cache_ttl: float | Omit = omit, @@ -182,7 +182,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, elements: Iterable[scrape_create_params.Variant1Element], url: str, cache_ttl: float | Omit = omit, @@ -310,11 +310,11 @@ def create( """ ... - @required_args(["account_id", "elements", "html"], ["account_id", "elements", "url"]) + @required_args(["elements", "html"], ["elements", "url"]) def create( self, *, - account_id: str, + account_id: str | None = None, elements: Iterable[scrape_create_params.Variant0Element] | Iterable[scrape_create_params.Variant1Element], html: str | Omit = omit, cache_ttl: float | Omit = omit, @@ -398,10 +398,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ScrapeCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/scrape", + path_template("/accounts/{account_id}/browser-rendering/scrape", account_id=account_id), body=maybe_transform( { "elements": elements, @@ -464,7 +466,7 @@ def with_streaming_response(self) -> AsyncScrapeResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, elements: Iterable[scrape_create_params.Variant0Element], html: str, cache_ttl: float | Omit = omit, @@ -597,7 +599,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, elements: Iterable[scrape_create_params.Variant1Element], url: str, cache_ttl: float | Omit = omit, @@ -725,11 +727,11 @@ async def create( """ ... - @required_args(["account_id", "elements", "html"], ["account_id", "elements", "url"]) + @required_args(["elements", "html"], ["elements", "url"]) async def create( self, *, - account_id: str, + account_id: str | None = None, elements: Iterable[scrape_create_params.Variant0Element] | Iterable[scrape_create_params.Variant1Element], html: str | Omit = omit, cache_ttl: float | Omit = omit, @@ -813,10 +815,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ScrapeCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/scrape", + path_template("/accounts/{account_id}/browser-rendering/scrape", account_id=account_id), body=await async_maybe_transform( { "elements": elements, diff --git a/src/cloudflare/resources/browser_rendering/screenshot.py b/src/cloudflare/resources/browser_rendering/screenshot.py index b5a89b5bee3..dc9b8c3d4ad 100644 --- a/src/cloudflare/resources/browser_rendering/screenshot.py +++ b/src/cloudflare/resources/browser_rendering/screenshot.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> ScreenshotResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -188,7 +188,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -323,11 +323,11 @@ def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -417,10 +417,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ScreenshotCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/screenshot", + path_template("/accounts/{account_id}/browser-rendering/screenshot", account_id=account_id), body=maybe_transform( { "html": html, @@ -484,7 +486,7 @@ def with_streaming_response(self) -> AsyncScreenshotResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -624,7 +626,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -759,11 +761,11 @@ async def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) async def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -853,10 +855,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ScreenshotCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/screenshot", + path_template("/accounts/{account_id}/browser-rendering/screenshot", account_id=account_id), body=await async_maybe_transform( { "html": html, diff --git a/src/cloudflare/resources/browser_rendering/snapshot.py b/src/cloudflare/resources/browser_rendering/snapshot.py index 6326f67114f..14c959ef1fa 100644 --- a/src/cloudflare/resources/browser_rendering/snapshot.py +++ b/src/cloudflare/resources/browser_rendering/snapshot.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> SnapshotResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -185,7 +185,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -316,11 +316,11 @@ def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -408,10 +408,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[SnapshotCreateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/snapshot", + path_template("/accounts/{account_id}/browser-rendering/snapshot", account_id=account_id), body=maybe_transform( { "html": html, @@ -474,7 +476,7 @@ def with_streaming_response(self) -> AsyncSnapshotResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, html: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -610,7 +612,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -741,11 +743,11 @@ async def create( """ ... - @required_args(["account_id", "html"], ["account_id", "url"]) + @required_args(["html"], ["url"]) async def create( self, *, - account_id: str, + account_id: str | None = None, html: str | Omit = omit, cache_ttl: float | Omit = omit, action_timeout: float | Omit = omit, @@ -833,10 +835,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[SnapshotCreateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/browser-rendering/snapshot", + path_template("/accounts/{account_id}/browser-rendering/snapshot", account_id=account_id), body=await async_maybe_transform( { "html": html, diff --git a/src/cloudflare/resources/cache/api.md b/src/cloudflare/resources/cache/api.md new file mode 100644 index 00000000000..aa7b9c376b3 --- /dev/null +++ b/src/cloudflare/resources/cache/api.md @@ -0,0 +1,88 @@ +# Cache + +Types: + +```python +from cloudflare.types.cache import CachePurgeResponse +``` + +Methods: + +- client.cache.purge(\*, zone_id, \*\*params) -> Optional[CachePurgeResponse] + +## CacheReserve + +Types: + +```python +from cloudflare.types.cache import ( + CacheReserve, + CacheReserveClear, + State, + CacheReserveClearResponse, + CacheReserveEditResponse, + CacheReserveGetResponse, + CacheReserveStatusResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.cache import ( + SmartTieredCacheDeleteResponse, + SmartTieredCacheEditResponse, + SmartTieredCacheGetResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.cache import ( + CacheVariant, + VariantDeleteResponse, + VariantEditResponse, + VariantGetResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.cache import ( + RegionalTieredCache, + RegionalTieredCacheEditResponse, + RegionalTieredCacheGetResponse, +) +``` + +Methods: + +- client.cache.regional_tiered_cache.edit(\*, zone_id, \*\*params) -> Optional[RegionalTieredCacheEditResponse] +- client.cache.regional_tiered_cache.get(\*, zone_id) -> Optional[RegionalTieredCacheGetResponse] diff --git a/src/cloudflare/resources/cache/cache.py b/src/cloudflare/resources/cache/cache.py index 832b66a1363..140c5cce06f 100644 --- a/src/cloudflare/resources/cache/cache.py +++ b/src/cloudflare/resources/cache/cache.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, maybe_transform, async_maybe_transform from .variants import ( VariantsResource, AsyncVariantsResource, @@ -97,7 +97,7 @@ def with_streaming_response(self) -> CacheResourceWithStreamingResponse: def purge( self, *, - zone_id: str, + zone_id: str | None = None, tags: 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. @@ -199,7 +199,7 @@ def purge( def purge( self, *, - zone_id: str, + zone_id: str | None = None, hosts: 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. @@ -301,7 +301,7 @@ def purge( def purge( self, *, - zone_id: str, + zone_id: str | None = None, prefixes: 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. @@ -403,7 +403,7 @@ def purge( def purge( self, *, - zone_id: str, + zone_id: str | None = None, purge_everything: 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. @@ -505,7 +505,7 @@ def purge( def purge( self, *, - zone_id: str, + zone_id: str | None = None, files: 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. @@ -607,7 +607,7 @@ def purge( def purge( self, *, - zone_id: str, + zone_id: str | None = None, files: Iterable[cache_purge_params.CachePurgeSingleFileWithURLAndHeadersFile] | 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. @@ -705,11 +705,10 @@ def purge( """ ... - @required_args(["zone_id"]) def purge( self, *, - zone_id: str, + zone_id: str | None = None, tags: SequenceNotStr[str] | Omit = omit, hosts: SequenceNotStr[str] | Omit = omit, prefixes: SequenceNotStr[str] | Omit = omit, @@ -724,10 +723,12 @@ def purge( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[CachePurgeResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/purge_cache", + path_template("/zones/{zone_id}/purge_cache", zone_id=zone_id), body=maybe_transform( { "tags": tags, @@ -789,7 +790,7 @@ def with_streaming_response(self) -> AsyncCacheResourceWithStreamingResponse: async def purge( self, *, - zone_id: str, + zone_id: str | None = None, tags: 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. @@ -891,7 +892,7 @@ async def purge( async def purge( self, *, - zone_id: str, + zone_id: str | None = None, hosts: 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. @@ -993,7 +994,7 @@ async def purge( async def purge( self, *, - zone_id: str, + zone_id: str | None = None, prefixes: 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. @@ -1095,7 +1096,7 @@ async def purge( async def purge( self, *, - zone_id: str, + zone_id: str | None = None, purge_everything: 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. @@ -1197,7 +1198,7 @@ async def purge( async def purge( self, *, - zone_id: str, + zone_id: str | None = None, files: 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. @@ -1299,7 +1300,7 @@ async def purge( async def purge( self, *, - zone_id: str, + zone_id: str | None = None, files: Iterable[cache_purge_params.CachePurgeSingleFileWithURLAndHeadersFile] | 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. @@ -1397,11 +1398,10 @@ async def purge( """ ... - @required_args(["zone_id"]) async def purge( self, *, - zone_id: str, + zone_id: str | None = None, tags: SequenceNotStr[str] | Omit = omit, hosts: SequenceNotStr[str] | Omit = omit, prefixes: SequenceNotStr[str] | Omit = omit, @@ -1416,10 +1416,12 @@ async def purge( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[CachePurgeResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/purge_cache", + path_template("/zones/{zone_id}/purge_cache", zone_id=zone_id), body=await async_maybe_transform( { "tags": tags, diff --git a/src/cloudflare/resources/cache/cache_reserve.py b/src/cloudflare/resources/cache/cache_reserve.py index f4196a32033..e937dee80c0 100644 --- a/src/cloudflare/resources/cache/cache_reserve.py +++ b/src/cloudflare/resources/cache/cache_reserve.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> CacheReserveResourceWithStreamingResponse: def clear( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -77,10 +77,12 @@ def clear( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/cache_reserve_clear", + path_template("/zones/{zone_id}/cache/cache_reserve_clear", zone_id=zone_id), body=maybe_transform(body, cache_reserve_clear_params.CacheReserveClearParams), options=make_request_options( extra_headers=extra_headers, @@ -95,7 +97,7 @@ def clear( def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -125,10 +127,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/cache_reserve", + path_template("/zones/{zone_id}/cache/cache_reserve", zone_id=zone_id), body=maybe_transform({"value": value}, cache_reserve_edit_params.CacheReserveEditParams), options=make_request_options( extra_headers=extra_headers, @@ -143,7 +147,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -170,10 +174,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/cache/cache_reserve", + path_template("/zones/{zone_id}/cache/cache_reserve", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -187,7 +193,7 @@ def get( def status( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -212,10 +218,12 @@ def status( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/cache/cache_reserve_clear", + path_template("/zones/{zone_id}/cache/cache_reserve_clear", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -250,7 +258,7 @@ def with_streaming_response(self) -> AsyncCacheReserveResourceWithStreamingRespo async def clear( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -276,10 +284,12 @@ async def clear( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/cache_reserve_clear", + path_template("/zones/{zone_id}/cache/cache_reserve_clear", zone_id=zone_id), body=await async_maybe_transform(body, cache_reserve_clear_params.CacheReserveClearParams), options=make_request_options( extra_headers=extra_headers, @@ -294,7 +304,7 @@ async def clear( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -324,10 +334,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/cache_reserve", + path_template("/zones/{zone_id}/cache/cache_reserve", zone_id=zone_id), body=await async_maybe_transform({"value": value}, cache_reserve_edit_params.CacheReserveEditParams), options=make_request_options( extra_headers=extra_headers, @@ -342,7 +354,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -369,10 +381,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/cache/cache_reserve", + path_template("/zones/{zone_id}/cache/cache_reserve", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -386,7 +400,7 @@ async def get( async def status( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -411,10 +425,12 @@ async def status( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/cache/cache_reserve_clear", + path_template("/zones/{zone_id}/cache/cache_reserve_clear", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cache/regional_tiered_cache.py b/src/cloudflare/resources/cache/regional_tiered_cache.py index f70da5cadcb..50c9c874555 100644 --- a/src/cloudflare/resources/cache/regional_tiered_cache.py +++ b/src/cloudflare/resources/cache/regional_tiered_cache.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> RegionalTieredCacheResourceWithStreamingRes def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -76,10 +76,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/regional_tiered_cache", + path_template("/zones/{zone_id}/cache/regional_tiered_cache", zone_id=zone_id), body=maybe_transform({"value": value}, regional_tiered_cache_edit_params.RegionalTieredCacheEditParams), options=make_request_options( extra_headers=extra_headers, @@ -96,7 +98,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -120,10 +122,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/cache/regional_tiered_cache", + path_template("/zones/{zone_id}/cache/regional_tiered_cache", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -158,7 +162,7 @@ def with_streaming_response(self) -> AsyncRegionalTieredCacheResourceWithStreami async def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -185,10 +189,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/regional_tiered_cache", + path_template("/zones/{zone_id}/cache/regional_tiered_cache", zone_id=zone_id), body=await async_maybe_transform( {"value": value}, regional_tiered_cache_edit_params.RegionalTieredCacheEditParams ), @@ -207,7 +213,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -231,10 +237,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/cache/regional_tiered_cache", + path_template("/zones/{zone_id}/cache/regional_tiered_cache", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cache/smart_tiered_cache.py b/src/cloudflare/resources/cache/smart_tiered_cache.py index f9eefc2f36f..0542a3dff65 100644 --- a/src/cloudflare/resources/cache/smart_tiered_cache.py +++ b/src/cloudflare/resources/cache/smart_tiered_cache.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> SmartTieredCacheResourceWithStreamingRespon def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -77,10 +77,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/tiered_cache_smart_topology_enable", + path_template("/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -94,7 +96,7 @@ def delete( def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -124,10 +126,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/tiered_cache_smart_topology_enable", + path_template("/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", zone_id=zone_id), body=maybe_transform({"value": value}, smart_tiered_cache_edit_params.SmartTieredCacheEditParams), options=make_request_options( extra_headers=extra_headers, @@ -142,7 +146,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -169,10 +173,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", + path_template("/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -207,7 +213,7 @@ def with_streaming_response(self) -> AsyncSmartTieredCacheResourceWithStreamingR async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -234,10 +240,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/tiered_cache_smart_topology_enable", + path_template("/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -251,7 +259,7 @@ async def delete( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["on", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -281,10 +289,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/tiered_cache_smart_topology_enable", + path_template("/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", zone_id=zone_id), body=await async_maybe_transform( {"value": value}, smart_tiered_cache_edit_params.SmartTieredCacheEditParams ), @@ -301,7 +311,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -328,10 +338,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", + path_template("/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cache/variants.py b/src/cloudflare/resources/cache/variants.py index a263f6997d4..e9c160ae31c 100644 --- a/src/cloudflare/resources/cache/variants.py +++ b/src/cloudflare/resources/cache/variants.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> VariantsResourceWithStreamingResponse: def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -75,10 +75,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/variants", + path_template("/zones/{zone_id}/cache/variants", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -92,7 +94,7 @@ def delete( def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: variant_edit_params.Value, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -121,10 +123,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/variants", + path_template("/zones/{zone_id}/cache/variants", zone_id=zone_id), body=maybe_transform({"value": value}, variant_edit_params.VariantEditParams), options=make_request_options( extra_headers=extra_headers, @@ -139,7 +143,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -165,10 +169,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/cache/variants", + path_template("/zones/{zone_id}/cache/variants", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -203,7 +209,7 @@ def with_streaming_response(self) -> AsyncVariantsResourceWithStreamingResponse: async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -229,10 +235,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/variants", + path_template("/zones/{zone_id}/cache/variants", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -246,7 +254,7 @@ async def delete( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, value: variant_edit_params.Value, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -275,10 +283,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cache/variants", + path_template("/zones/{zone_id}/cache/variants", zone_id=zone_id), body=await async_maybe_transform({"value": value}, variant_edit_params.VariantEditParams), options=make_request_options( extra_headers=extra_headers, @@ -293,7 +303,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -319,10 +329,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/cache/variants", + path_template("/zones/{zone_id}/cache/variants", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/calls/api.md b/src/cloudflare/resources/calls/api.md new file mode 100644 index 00000000000..44df8a15f22 --- /dev/null +++ b/src/cloudflare/resources/calls/api.md @@ -0,0 +1,45 @@ +# Calls + +## SFU + +Types: + +```python +from cloudflare.types.calls import ( + SFUCreateResponse, + SFUUpdateResponse, + SFUListResponse, + SFUDeleteResponse, + SFUGetResponse, +) +``` + +Methods: + +- 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] + +## TURN + +Types: + +```python +from cloudflare.types.calls import ( + TURNCreateResponse, + TURNUpdateResponse, + TURNListResponse, + TURNDeleteResponse, + TURNGetResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/calls/sfu.py b/src/cloudflare/resources/calls/sfu.py index 822b9a37002..9898a2c3d6b 100644 --- a/src/cloudflare/resources/calls/sfu.py +++ b/src/cloudflare/resources/calls/sfu.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> SFUResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -79,10 +79,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/calls/apps", + path_template("/accounts/{account_id}/calls/apps", account_id=account_id), body=maybe_transform({"name": name}, sfu_create_params.SFUCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -98,7 +100,7 @@ def update( self, app_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -125,12 +127,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._put( - f"/accounts/{account_id}/calls/apps/{app_id}", + path_template("/accounts/{account_id}/calls/apps/{app_id}", account_id=account_id, app_id=app_id), body=maybe_transform({"name": name}, sfu_update_params.SFUUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -145,7 +149,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -167,10 +171,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/calls/apps", + path_template("/accounts/{account_id}/calls/apps", account_id=account_id), page=SyncSinglePage[SFUListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -182,7 +188,7 @@ def delete( self, app_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -206,12 +212,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._delete( - f"/accounts/{account_id}/calls/apps/{app_id}", + path_template("/accounts/{account_id}/calls/apps/{app_id}", account_id=account_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -226,7 +234,7 @@ def get( self, app_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -250,12 +258,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/calls/apps/{app_id}", + path_template("/accounts/{account_id}/calls/apps/{app_id}", account_id=account_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -290,7 +300,7 @@ def with_streaming_response(self) -> AsyncSFUResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -317,10 +327,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/calls/apps", + path_template("/accounts/{account_id}/calls/apps", account_id=account_id), body=await async_maybe_transform({"name": name}, sfu_create_params.SFUCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -336,7 +348,7 @@ async def update( self, app_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -363,12 +375,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._put( - f"/accounts/{account_id}/calls/apps/{app_id}", + path_template("/accounts/{account_id}/calls/apps/{app_id}", account_id=account_id, app_id=app_id), body=await async_maybe_transform({"name": name}, sfu_update_params.SFUUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -383,7 +397,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -405,10 +419,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/calls/apps", + path_template("/accounts/{account_id}/calls/apps", account_id=account_id), page=AsyncSinglePage[SFUListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -420,7 +436,7 @@ async def delete( self, app_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -444,12 +460,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._delete( - f"/accounts/{account_id}/calls/apps/{app_id}", + path_template("/accounts/{account_id}/calls/apps/{app_id}", account_id=account_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -464,7 +482,7 @@ async def get( self, app_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -488,12 +506,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/calls/apps/{app_id}", + path_template("/accounts/{account_id}/calls/apps/{app_id}", account_id=account_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/calls/turn.py b/src/cloudflare/resources/calls/turn.py index fd7479532c0..06ec7497e05 100644 --- a/src/cloudflare/resources/calls/turn.py +++ b/src/cloudflare/resources/calls/turn.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> TURNResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -77,10 +77,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/calls/turn_keys", + path_template("/accounts/{account_id}/calls/turn_keys", account_id=account_id), body=maybe_transform({"name": name}, turn_create_params.TURNCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -96,7 +98,7 @@ def update( self, key_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -123,12 +125,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not key_id: raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") return self._put( - f"/accounts/{account_id}/calls/turn_keys/{key_id}", + path_template("/accounts/{account_id}/calls/turn_keys/{key_id}", account_id=account_id, key_id=key_id), body=maybe_transform({"name": name}, turn_update_params.TURNUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -143,7 +147,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -165,10 +169,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/calls/turn_keys", + path_template("/accounts/{account_id}/calls/turn_keys", account_id=account_id), page=SyncSinglePage[TURNListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -180,7 +186,7 @@ def delete( self, key_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -204,12 +210,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not key_id: raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") return self._delete( - f"/accounts/{account_id}/calls/turn_keys/{key_id}", + path_template("/accounts/{account_id}/calls/turn_keys/{key_id}", account_id=account_id, key_id=key_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -224,7 +232,7 @@ def get( self, key_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -248,12 +256,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not key_id: raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") return self._get( - f"/accounts/{account_id}/calls/turn_keys/{key_id}", + path_template("/accounts/{account_id}/calls/turn_keys/{key_id}", account_id=account_id, key_id=key_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -288,7 +298,7 @@ def with_streaming_response(self) -> AsyncTURNResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -313,10 +323,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/calls/turn_keys", + path_template("/accounts/{account_id}/calls/turn_keys", account_id=account_id), body=await async_maybe_transform({"name": name}, turn_create_params.TURNCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -332,7 +344,7 @@ async def update( self, key_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -359,12 +371,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not key_id: raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") return await self._put( - f"/accounts/{account_id}/calls/turn_keys/{key_id}", + path_template("/accounts/{account_id}/calls/turn_keys/{key_id}", account_id=account_id, key_id=key_id), body=await async_maybe_transform({"name": name}, turn_update_params.TURNUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -379,7 +393,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -401,10 +415,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/calls/turn_keys", + path_template("/accounts/{account_id}/calls/turn_keys", account_id=account_id), page=AsyncSinglePage[TURNListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -416,7 +432,7 @@ async def delete( self, key_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -440,12 +456,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not key_id: raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") return await self._delete( - f"/accounts/{account_id}/calls/turn_keys/{key_id}", + path_template("/accounts/{account_id}/calls/turn_keys/{key_id}", account_id=account_id, key_id=key_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -460,7 +478,7 @@ async def get( self, key_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -484,12 +502,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not key_id: raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") return await self._get( - f"/accounts/{account_id}/calls/turn_keys/{key_id}", + path_template("/accounts/{account_id}/calls/turn_keys/{key_id}", account_id=account_id, key_id=key_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/certificate_authorities/api.md b/src/cloudflare/resources/certificate_authorities/api.md new file mode 100644 index 00000000000..b04f13930f3 --- /dev/null +++ b/src/cloudflare/resources/certificate_authorities/api.md @@ -0,0 +1,19 @@ +# CertificateAuthorities + +## HostnameAssociations + +Types: + +```python +from cloudflare.types.certificate_authorities import ( + HostnameAssociation, + TLSHostnameAssociation, + HostnameAssociationUpdateResponse, + HostnameAssociationGetResponse, +) +``` + +Methods: + +- client.certificate_authorities.hostname_associations.update(\*, zone_id, \*\*params) -> Optional[HostnameAssociationUpdateResponse] +- client.certificate_authorities.hostname_associations.get(\*, zone_id, \*\*params) -> Optional[HostnameAssociationGetResponse] diff --git a/src/cloudflare/resources/certificate_authorities/hostname_associations.py b/src/cloudflare/resources/certificate_authorities/hostname_associations.py index 6c525f63bca..8ae6c3e093e 100644 --- a/src/cloudflare/resources/certificate_authorities/hostname_associations.py +++ b/src/cloudflare/resources/certificate_authorities/hostname_associations.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> HostnameAssociationsResourceWithStreamingRe def update( self, *, - zone_id: str, + zone_id: str | None = None, hostnames: SequenceNotStr[HostnameAssociation] | Omit = omit, mtls_certificate_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,10 +77,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/certificate_authorities/hostname_associations", + path_template("/zones/{zone_id}/certificate_authorities/hostname_associations", zone_id=zone_id), body=maybe_transform( { "hostnames": hostnames, @@ -103,7 +105,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, mtls_certificate_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. @@ -130,10 +132,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/certificate_authorities/hostname_associations", + path_template("/zones/{zone_id}/certificate_authorities/hostname_associations", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -172,7 +176,7 @@ def with_streaming_response(self) -> AsyncHostnameAssociationsResourceWithStream async def update( self, *, - zone_id: str, + zone_id: str | None = None, hostnames: SequenceNotStr[HostnameAssociation] | Omit = omit, mtls_certificate_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -200,10 +204,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/certificate_authorities/hostname_associations", + path_template("/zones/{zone_id}/certificate_authorities/hostname_associations", zone_id=zone_id), body=await async_maybe_transform( { "hostnames": hostnames, @@ -226,7 +232,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, mtls_certificate_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. @@ -253,10 +259,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/certificate_authorities/hostname_associations", + path_template("/zones/{zone_id}/certificate_authorities/hostname_associations", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/client_certificates/__init__.py b/src/cloudflare/resources/client_certificates/__init__.py new file mode 100644 index 00000000000..be8d5b6ccc3 --- /dev/null +++ b/src/cloudflare/resources/client_certificates/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .client_certificates import ( + ClientCertificatesResource, + AsyncClientCertificatesResource, + ClientCertificatesResourceWithRawResponse, + AsyncClientCertificatesResourceWithRawResponse, + ClientCertificatesResourceWithStreamingResponse, + AsyncClientCertificatesResourceWithStreamingResponse, +) + +__all__ = [ + "ClientCertificatesResource", + "AsyncClientCertificatesResource", + "ClientCertificatesResourceWithRawResponse", + "AsyncClientCertificatesResourceWithRawResponse", + "ClientCertificatesResourceWithStreamingResponse", + "AsyncClientCertificatesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/client_certificates/api.md b/src/cloudflare/resources/client_certificates/api.md new file mode 100644 index 00000000000..52db81cf0d2 --- /dev/null +++ b/src/cloudflare/resources/client_certificates/api.md @@ -0,0 +1,15 @@ +# ClientCertificates + +Types: + +```python +from cloudflare.types.client_certificates import ClientCertificate +``` + +Methods: + +- 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[ClientCertificate] +- client.client_certificates.edit(client_certificate_id, \*, zone_id, \*\*params) -> Optional[ClientCertificate] +- client.client_certificates.get(client_certificate_id, \*, zone_id) -> Optional[ClientCertificate] diff --git a/src/cloudflare/resources/client_certificates.py b/src/cloudflare/resources/client_certificates/client_certificates.py similarity index 87% rename from src/cloudflare/resources/client_certificates.py rename to src/cloudflare/resources/client_certificates/client_certificates.py index 3a347848901..a864d12bdda 100644 --- a/src/cloudflare/resources/client_certificates.py +++ b/src/cloudflare/resources/client_certificates/client_certificates.py @@ -7,25 +7,25 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, 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.client_certificates import ( +from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.client_certificates import ( client_certificate_edit_params, client_certificate_list_params, client_certificate_create_params, ) -from ..types.client_certificates.client_certificate import ClientCertificate +from ...types.client_certificates.client_certificate import ClientCertificate __all__ = ["ClientCertificatesResource", "AsyncClientCertificatesResource"] @@ -53,7 +53,7 @@ def with_streaming_response(self) -> ClientCertificatesResourceWithStreamingResp def create( self, *, - zone_id: str, + zone_id: str | None = None, csr: str, validity_days: int, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -81,10 +81,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/client_certificates", + path_template("/zones/{zone_id}/client_certificates", zone_id=zone_id), body=maybe_transform( { "csr": csr, @@ -105,7 +107,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, limit: int | Omit = omit, offset: int | Omit = omit, page: float | Omit = omit, @@ -143,10 +145,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/client_certificates", + path_template("/zones/{zone_id}/client_certificates", zone_id=zone_id), page=SyncV4PagePaginationArray[ClientCertificate], options=make_request_options( extra_headers=extra_headers, @@ -171,7 +175,7 @@ def delete( self, client_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -196,6 +200,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not client_certificate_id: @@ -203,7 +209,11 @@ def delete( f"Expected a non-empty value for `client_certificate_id` but received {client_certificate_id!r}" ) return self._delete( - f"/zones/{zone_id}/client_certificates/{client_certificate_id}", + path_template( + "/zones/{zone_id}/client_certificates/{client_certificate_id}", + zone_id=zone_id, + client_certificate_id=client_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -218,7 +228,7 @@ def edit( self, client_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, reactivate: 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. @@ -244,6 +254,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not client_certificate_id: @@ -251,7 +263,11 @@ def edit( f"Expected a non-empty value for `client_certificate_id` but received {client_certificate_id!r}" ) return self._patch( - f"/zones/{zone_id}/client_certificates/{client_certificate_id}", + path_template( + "/zones/{zone_id}/client_certificates/{client_certificate_id}", + zone_id=zone_id, + client_certificate_id=client_certificate_id, + ), body=maybe_transform( {"reactivate": reactivate}, client_certificate_edit_params.ClientCertificateEditParams ), @@ -269,7 +285,7 @@ def get( self, client_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -293,6 +309,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not client_certificate_id: @@ -300,7 +318,11 @@ def get( f"Expected a non-empty value for `client_certificate_id` but received {client_certificate_id!r}" ) return self._get( - f"/zones/{zone_id}/client_certificates/{client_certificate_id}", + path_template( + "/zones/{zone_id}/client_certificates/{client_certificate_id}", + zone_id=zone_id, + client_certificate_id=client_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -335,7 +357,7 @@ def with_streaming_response(self) -> AsyncClientCertificatesResourceWithStreamin async def create( self, *, - zone_id: str, + zone_id: str | None = None, csr: str, validity_days: int, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -363,10 +385,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/client_certificates", + path_template("/zones/{zone_id}/client_certificates", zone_id=zone_id), body=await async_maybe_transform( { "csr": csr, @@ -387,7 +411,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, limit: int | Omit = omit, offset: int | Omit = omit, page: float | Omit = omit, @@ -425,10 +449,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/client_certificates", + path_template("/zones/{zone_id}/client_certificates", zone_id=zone_id), page=AsyncV4PagePaginationArray[ClientCertificate], options=make_request_options( extra_headers=extra_headers, @@ -453,7 +479,7 @@ async def delete( self, client_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -478,6 +504,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not client_certificate_id: @@ -485,7 +513,11 @@ async def delete( f"Expected a non-empty value for `client_certificate_id` but received {client_certificate_id!r}" ) return await self._delete( - f"/zones/{zone_id}/client_certificates/{client_certificate_id}", + path_template( + "/zones/{zone_id}/client_certificates/{client_certificate_id}", + zone_id=zone_id, + client_certificate_id=client_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -500,7 +532,7 @@ async def edit( self, client_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, reactivate: 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. @@ -526,6 +558,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not client_certificate_id: @@ -533,7 +567,11 @@ async def edit( f"Expected a non-empty value for `client_certificate_id` but received {client_certificate_id!r}" ) return await self._patch( - f"/zones/{zone_id}/client_certificates/{client_certificate_id}", + path_template( + "/zones/{zone_id}/client_certificates/{client_certificate_id}", + zone_id=zone_id, + client_certificate_id=client_certificate_id, + ), body=await async_maybe_transform( {"reactivate": reactivate}, client_certificate_edit_params.ClientCertificateEditParams ), @@ -551,7 +589,7 @@ async def get( self, client_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -575,6 +613,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not client_certificate_id: @@ -582,7 +622,11 @@ async def get( f"Expected a non-empty value for `client_certificate_id` but received {client_certificate_id!r}" ) return await self._get( - f"/zones/{zone_id}/client_certificates/{client_certificate_id}", + path_template( + "/zones/{zone_id}/client_certificates/{client_certificate_id}", + zone_id=zone_id, + client_certificate_id=client_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cloud_connector/api.md b/src/cloudflare/resources/cloud_connector/api.md new file mode 100644 index 00000000000..80c91d1ac20 --- /dev/null +++ b/src/cloudflare/resources/cloud_connector/api.md @@ -0,0 +1,14 @@ +# CloudConnector + +## Rules + +Types: + +```python +from cloudflare.types.cloud_connector import RuleUpdateResponse, RuleListResponse +``` + +Methods: + +- client.cloud_connector.rules.update(\*, zone_id, \*\*params) -> SyncSinglePage[RuleUpdateResponse] +- client.cloud_connector.rules.list(\*, zone_id) -> SyncSinglePage[RuleListResponse] diff --git a/src/cloudflare/resources/cloud_connector/rules.py b/src/cloudflare/resources/cloud_connector/rules.py index 565996aa212..a66d2107730 100644 --- a/src/cloudflare/resources/cloud_connector/rules.py +++ b/src/cloudflare/resources/cloud_connector/rules.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> RulesResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, rules: Iterable[rule_update_params.Rule] | 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. @@ -71,10 +71,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cloud_connector/rules", + path_template("/zones/{zone_id}/cloud_connector/rules", zone_id=zone_id), page=SyncSinglePage[RuleUpdateResponse], body=maybe_transform(rules, Iterable[rule_update_params.Rule]), options=make_request_options( @@ -87,7 +89,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -109,10 +111,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cloud_connector/rules", + path_template("/zones/{zone_id}/cloud_connector/rules", zone_id=zone_id), page=SyncSinglePage[RuleListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -144,7 +148,7 @@ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, rules: Iterable[rule_update_params.Rule] | 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. @@ -167,10 +171,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cloud_connector/rules", + path_template("/zones/{zone_id}/cloud_connector/rules", zone_id=zone_id), page=AsyncSinglePage[RuleUpdateResponse], body=maybe_transform(rules, Iterable[rule_update_params.Rule]), options=make_request_options( @@ -183,7 +189,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -205,10 +211,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/cloud_connector/rules", + path_template("/zones/{zone_id}/cloud_connector/rules", zone_id=zone_id), page=AsyncSinglePage[RuleListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/cloudforce_one/api.md b/src/cloudflare/resources/cloudforce_one/api.md new file mode 100644 index 00000000000..a53cc4086b3 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/api.md @@ -0,0 +1,297 @@ +# CloudforceOne + +## Scans + +### Results + +Types: + +```python +from cloudflare.types.cloudforce_one.scans import ScanResult, ResultGetResponse +``` + +Methods: + +- client.cloudforce_one.scans.results.get(config_id, \*, account_id) -> ResultGetResponse + +### Config + +Types: + +```python +from cloudflare.types.cloudforce_one.scans import ( + ConfigCreateResponse, + ConfigListResponse, + ConfigEditResponse, +) +``` + +Methods: + +- 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] + +## BinaryStorage + +Types: + +```python +from cloudflare.types.cloudforce_one import BinaryStorageCreateResponse +``` + +Methods: + +- client.cloudforce_one.binary_storage.create(\*, account_id, \*\*params) -> BinaryStorageCreateResponse +- client.cloudforce_one.binary_storage.get(hash, \*, account_id) -> None + +## Requests + +Types: + +```python +from cloudflare.types.cloudforce_one import ( + Item, + ListItem, + Quota, + RequestConstants, + RequestTypes, + RequestDeleteResponse, + RequestTypesResponse, +) +``` + +Methods: + +- 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] + +### Message + +Types: + +```python +from cloudflare.types.cloudforce_one.requests import Message, MessageDeleteResponse +``` + +Methods: + +- 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] + +### Priority + +Types: + +```python +from cloudflare.types.cloudforce_one.requests import ( + Label, + Priority, + PriorityEdit, + PriorityDeleteResponse, +) +``` + +Methods: + +- 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] + +### Assets + +Types: + +```python +from cloudflare.types.cloudforce_one.requests import ( + AssetCreateResponse, + AssetUpdateResponse, + AssetDeleteResponse, + AssetGetResponse, +) +``` + +Methods: + +- 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] + +## ThreatEvents + +Types: + +```python +from cloudflare.types.cloudforce_one import ( + ThreatEventCreateResponse, + ThreatEventListResponse, + ThreatEventBulkCreateResponse, + ThreatEventEditResponse, + ThreatEventGetResponse, +) +``` + +Methods: + +- 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.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 + +### Attackers + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import AttackerListResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.attackers.list(\*, account_id, \*\*params) -> AttackerListResponse + +### Categories + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import ( + CategoryCreateResponse, + CategoryListResponse, + CategoryDeleteResponse, + CategoryEditResponse, + CategoryGetResponse, +) +``` + +Methods: + +- 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.cloudforce_one.threat_events import CountryListResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.countries.list(\*, account_id) -> CountryListResponse + +### Datasets + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import ( + DatasetCreateResponse, + DatasetListResponse, + DatasetEditResponse, + DatasetGetResponse, + DatasetRawResponse, +) +``` + +Methods: + +- 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 + +### IndicatorTypes + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import IndicatorTypeListResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.indicator_types.list(\*, account_id) -> IndicatorTypeListResponse + +### Raw + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import RawEditResponse, RawGetResponse +``` + +Methods: + +- 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 + +### Relate + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import RelateDeleteResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.relate.delete(event_id, \*, account_id) -> RelateDeleteResponse + +### Tags + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import TagCreateResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.tags.create(\*, account_id, \*\*params) -> TagCreateResponse + +### EventTags + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import ( + EventTagCreateResponse, + EventTagDeleteResponse, +) +``` + +Methods: + +- 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 + +### TargetIndustries + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import TargetIndustryListResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.target_industries.list(\*, account_id, \*\*params) -> TargetIndustryListResponse diff --git a/src/cloudflare/resources/cloudforce_one/binary_storage.py b/src/cloudflare/resources/cloudforce_one/binary_storage.py index 0fe9078f558..74c98d84c2a 100644 --- a/src/cloudflare/resources/cloudforce_one/binary_storage.py +++ b/src/cloudflare/resources/cloudforce_one/binary_storage.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NoneType, NotGiven, FileTypes, not_given -from ..._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform +from ..._utils import extract_files, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +46,7 @@ def with_streaming_response(self) -> BinaryStorageResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, file: FileTypes, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -71,6 +71,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") body = deepcopy_minimal({"file": file}) @@ -80,7 +82,7 @@ def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/cloudforce-one/binary", + path_template("/accounts/{account_id}/cloudforce-one/binary", account_id=account_id), body=maybe_transform(body, binary_storage_create_params.BinaryStorageCreateParams), files=files, options=make_request_options( @@ -93,7 +95,7 @@ def get( self, hash: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -117,13 +119,15 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hash: raise ValueError(f"Expected a non-empty value for `hash` but received {hash!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/cloudforce-one/binary/{hash}", + path_template("/accounts/{account_id}/cloudforce-one/binary/{hash}", account_id=account_id, hash=hash), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -154,7 +158,7 @@ def with_streaming_response(self) -> AsyncBinaryStorageResourceWithStreamingResp async def create( self, *, - account_id: str, + account_id: str | None = None, file: FileTypes, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -179,6 +183,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") body = deepcopy_minimal({"file": file}) @@ -188,7 +194,7 @@ async def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/cloudforce-one/binary", + path_template("/accounts/{account_id}/cloudforce-one/binary", account_id=account_id), body=await async_maybe_transform(body, binary_storage_create_params.BinaryStorageCreateParams), files=files, options=make_request_options( @@ -201,7 +207,7 @@ async def get( self, hash: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -225,13 +231,15 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hash: raise ValueError(f"Expected a non-empty value for `hash` but received {hash!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/cloudforce-one/binary/{hash}", + path_template("/accounts/{account_id}/cloudforce-one/binary/{hash}", account_id=account_id, hash=hash), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/cloudforce_one/requests/assets.py b/src/cloudflare/resources/cloudforce_one/requests/assets.py index 5d4d2dcc857..2537b2beaee 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/assets.py +++ b/src/cloudflare/resources/cloudforce_one/requests/assets.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def create( self, request_id: str, *, - account_id: str, + account_id: str | None = None, page: int, per_page: int, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -82,12 +82,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._get_api_list( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset", + account_id=account_id, + request_id=request_id, + ), page=SyncSinglePage[AssetCreateResponse], body=maybe_transform( { @@ -107,7 +113,7 @@ def update( self, asset_id: str, *, - account_id: str, + account_id: str | None = None, request_id: str, source: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -137,6 +143,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: @@ -144,7 +152,12 @@ def update( if not asset_id: raise ValueError(f"Expected a non-empty value for `asset_id` but received {asset_id!r}") return self._put( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + account_id=account_id, + request_id=request_id, + asset_id=asset_id, + ), body=maybe_transform({"source": source}, asset_update_params.AssetUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -160,7 +173,7 @@ def delete( self, asset_id: str, *, - account_id: str, + account_id: str | None = None, request_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. @@ -187,6 +200,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: @@ -194,7 +209,12 @@ def delete( if not asset_id: raise ValueError(f"Expected a non-empty value for `asset_id` but received {asset_id!r}") return self._delete( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + account_id=account_id, + request_id=request_id, + asset_id=asset_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -205,7 +225,7 @@ def get( self, asset_id: str, *, - account_id: str, + account_id: str | None = None, request_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. @@ -232,6 +252,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: @@ -239,7 +261,12 @@ def get( if not asset_id: raise ValueError(f"Expected a non-empty value for `asset_id` but received {asset_id!r}") return self._get_api_list( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + account_id=account_id, + request_id=request_id, + asset_id=asset_id, + ), page=SyncSinglePage[AssetGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -272,7 +299,7 @@ def create( self, request_id: str, *, - account_id: str, + account_id: str | None = None, page: int, per_page: int, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -302,12 +329,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._get_api_list( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset", + account_id=account_id, + request_id=request_id, + ), page=AsyncSinglePage[AssetCreateResponse], body=maybe_transform( { @@ -327,7 +360,7 @@ async def update( self, asset_id: str, *, - account_id: str, + account_id: str | None = None, request_id: str, source: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -357,6 +390,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: @@ -364,7 +399,12 @@ async def update( if not asset_id: raise ValueError(f"Expected a non-empty value for `asset_id` but received {asset_id!r}") return await self._put( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + account_id=account_id, + request_id=request_id, + asset_id=asset_id, + ), body=await async_maybe_transform({"source": source}, asset_update_params.AssetUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -380,7 +420,7 @@ async def delete( self, asset_id: str, *, - account_id: str, + account_id: str | None = None, request_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. @@ -407,6 +447,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: @@ -414,7 +456,12 @@ async def delete( if not asset_id: raise ValueError(f"Expected a non-empty value for `asset_id` but received {asset_id!r}") return await self._delete( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + account_id=account_id, + request_id=request_id, + asset_id=asset_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -425,7 +472,7 @@ def get( self, asset_id: str, *, - account_id: str, + account_id: str | None = None, request_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. @@ -452,6 +499,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: @@ -459,7 +508,12 @@ def get( if not asset_id: raise ValueError(f"Expected a non-empty value for `asset_id` but received {asset_id!r}") return self._get_api_list( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/asset/{asset_id}", + account_id=account_id, + request_id=request_id, + asset_id=asset_id, + ), page=AsyncSinglePage[AssetGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index c4a987791df..36a6cd9b811 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def create( self, request_id: str, *, - account_id: str, + account_id: str | None = None, content: 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. @@ -79,12 +79,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._post( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/new", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/new", + account_id=account_id, + request_id=request_id, + ), body=maybe_transform({"content": content}, message_create_params.MessageCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -100,7 +106,7 @@ def update( self, message_id: int, *, - account_id: str, + account_id: str | None = None, request_id: str, content: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -128,12 +134,19 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._put( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/{message_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/{message_id}", + account_id=account_id, + request_id=request_id, + message_id=message_id, + ), body=maybe_transform({"content": content}, message_update_params.MessageUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -149,7 +162,7 @@ def delete( self, message_id: int, *, - account_id: str, + account_id: str | None = None, request_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. @@ -174,12 +187,19 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._delete( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/{message_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/{message_id}", + account_id=account_id, + request_id=request_id, + message_id=message_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -190,7 +210,7 @@ def get( self, request_id: str, *, - account_id: str, + account_id: str | None = None, page: int, per_page: int, after: Union[str, datetime] | Omit = omit, @@ -232,12 +252,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._get_api_list( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/message", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/message", + account_id=account_id, + request_id=request_id, + ), page=SyncSinglePage[Message], body=maybe_transform( { @@ -282,7 +308,7 @@ async def create( self, request_id: str, *, - account_id: str, + account_id: str | None = None, content: 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. @@ -309,12 +335,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return await self._post( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/new", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/new", + account_id=account_id, + request_id=request_id, + ), body=await async_maybe_transform({"content": content}, message_create_params.MessageCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -330,7 +362,7 @@ async def update( self, message_id: int, *, - account_id: str, + account_id: str | None = None, request_id: str, content: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -358,12 +390,19 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return await self._put( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/{message_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/{message_id}", + account_id=account_id, + request_id=request_id, + message_id=message_id, + ), body=await async_maybe_transform({"content": content}, message_update_params.MessageUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -379,7 +418,7 @@ async def delete( self, message_id: int, *, - account_id: str, + account_id: str | None = None, request_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. @@ -404,12 +443,19 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return await self._delete( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/{message_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/message/{message_id}", + account_id=account_id, + request_id=request_id, + message_id=message_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -420,7 +466,7 @@ def get( self, request_id: str, *, - account_id: str, + account_id: str | None = None, page: int, per_page: int, after: Union[str, datetime] | Omit = omit, @@ -462,12 +508,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._get_api_list( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}/message", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}/message", + account_id=account_id, + request_id=request_id, + ), page=AsyncSinglePage[Message], body=maybe_transform( { diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index b116e115fd3..2ef99cda698 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> PriorityResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, labels: SequenceNotStr[Label], priority: int, requirement: str, @@ -86,10 +86,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/priority/new", + path_template("/accounts/{account_id}/cloudforce-one/requests/priority/new", account_id=account_id), body=maybe_transform( { "labels": labels, @@ -113,7 +115,7 @@ def update( self, priority_id: str, *, - account_id: str, + account_id: str | None = None, labels: SequenceNotStr[Label], priority: int, requirement: str, @@ -149,12 +151,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not priority_id: raise ValueError(f"Expected a non-empty value for `priority_id` but received {priority_id!r}") return self._put( - f"/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + account_id=account_id, + priority_id=priority_id, + ), body=maybe_transform( { "labels": labels, @@ -178,7 +186,7 @@ def delete( self, priority_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -202,12 +210,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not priority_id: raise ValueError(f"Expected a non-empty value for `priority_id` but received {priority_id!r}") return self._delete( - f"/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + account_id=account_id, + priority_id=priority_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -218,7 +232,7 @@ def get( self, priority_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -242,12 +256,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not priority_id: raise ValueError(f"Expected a non-empty value for `priority_id` but received {priority_id!r}") return self._get( - f"/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + account_id=account_id, + priority_id=priority_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -261,7 +281,7 @@ def get( def quota( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -283,10 +303,12 @@ def quota( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/priority/quota", + path_template("/accounts/{account_id}/cloudforce-one/requests/priority/quota", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -321,7 +343,7 @@ def with_streaming_response(self) -> AsyncPriorityResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, labels: SequenceNotStr[Label], priority: int, requirement: str, @@ -355,10 +377,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/priority/new", + path_template("/accounts/{account_id}/cloudforce-one/requests/priority/new", account_id=account_id), body=await async_maybe_transform( { "labels": labels, @@ -382,7 +406,7 @@ async def update( self, priority_id: str, *, - account_id: str, + account_id: str | None = None, labels: SequenceNotStr[Label], priority: int, requirement: str, @@ -418,12 +442,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not priority_id: raise ValueError(f"Expected a non-empty value for `priority_id` but received {priority_id!r}") return await self._put( - f"/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + account_id=account_id, + priority_id=priority_id, + ), body=await async_maybe_transform( { "labels": labels, @@ -447,7 +477,7 @@ async def delete( self, priority_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -471,12 +501,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not priority_id: raise ValueError(f"Expected a non-empty value for `priority_id` but received {priority_id!r}") return await self._delete( - f"/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + account_id=account_id, + priority_id=priority_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -487,7 +523,7 @@ async def get( self, priority_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -511,12 +547,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not priority_id: raise ValueError(f"Expected a non-empty value for `priority_id` but received {priority_id!r}") return await self._get( - f"/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/priority/{priority_id}", + account_id=account_id, + priority_id=priority_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -530,7 +572,7 @@ async def get( async def quota( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -552,10 +594,12 @@ async def quota( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/priority/quota", + path_template("/accounts/{account_id}/cloudforce-one/requests/priority/quota", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index ec6ebb2d81c..ce5d1b7d0a7 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -33,7 +33,7 @@ AsyncPriorityResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -91,7 +91,7 @@ def with_streaming_response(self) -> RequestsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, content: str | Omit = omit, priority: str | Omit = omit, request_type: str | Omit = omit, @@ -130,10 +130,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/new", + path_template("/accounts/{account_id}/cloudforce-one/requests/new", account_id=account_id), body=maybe_transform( { "content": content, @@ -158,7 +160,7 @@ def update( self, request_id: str, *, - account_id: str, + account_id: str | None = None, content: str | Omit = omit, priority: str | Omit = omit, request_type: str | Omit = omit, @@ -200,12 +202,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._put( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}", + account_id=account_id, + request_id=request_id, + ), body=maybe_transform( { "content": content, @@ -229,7 +237,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int, per_page: int, completed_after: Union[str, datetime] | Omit = omit, @@ -281,10 +289,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests", + path_template("/accounts/{account_id}/cloudforce-one/requests", account_id=account_id), page=SyncSinglePage[ListItem], body=maybe_transform( { @@ -312,7 +322,7 @@ def delete( self, request_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -336,12 +346,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._delete( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}", + account_id=account_id, + request_id=request_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -351,7 +367,7 @@ def delete( def constants( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -374,10 +390,12 @@ def constants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/constants", + path_template("/accounts/{account_id}/cloudforce-one/requests/constants", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -392,7 +410,7 @@ def get( self, request_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -416,12 +434,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return self._get( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}", + account_id=account_id, + request_id=request_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -435,7 +459,7 @@ def get( def quota( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -457,10 +481,12 @@ def quota( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/quota", + path_template("/accounts/{account_id}/cloudforce-one/requests/quota", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -474,7 +500,7 @@ def quota( def types( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -496,10 +522,12 @@ def types( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/types", + path_template("/accounts/{account_id}/cloudforce-one/requests/types", account_id=account_id), page=SyncSinglePage[RequestTypesResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -543,7 +571,7 @@ def with_streaming_response(self) -> AsyncRequestsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, content: str | Omit = omit, priority: str | Omit = omit, request_type: str | Omit = omit, @@ -582,10 +610,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/new", + path_template("/accounts/{account_id}/cloudforce-one/requests/new", account_id=account_id), body=await async_maybe_transform( { "content": content, @@ -610,7 +640,7 @@ async def update( self, request_id: str, *, - account_id: str, + account_id: str | None = None, content: str | Omit = omit, priority: str | Omit = omit, request_type: str | Omit = omit, @@ -652,12 +682,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return await self._put( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}", + account_id=account_id, + request_id=request_id, + ), body=await async_maybe_transform( { "content": content, @@ -681,7 +717,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int, per_page: int, completed_after: Union[str, datetime] | Omit = omit, @@ -733,10 +769,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests", + path_template("/accounts/{account_id}/cloudforce-one/requests", account_id=account_id), page=AsyncSinglePage[ListItem], body=maybe_transform( { @@ -764,7 +802,7 @@ async def delete( self, request_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -788,12 +826,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return await self._delete( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}", + account_id=account_id, + request_id=request_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -803,7 +847,7 @@ async def delete( async def constants( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -826,10 +870,12 @@ async def constants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/constants", + path_template("/accounts/{account_id}/cloudforce-one/requests/constants", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -844,7 +890,7 @@ async def get( self, request_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -868,12 +914,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not request_id: raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}") return await self._get( - f"/accounts/{account_id}/cloudforce-one/requests/{request_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/requests/{request_id}", + account_id=account_id, + request_id=request_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -887,7 +939,7 @@ async def get( async def quota( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -909,10 +961,12 @@ async def quota( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/quota", + path_template("/accounts/{account_id}/cloudforce-one/requests/quota", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -926,7 +980,7 @@ async def quota( def types( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -948,10 +1002,12 @@ def types( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/requests/types", + path_template("/accounts/{account_id}/cloudforce-one/requests/types", account_id=account_id), page=AsyncSinglePage[RequestTypesResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/cloudforce_one/scans/config.py b/src/cloudflare/resources/cloudforce_one/scans/config.py index 4f30d5341a1..d6ec1313236 100644 --- a/src/cloudflare/resources/cloudforce_one/scans/config.py +++ b/src/cloudflare/resources/cloudforce_one/scans/config.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> ConfigResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, ips: SequenceNotStr[str], frequency: float | Omit = omit, ports: SequenceNotStr[str] | Omit = omit, @@ -84,10 +84,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/scans/config", + path_template("/accounts/{account_id}/cloudforce-one/scans/config", account_id=account_id), body=maybe_transform( { "ips": ips, @@ -109,7 +111,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -131,10 +133,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/scans/config", + path_template("/accounts/{account_id}/cloudforce-one/scans/config", account_id=account_id), page=SyncSinglePage[ConfigListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -146,7 +150,7 @@ def delete( self, config_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -170,12 +174,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return self._delete( - f"/accounts/{account_id}/cloudforce-one/scans/config/{config_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/scans/config/{config_id}", + account_id=account_id, + config_id=config_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -190,7 +200,7 @@ def edit( self, config_id: str, *, - account_id: str, + account_id: str | None = None, frequency: float | Omit = omit, ips: SequenceNotStr[str] | Omit = omit, ports: SequenceNotStr[str] | Omit = omit, @@ -226,12 +236,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return self._patch( - f"/accounts/{account_id}/cloudforce-one/scans/config/{config_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/scans/config/{config_id}", + account_id=account_id, + config_id=config_id, + ), body=maybe_transform( { "frequency": frequency, @@ -274,7 +290,7 @@ def with_streaming_response(self) -> AsyncConfigResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, ips: SequenceNotStr[str], frequency: float | Omit = omit, ports: SequenceNotStr[str] | Omit = omit, @@ -308,10 +324,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/scans/config", + path_template("/accounts/{account_id}/cloudforce-one/scans/config", account_id=account_id), body=await async_maybe_transform( { "ips": ips, @@ -333,7 +351,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -355,10 +373,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/scans/config", + path_template("/accounts/{account_id}/cloudforce-one/scans/config", account_id=account_id), page=AsyncSinglePage[ConfigListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -370,7 +390,7 @@ async def delete( self, config_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -394,12 +414,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return await self._delete( - f"/accounts/{account_id}/cloudforce-one/scans/config/{config_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/scans/config/{config_id}", + account_id=account_id, + config_id=config_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -414,7 +440,7 @@ async def edit( self, config_id: str, *, - account_id: str, + account_id: str | None = None, frequency: float | Omit = omit, ips: SequenceNotStr[str] | Omit = omit, ports: SequenceNotStr[str] | Omit = omit, @@ -450,12 +476,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return await self._patch( - f"/accounts/{account_id}/cloudforce-one/scans/config/{config_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/scans/config/{config_id}", + account_id=account_id, + config_id=config_id, + ), body=await async_maybe_transform( { "frequency": frequency, diff --git a/src/cloudflare/resources/cloudforce_one/scans/results.py b/src/cloudflare/resources/cloudforce_one/scans/results.py index 30bc7294fd2..be4c7683a52 100644 --- a/src/cloudflare/resources/cloudforce_one/scans/results.py +++ b/src/cloudflare/resources/cloudforce_one/scans/results.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +47,7 @@ def get( self, config_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -70,12 +71,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return self._get( - f"/accounts/{account_id}/cloudforce-one/scans/results/{config_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/scans/results/{config_id}", + account_id=account_id, + config_id=config_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -111,7 +118,7 @@ async def get( self, config_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -135,12 +142,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return await self._get( - f"/accounts/{account_id}/cloudforce-one/scans/results/{config_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/scans/results/{config_id}", + account_id=account_id, + config_id=config_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/attackers.py b/src/cloudflare/resources/cloudforce_one/threat_events/attackers.py index 657c8816f7e..e4743cd08c3 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/attackers.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/attackers.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,7 +44,7 @@ def with_streaming_response(self) -> AttackersResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, dataset_ids: 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. @@ -70,10 +70,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/attackers", + path_template("/accounts/{account_id}/cloudforce-one/events/attackers", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -108,7 +110,7 @@ def with_streaming_response(self) -> AsyncAttackersResourceWithStreamingResponse async def list( self, *, - account_id: str, + account_id: str | None = None, dataset_ids: 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. @@ -134,10 +136,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/attackers", + path_template("/accounts/{account_id}/cloudforce-one/events/attackers", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/categories.py b/src/cloudflare/resources/cloudforce_one/threat_events/categories.py index 362345bb7e2..823a1906a79 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/categories.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/categories.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> CategoriesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, kill_chain: float, name: str, mitre_attack: SequenceNotStr[str] | Omit = omit, @@ -75,10 +75,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/categories/create", + path_template("/accounts/{account_id}/cloudforce-one/events/categories/create", account_id=account_id), body=maybe_transform( { "kill_chain": kill_chain, @@ -98,7 +100,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, dataset_ids: 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. @@ -124,10 +126,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/categories", + path_template("/accounts/{account_id}/cloudforce-one/events/categories", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -142,7 +146,7 @@ def delete( self, category_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -166,12 +170,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not category_id: raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") return self._delete( - f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + account_id=account_id, + category_id=category_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -182,7 +192,7 @@ def edit( self, category_id: str, *, - account_id: str, + account_id: str | None = None, kill_chain: float | Omit = omit, mitre_attack: SequenceNotStr[str] | Omit = omit, mitre_capec: SequenceNotStr[str] | Omit = omit, @@ -211,12 +221,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not category_id: raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") return self._patch( - f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + account_id=account_id, + category_id=category_id, + ), body=maybe_transform( { "kill_chain": kill_chain, @@ -237,7 +253,7 @@ def get( self, category_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -261,12 +277,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not category_id: raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") return self._get( - f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + account_id=account_id, + category_id=category_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -297,7 +319,7 @@ def with_streaming_response(self) -> AsyncCategoriesResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, kill_chain: float, name: str, mitre_attack: SequenceNotStr[str] | Omit = omit, @@ -324,10 +346,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/categories/create", + path_template("/accounts/{account_id}/cloudforce-one/events/categories/create", account_id=account_id), body=await async_maybe_transform( { "kill_chain": kill_chain, @@ -347,7 +371,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, dataset_ids: 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. @@ -373,10 +397,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/categories", + path_template("/accounts/{account_id}/cloudforce-one/events/categories", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -393,7 +419,7 @@ async def delete( self, category_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -417,12 +443,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not category_id: raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") return await self._delete( - f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + account_id=account_id, + category_id=category_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -433,7 +465,7 @@ async def edit( self, category_id: str, *, - account_id: str, + account_id: str | None = None, kill_chain: float | Omit = omit, mitre_attack: SequenceNotStr[str] | Omit = omit, mitre_capec: SequenceNotStr[str] | Omit = omit, @@ -462,12 +494,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not category_id: raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") return await self._patch( - f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + account_id=account_id, + category_id=category_id, + ), body=await async_maybe_transform( { "kill_chain": kill_chain, @@ -488,7 +526,7 @@ async def get( self, category_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -512,12 +550,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not category_id: raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") return await self._get( - f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + account_id=account_id, + category_id=category_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/countries.py b/src/cloudflare/resources/cloudforce_one/threat_events/countries.py index c413c5650b4..c214b7a1a12 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/countries.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/countries.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -42,7 +43,7 @@ def with_streaming_response(self) -> CountriesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -64,10 +65,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/countries", + path_template("/accounts/{account_id}/cloudforce-one/events/countries", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -98,7 +101,7 @@ def with_streaming_response(self) -> AsyncCountriesResourceWithStreamingResponse async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -120,10 +123,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/countries", + path_template("/accounts/{account_id}/cloudforce-one/events/countries", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/datasets/datasets.py b/src/cloudflare/resources/cloudforce_one/threat_events/datasets.py similarity index 83% rename from src/cloudflare/resources/cloudforce_one/threat_events/datasets/datasets.py rename to src/cloudflare/resources/cloudforce_one/threat_events/datasets.py index 6fb96b5cba8..d84e8b5bdbc 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/datasets/datasets.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/datasets.py @@ -4,23 +4,23 @@ 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 ( +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template, 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.cloudforce_one.threat_events import dataset_edit_params, dataset_create_params -from .....types.cloudforce_one.threat_events.dataset_get_response import DatasetGetResponse -from .....types.cloudforce_one.threat_events.dataset_raw_response import DatasetRawResponse -from .....types.cloudforce_one.threat_events.dataset_edit_response import DatasetEditResponse -from .....types.cloudforce_one.threat_events.dataset_list_response import DatasetListResponse -from .....types.cloudforce_one.threat_events.dataset_create_response import DatasetCreateResponse +from ...._base_client import make_request_options +from ....types.cloudforce_one.threat_events import dataset_edit_params, dataset_create_params +from ....types.cloudforce_one.threat_events.dataset_get_response import DatasetGetResponse +from ....types.cloudforce_one.threat_events.dataset_raw_response import DatasetRawResponse +from ....types.cloudforce_one.threat_events.dataset_edit_response import DatasetEditResponse +from ....types.cloudforce_one.threat_events.dataset_list_response import DatasetListResponse +from ....types.cloudforce_one.threat_events.dataset_create_response import DatasetCreateResponse __all__ = ["DatasetsResource", "AsyncDatasetsResource"] @@ -48,7 +48,7 @@ def with_streaming_response(self) -> DatasetsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, is_public: bool, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,10 +77,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/dataset/create", + path_template("/accounts/{account_id}/cloudforce-one/events/dataset/create", account_id=account_id), body=maybe_transform( { "is_public": is_public, @@ -97,7 +99,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -119,10 +121,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/dataset", + path_template("/accounts/{account_id}/cloudforce-one/events/dataset", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -133,7 +137,7 @@ def edit( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, is_public: bool, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -164,12 +168,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return self._patch( - f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + account_id=account_id, + dataset_id=dataset_id, + ), body=maybe_transform( { "is_public": is_public, @@ -187,7 +197,7 @@ def get( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -211,12 +221,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return self._get( - f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + account_id=account_id, + dataset_id=dataset_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -227,7 +243,7 @@ def raw( self, event_id: str, *, - account_id: str, + account_id: str | None = None, dataset_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. @@ -256,6 +272,8 @@ def raw( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: @@ -263,7 +281,12 @@ def raw( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._get( - f"/accounts/{account_id}/cloudforce-one/events/raw/{dataset_id}/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/raw/{dataset_id}/{event_id}", + account_id=account_id, + dataset_id=dataset_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -294,7 +317,7 @@ def with_streaming_response(self) -> AsyncDatasetsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, is_public: bool, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -323,10 +346,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/dataset/create", + path_template("/accounts/{account_id}/cloudforce-one/events/dataset/create", account_id=account_id), body=await async_maybe_transform( { "is_public": is_public, @@ -343,7 +368,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -365,10 +390,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/dataset", + path_template("/accounts/{account_id}/cloudforce-one/events/dataset", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -379,7 +406,7 @@ async def edit( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, is_public: bool, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -410,12 +437,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return await self._patch( - f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + account_id=account_id, + dataset_id=dataset_id, + ), body=await async_maybe_transform( { "is_public": is_public, @@ -433,7 +466,7 @@ async def get( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -457,12 +490,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return await self._get( - f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + account_id=account_id, + dataset_id=dataset_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -473,7 +512,7 @@ async def raw( self, event_id: str, *, - account_id: str, + account_id: str | None = None, dataset_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. @@ -502,6 +541,8 @@ async def raw( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: @@ -509,7 +550,12 @@ async def raw( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._get( - f"/accounts/{account_id}/cloudforce-one/events/raw/{dataset_id}/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/raw/{dataset_id}/{event_id}", + account_id=account_id, + dataset_id=dataset_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/datasets/__init__.py b/src/cloudflare/resources/cloudforce_one/threat_events/datasets/__init__.py deleted file mode 100644 index af825c8e995..00000000000 --- a/src/cloudflare/resources/cloudforce_one/threat_events/datasets/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .datasets import ( - DatasetsResource, - AsyncDatasetsResource, - DatasetsResourceWithRawResponse, - AsyncDatasetsResourceWithRawResponse, - DatasetsResourceWithStreamingResponse, - AsyncDatasetsResourceWithStreamingResponse, -) - -__all__ = [ - "DatasetsResource", - "AsyncDatasetsResource", - "DatasetsResourceWithRawResponse", - "AsyncDatasetsResourceWithRawResponse", - "DatasetsResourceWithStreamingResponse", - "AsyncDatasetsResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/event_tags.py b/src/cloudflare/resources/cloudforce_one/threat_events/event_tags.py index 67ce4f627f8..edcf808bfc5 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/event_tags.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/event_tags.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def create( self, event_id: str, *, - account_id: str, + account_id: str | None = None, tags: 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. @@ -74,12 +74,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._post( - f"/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}/create", + path_template( + "/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}/create", + account_id=account_id, + event_id=event_id, + ), body=maybe_transform({"tags": tags}, event_tag_create_params.EventTagCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -95,7 +101,7 @@ def delete( self, event_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -119,12 +125,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._delete( - f"/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}", + account_id=account_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -160,7 +172,7 @@ async def create( self, event_id: str, *, - account_id: str, + account_id: str | None = None, tags: 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. @@ -185,12 +197,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._post( - f"/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}/create", + path_template( + "/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}/create", + account_id=account_id, + event_id=event_id, + ), body=await async_maybe_transform({"tags": tags}, event_tag_create_params.EventTagCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -206,7 +224,7 @@ async def delete( self, event_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -230,12 +248,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._delete( - f"/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}", + account_id=account_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/indicator_types.py b/src/cloudflare/resources/cloudforce_one/threat_events/indicator_types.py index 70e20938124..fe68ce94269 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/indicator_types.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/indicator_types.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> IndicatorTypesResourceWithStreamingResponse def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -69,10 +70,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/indicatorTypes", + path_template("/accounts/{account_id}/cloudforce-one/events/indicatorTypes", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -104,7 +107,7 @@ def with_streaming_response(self) -> AsyncIndicatorTypesResourceWithStreamingRes async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -128,10 +131,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/indicatorTypes", + path_template("/accounts/{account_id}/cloudforce-one/events/indicatorTypes", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/raw.py b/src/cloudflare/resources/cloudforce_one/threat_events/raw.py index d12ca4f7eeb..584c56cc47f 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/raw.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/raw.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +46,7 @@ def edit( self, raw_id: str, *, - account_id: str, + account_id: str | None = None, event_id: str, data: object | Omit = omit, source: str | Omit = omit, @@ -76,6 +76,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: @@ -83,7 +85,12 @@ def edit( if not raw_id: raise ValueError(f"Expected a non-empty value for `raw_id` but received {raw_id!r}") return self._patch( - f"/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + account_id=account_id, + event_id=event_id, + raw_id=raw_id, + ), body=maybe_transform( { "data": data, @@ -102,7 +109,7 @@ def get( self, raw_id: str, *, - account_id: str, + account_id: str | None = None, event_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. @@ -129,6 +136,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: @@ -136,7 +145,12 @@ def get( if not raw_id: raise ValueError(f"Expected a non-empty value for `raw_id` but received {raw_id!r}") return self._get( - f"/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + account_id=account_id, + event_id=event_id, + raw_id=raw_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -168,7 +182,7 @@ async def edit( self, raw_id: str, *, - account_id: str, + account_id: str | None = None, event_id: str, data: object | Omit = omit, source: str | Omit = omit, @@ -198,6 +212,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: @@ -205,7 +221,12 @@ async def edit( if not raw_id: raise ValueError(f"Expected a non-empty value for `raw_id` but received {raw_id!r}") return await self._patch( - f"/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + account_id=account_id, + event_id=event_id, + raw_id=raw_id, + ), body=await async_maybe_transform( { "data": data, @@ -224,7 +245,7 @@ async def get( self, raw_id: str, *, - account_id: str, + account_id: str | None = None, event_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. @@ -251,6 +272,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: @@ -258,7 +281,12 @@ async def get( if not raw_id: raise ValueError(f"Expected a non-empty value for `raw_id` but received {raw_id!r}") return await self._get( - f"/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + account_id=account_id, + event_id=event_id, + raw_id=raw_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/relate.py b/src/cloudflare/resources/cloudforce_one/threat_events/relate.py index bbadf4ae8f0..098c33bc5bc 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/relate.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/relate.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +47,7 @@ def delete( self, event_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -70,12 +71,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._delete( - f"/accounts/{account_id}/cloudforce-one/events/relate/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/relate/{event_id}", + account_id=account_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -111,7 +118,7 @@ async def delete( self, event_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -135,12 +142,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._delete( - f"/accounts/{account_id}/cloudforce-one/events/relate/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/relate/{event_id}", + account_id=account_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/tags.py b/src/cloudflare/resources/cloudforce_one/threat_events/tags.py index bd3bdfee8dc..6efb7037628 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/tags.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/tags.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,7 +44,7 @@ def with_streaming_response(self) -> TagsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, value: str, active_duration: str | Omit = omit, actor_category: str | Omit = omit, @@ -82,10 +82,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/tags/create", + path_template("/accounts/{account_id}/cloudforce-one/events/tags/create", account_id=account_id), body=maybe_transform( { "value": value, @@ -137,7 +139,7 @@ def with_streaming_response(self) -> AsyncTagsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, value: str, active_duration: str | Omit = omit, actor_category: str | Omit = omit, @@ -175,10 +177,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/tags/create", + path_template("/accounts/{account_id}/cloudforce-one/events/tags/create", account_id=account_id), body=await async_maybe_transform( { "value": value, diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/target_industries.py b/src/cloudflare/resources/cloudforce_one/threat_events/target_industries.py index 226c4e4394d..60f9e7e8be3 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/target_industries.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/target_industries.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,7 +44,7 @@ def with_streaming_response(self) -> TargetIndustriesResourceWithStreamingRespon def list( self, *, - account_id: str, + account_id: str | None = None, dataset_ids: 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. @@ -70,10 +70,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/targetIndustries", + path_template("/accounts/{account_id}/cloudforce-one/events/targetIndustries", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -110,7 +112,7 @@ def with_streaming_response(self) -> AsyncTargetIndustriesResourceWithStreamingR async def list( self, *, - account_id: str, + account_id: str | None = None, dataset_ids: 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. @@ -136,10 +138,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/targetIndustries", + path_template("/accounts/{account_id}/cloudforce-one/events/targetIndustries", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py b/src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py index 9f908c274bb..2bf7fa22434 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py @@ -33,8 +33,16 @@ RelateResourceWithStreamingResponse, AsyncRelateResourceWithStreamingResponse, ) +from .datasets import ( + DatasetsResource, + AsyncDatasetsResource, + DatasetsResourceWithRawResponse, + AsyncDatasetsResourceWithRawResponse, + DatasetsResourceWithStreamingResponse, + AsyncDatasetsResourceWithStreamingResponse, +) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from .attackers import ( AttackersResource, AsyncAttackersResource, @@ -84,14 +92,6 @@ IndicatorTypesResourceWithStreamingResponse, AsyncIndicatorTypesResourceWithStreamingResponse, ) -from .datasets.datasets import ( - DatasetsResource, - AsyncDatasetsResource, - DatasetsResourceWithRawResponse, - AsyncDatasetsResourceWithRawResponse, - DatasetsResourceWithStreamingResponse, - AsyncDatasetsResourceWithStreamingResponse, -) from .target_industries import ( TargetIndustriesResource, AsyncTargetIndustriesResource, @@ -178,7 +178,7 @@ def with_streaming_response(self) -> ThreatEventsResourceWithStreamingResponse: def create( self, *, - path_account_id: str, + path_account_id: str | None = None, category: str, date: Union[str, datetime], event: str, @@ -222,10 +222,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if path_account_id is None: + path_account_id = self._client._get_account_id_path_param() if not path_account_id: raise ValueError(f"Expected a non-empty value for `path_account_id` but received {path_account_id!r}") return self._post( - f"/accounts/{path_account_id}/cloudforce-one/events/create", + path_template("/accounts/{path_account_id}/cloudforce-one/events/create", path_account_id=path_account_id), body=maybe_transform( { "category": category, @@ -256,7 +258,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, dataset_id: SequenceNotStr[str] | Omit = omit, force_refresh: bool | Omit = omit, @@ -301,10 +303,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events", + path_template("/accounts/{account_id}/cloudforce-one/events", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -331,7 +335,7 @@ def list( def bulk_create( self, *, - account_id: str, + account_id: str | None = None, data: Iterable[threat_event_bulk_create_params.Data], dataset_id: str, include_created_events: bool | Omit = omit, @@ -363,10 +367,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/create/bulk", + path_template("/accounts/{account_id}/cloudforce-one/events/create/bulk", account_id=account_id), body=maybe_transform( { "data": data, @@ -385,7 +391,7 @@ def edit( self, event_id: str, *, - account_id: str, + account_id: str | None = None, dataset_id: str, attacker: Optional[str] | Omit = omit, attacker_country: str | Omit = omit, @@ -425,12 +431,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._patch( - f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/{event_id}", account_id=account_id, event_id=event_id + ), body=maybe_transform( { "dataset_id": dataset_id, @@ -461,7 +471,7 @@ def get( self, event_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -487,12 +497,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._get( - f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/{event_id}", account_id=account_id, event_id=event_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -563,7 +577,7 @@ def with_streaming_response(self) -> AsyncThreatEventsResourceWithStreamingRespo async def create( self, *, - path_account_id: str, + path_account_id: str | None = None, category: str, date: Union[str, datetime], event: str, @@ -607,10 +621,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if path_account_id is None: + path_account_id = self._client._get_account_id_path_param() if not path_account_id: raise ValueError(f"Expected a non-empty value for `path_account_id` but received {path_account_id!r}") return await self._post( - f"/accounts/{path_account_id}/cloudforce-one/events/create", + path_template("/accounts/{path_account_id}/cloudforce-one/events/create", path_account_id=path_account_id), body=await async_maybe_transform( { "category": category, @@ -641,7 +657,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, dataset_id: SequenceNotStr[str] | Omit = omit, force_refresh: bool | Omit = omit, @@ -686,10 +702,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events", + path_template("/accounts/{account_id}/cloudforce-one/events", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -716,7 +734,7 @@ async def list( async def bulk_create( self, *, - account_id: str, + account_id: str | None = None, data: Iterable[threat_event_bulk_create_params.Data], dataset_id: str, include_created_events: bool | Omit = omit, @@ -748,10 +766,12 @@ async def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cloudforce-one/events/create/bulk", + path_template("/accounts/{account_id}/cloudforce-one/events/create/bulk", account_id=account_id), body=await async_maybe_transform( { "data": data, @@ -770,7 +790,7 @@ async def edit( self, event_id: str, *, - account_id: str, + account_id: str | None = None, dataset_id: str, attacker: Optional[str] | Omit = omit, attacker_country: str | Omit = omit, @@ -810,12 +830,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._patch( - f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/{event_id}", account_id=account_id, event_id=event_id + ), body=await async_maybe_transform( { "dataset_id": dataset_id, @@ -846,7 +870,7 @@ async def get( self, event_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -872,12 +896,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._get( - f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + path_template( + "/accounts/{account_id}/cloudforce-one/events/{event_id}", account_id=account_id, event_id=event_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/connectivity/api.md b/src/cloudflare/resources/connectivity/api.md new file mode 100644 index 00000000000..146f0dc3460 --- /dev/null +++ b/src/cloudflare/resources/connectivity/api.md @@ -0,0 +1,24 @@ +# 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] diff --git a/src/cloudflare/resources/connectivity/directory/services.py b/src/cloudflare/resources/connectivity/directory/services.py index d03dd45a7bd..00570aff11b 100644 --- a/src/cloudflare/resources/connectivity/directory/services.py +++ b/src/cloudflare/resources/connectivity/directory/services.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ...._utils import required_args, maybe_transform, async_maybe_transform +from ...._utils import path_template, required_args, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> ServicesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, host: service_create_params.InfraHTTPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -91,7 +91,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, host: service_create_params.InfraTCPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -125,11 +125,11 @@ def create( """ ... - @required_args(["account_id", "host", "name", "type"]) + @required_args(["host", "name", "type"]) def create( self, *, - account_id: str, + account_id: str | None = None, host: service_create_params.InfraHTTPServiceConfigHost | service_create_params.InfraTCPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -147,12 +147,14 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ServiceCreateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[ServiceCreateResponse], self._post( - f"/accounts/{account_id}/connectivity/directory/services", + path_template("/accounts/{account_id}/connectivity/directory/services", account_id=account_id), body=maybe_transform( { "host": host, @@ -184,7 +186,7 @@ def update( self, service_id: str, *, - account_id: str, + account_id: str | None = None, host: service_update_params.InfraHTTPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -221,7 +223,7 @@ def update( self, service_id: str, *, - account_id: str, + account_id: str | None = None, host: service_update_params.InfraTCPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -253,12 +255,12 @@ def update( """ ... - @required_args(["account_id", "host", "name", "type"]) + @required_args(["host", "name", "type"]) def update( self, service_id: str, *, - account_id: str, + account_id: str | None = None, host: service_update_params.InfraHTTPServiceConfigHost | service_update_params.InfraTCPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -276,6 +278,8 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ServiceUpdateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_id: @@ -283,7 +287,11 @@ def update( return cast( Optional[ServiceUpdateResponse], self._put( - f"/accounts/{account_id}/connectivity/directory/services/{service_id}", + path_template( + "/accounts/{account_id}/connectivity/directory/services/{service_id}", + account_id=account_id, + service_id=service_id, + ), body=maybe_transform( { "host": host, @@ -313,7 +321,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, type: Optional[Literal["tcp", "http"]] | Omit = omit, @@ -342,10 +350,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/connectivity/directory/services", + path_template("/accounts/{account_id}/connectivity/directory/services", account_id=account_id), page=SyncV4PagePaginationArray[ServiceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -368,7 +378,7 @@ def delete( self, service_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -388,13 +398,19 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_id: raise ValueError(f"Expected a non-empty value for `service_id` but received {service_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/connectivity/directory/services/{service_id}", + path_template( + "/accounts/{account_id}/connectivity/directory/services/{service_id}", + account_id=account_id, + service_id=service_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -405,7 +421,7 @@ def get( self, service_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -425,6 +441,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_id: @@ -432,7 +450,11 @@ def get( return cast( Optional[ServiceGetResponse], self._get( - f"/accounts/{account_id}/connectivity/directory/services/{service_id}", + path_template( + "/accounts/{account_id}/connectivity/directory/services/{service_id}", + account_id=account_id, + service_id=service_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -471,7 +493,7 @@ def with_streaming_response(self) -> AsyncServicesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, host: service_create_params.InfraHTTPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -509,7 +531,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, host: service_create_params.InfraTCPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -543,11 +565,11 @@ async def create( """ ... - @required_args(["account_id", "host", "name", "type"]) + @required_args(["host", "name", "type"]) async def create( self, *, - account_id: str, + account_id: str | None = None, host: service_create_params.InfraHTTPServiceConfigHost | service_create_params.InfraTCPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -565,12 +587,14 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ServiceCreateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[ServiceCreateResponse], await self._post( - f"/accounts/{account_id}/connectivity/directory/services", + path_template("/accounts/{account_id}/connectivity/directory/services", account_id=account_id), body=await async_maybe_transform( { "host": host, @@ -602,7 +626,7 @@ async def update( self, service_id: str, *, - account_id: str, + account_id: str | None = None, host: service_update_params.InfraHTTPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -639,7 +663,7 @@ async def update( self, service_id: str, *, - account_id: str, + account_id: str | None = None, host: service_update_params.InfraTCPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -671,12 +695,12 @@ async def update( """ ... - @required_args(["account_id", "host", "name", "type"]) + @required_args(["host", "name", "type"]) async def update( self, service_id: str, *, - account_id: str, + account_id: str | None = None, host: service_update_params.InfraHTTPServiceConfigHost | service_update_params.InfraTCPServiceConfigHost, name: str, type: Literal["tcp", "http"], @@ -694,6 +718,8 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ServiceUpdateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_id: @@ -701,7 +727,11 @@ async def update( return cast( Optional[ServiceUpdateResponse], await self._put( - f"/accounts/{account_id}/connectivity/directory/services/{service_id}", + path_template( + "/accounts/{account_id}/connectivity/directory/services/{service_id}", + account_id=account_id, + service_id=service_id, + ), body=await async_maybe_transform( { "host": host, @@ -731,7 +761,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, type: Optional[Literal["tcp", "http"]] | Omit = omit, @@ -760,10 +790,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/connectivity/directory/services", + path_template("/accounts/{account_id}/connectivity/directory/services", account_id=account_id), page=AsyncV4PagePaginationArray[ServiceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -786,7 +818,7 @@ async def delete( self, service_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -806,13 +838,19 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_id: raise ValueError(f"Expected a non-empty value for `service_id` but received {service_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/connectivity/directory/services/{service_id}", + path_template( + "/accounts/{account_id}/connectivity/directory/services/{service_id}", + account_id=account_id, + service_id=service_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -823,7 +861,7 @@ async def get( self, service_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -843,6 +881,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_id: @@ -850,7 +890,11 @@ async def get( return cast( Optional[ServiceGetResponse], await self._get( - f"/accounts/{account_id}/connectivity/directory/services/{service_id}", + path_template( + "/accounts/{account_id}/connectivity/directory/services/{service_id}", + account_id=account_id, + service_id=service_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/content_scanning/api.md b/src/cloudflare/resources/content_scanning/api.md new file mode 100644 index 00000000000..25fe9508864 --- /dev/null +++ b/src/cloudflare/resources/content_scanning/api.md @@ -0,0 +1,49 @@ +# ContentScanning + +Types: + +```python +from cloudflare.types.content_scanning import ( + ContentScanningCreateResponse, + ContentScanningUpdateResponse, + ContentScanningGetResponse, +) +``` + +Methods: + +- 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 + +## Payloads + +Types: + +```python +from cloudflare.types.content_scanning import ( + PayloadCreateResponse, + PayloadListResponse, + PayloadDeleteResponse, +) +``` + +Methods: + +- 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] + +## Settings + +Types: + +```python +from cloudflare.types.content_scanning import SettingGetResponse +``` + +Methods: + +- client.content_scanning.settings.get(\*, zone_id) -> SettingGetResponse diff --git a/src/cloudflare/resources/content_scanning/content_scanning.py b/src/cloudflare/resources/content_scanning/content_scanning.py index ddc8deba657..d2eee62c10d 100644 --- a/src/cloudflare/resources/content_scanning/content_scanning.py +++ b/src/cloudflare/resources/content_scanning/content_scanning.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .payloads import ( PayloadsResource, AsyncPayloadsResource, @@ -74,7 +74,7 @@ def with_streaming_response(self) -> ContentScanningResourceWithStreamingRespons def create( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["enabled", "disabled"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -99,10 +99,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/content-upload-scan/settings", + path_template("/zones/{zone_id}/content-upload-scan/settings", zone_id=zone_id), body=maybe_transform({"value": value}, content_scanning_create_params.ContentScanningCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -117,7 +119,7 @@ def create( def update( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["enabled", "disabled"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -142,10 +144,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/content-upload-scan/settings", + path_template("/zones/{zone_id}/content-upload-scan/settings", zone_id=zone_id), body=maybe_transform({"value": value}, content_scanning_update_params.ContentScanningUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -160,7 +164,7 @@ def update( def disable( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -182,10 +186,12 @@ def disable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/content-upload-scan/disable", + path_template("/zones/{zone_id}/content-upload-scan/disable", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -199,7 +205,7 @@ def disable( def enable( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -221,10 +227,12 @@ def enable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/content-upload-scan/enable", + path_template("/zones/{zone_id}/content-upload-scan/enable", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -238,7 +246,7 @@ def enable( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -260,10 +268,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/content-upload-scan/settings", + path_template("/zones/{zone_id}/content-upload-scan/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -306,7 +316,7 @@ def with_streaming_response(self) -> AsyncContentScanningResourceWithStreamingRe async def create( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["enabled", "disabled"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -331,10 +341,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/content-upload-scan/settings", + path_template("/zones/{zone_id}/content-upload-scan/settings", zone_id=zone_id), body=await async_maybe_transform( {"value": value}, content_scanning_create_params.ContentScanningCreateParams ), @@ -351,7 +363,7 @@ async def create( async def update( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["enabled", "disabled"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -376,10 +388,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/content-upload-scan/settings", + path_template("/zones/{zone_id}/content-upload-scan/settings", zone_id=zone_id), body=await async_maybe_transform( {"value": value}, content_scanning_update_params.ContentScanningUpdateParams ), @@ -396,7 +410,7 @@ async def update( async def disable( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -418,10 +432,12 @@ async def disable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/content-upload-scan/disable", + path_template("/zones/{zone_id}/content-upload-scan/disable", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -435,7 +451,7 @@ async def disable( async def enable( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -457,10 +473,12 @@ async def enable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/content-upload-scan/enable", + path_template("/zones/{zone_id}/content-upload-scan/enable", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -474,7 +492,7 @@ async def enable( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -496,10 +514,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/content-upload-scan/settings", + path_template("/zones/{zone_id}/content-upload-scan/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/content_scanning/payloads.py b/src/cloudflare/resources/content_scanning/payloads.py index a093c140132..b01ed70caa7 100644 --- a/src/cloudflare/resources/content_scanning/payloads.py +++ b/src/cloudflare/resources/content_scanning/payloads.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> PayloadsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[payload_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. @@ -72,10 +72,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/content-upload-scan/payloads", + path_template("/zones/{zone_id}/content-upload-scan/payloads", zone_id=zone_id), page=SyncSinglePage[PayloadCreateResponse], body=maybe_transform(body, Iterable[payload_create_params.Body]), options=make_request_options( @@ -88,7 +90,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -110,10 +112,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/content-upload-scan/payloads", + path_template("/zones/{zone_id}/content-upload-scan/payloads", zone_id=zone_id), page=SyncSinglePage[PayloadListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -125,7 +129,7 @@ def delete( self, expression_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -149,12 +153,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not expression_id: raise ValueError(f"Expected a non-empty value for `expression_id` but received {expression_id!r}") return self._get_api_list( - f"/zones/{zone_id}/content-upload-scan/payloads/{expression_id}", + path_template( + "/zones/{zone_id}/content-upload-scan/payloads/{expression_id}", + zone_id=zone_id, + expression_id=expression_id, + ), page=SyncSinglePage[PayloadDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -187,7 +197,7 @@ def with_streaming_response(self) -> AsyncPayloadsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[payload_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. @@ -210,10 +220,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/content-upload-scan/payloads", + path_template("/zones/{zone_id}/content-upload-scan/payloads", zone_id=zone_id), page=AsyncSinglePage[PayloadCreateResponse], body=maybe_transform(body, Iterable[payload_create_params.Body]), options=make_request_options( @@ -226,7 +238,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -248,10 +260,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/content-upload-scan/payloads", + path_template("/zones/{zone_id}/content-upload-scan/payloads", zone_id=zone_id), page=AsyncSinglePage[PayloadListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -263,7 +277,7 @@ def delete( self, expression_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -287,12 +301,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not expression_id: raise ValueError(f"Expected a non-empty value for `expression_id` but received {expression_id!r}") return self._get_api_list( - f"/zones/{zone_id}/content-upload-scan/payloads/{expression_id}", + path_template( + "/zones/{zone_id}/content-upload-scan/payloads/{expression_id}", + zone_id=zone_id, + expression_id=expression_id, + ), page=AsyncSinglePage[PayloadDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/content_scanning/settings.py b/src/cloudflare/resources/content_scanning/settings.py index c9e6ebf8adc..a0dc287149b 100644 --- a/src/cloudflare/resources/content_scanning/settings.py +++ b/src/cloudflare/resources/content_scanning/settings.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/content-upload-scan/settings", + path_template("/zones/{zone_id}/content-upload-scan/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -105,7 +108,7 @@ def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,10 +130,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/content-upload-scan/settings", + path_template("/zones/{zone_id}/content-upload-scan/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/custom_certificates/api.md b/src/cloudflare/resources/custom_certificates/api.md new file mode 100644 index 00000000000..10cd9f4d4c7 --- /dev/null +++ b/src/cloudflare/resources/custom_certificates/api.md @@ -0,0 +1,26 @@ +# CustomCertificates + +Types: + +```python +from cloudflare.types.custom_certificates import ( + CustomCertificate, + GeoRestrictions, + Status, + CustomCertificateDeleteResponse, +) +``` + +Methods: + +- 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[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 + +Methods: + +- client.custom_certificates.prioritize.update(\*, zone_id, \*\*params) -> SyncSinglePage[CustomCertificate] diff --git a/src/cloudflare/resources/custom_certificates/custom_certificates.py b/src/cloudflare/resources/custom_certificates/custom_certificates.py index f2819fb3a5f..e61e7897e6f 100644 --- a/src/cloudflare/resources/custom_certificates/custom_certificates.py +++ b/src/cloudflare/resources/custom_certificates/custom_certificates.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from .prioritize import ( PrioritizeResource, @@ -69,7 +69,7 @@ def with_streaming_response(self) -> CustomCertificatesResourceWithStreamingResp def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, private_key: str, bundle_method: BundleMethod | Omit = omit, @@ -135,10 +135,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_certificates", + path_template("/zones/{zone_id}/custom_certificates", zone_id=zone_id), body=maybe_transform( { "certificate": certificate, @@ -165,7 +167,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, match: Literal["any", "all"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -202,10 +204,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_certificates", + path_template("/zones/{zone_id}/custom_certificates", zone_id=zone_id), page=SyncV4PagePaginationArray[CustomCertificate], options=make_request_options( extra_headers=extra_headers, @@ -229,7 +233,7 @@ def delete( self, custom_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -253,6 +257,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_certificate_id: @@ -260,7 +266,11 @@ def delete( f"Expected a non-empty value for `custom_certificate_id` but received {custom_certificate_id!r}" ) return self._delete( - f"/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + path_template( + "/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + zone_id=zone_id, + custom_certificate_id=custom_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -277,7 +287,7 @@ def edit( self, custom_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, bundle_method: BundleMethod | Omit = omit, certificate: str | Omit = omit, custom_csr_id: str | Omit = omit, @@ -344,6 +354,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_certificate_id: @@ -351,7 +363,11 @@ def edit( f"Expected a non-empty value for `custom_certificate_id` but received {custom_certificate_id!r}" ) return self._patch( - f"/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + path_template( + "/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + zone_id=zone_id, + custom_certificate_id=custom_certificate_id, + ), body=maybe_transform( { "bundle_method": bundle_method, @@ -378,7 +394,7 @@ def get( self, custom_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -404,6 +420,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_certificate_id: @@ -411,7 +429,11 @@ def get( f"Expected a non-empty value for `custom_certificate_id` but received {custom_certificate_id!r}" ) return self._get( - f"/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + path_template( + "/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + zone_id=zone_id, + custom_certificate_id=custom_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -450,7 +472,7 @@ def with_streaming_response(self) -> AsyncCustomCertificatesResourceWithStreamin async def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, private_key: str, bundle_method: BundleMethod | Omit = omit, @@ -516,10 +538,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_certificates", + path_template("/zones/{zone_id}/custom_certificates", zone_id=zone_id), body=await async_maybe_transform( { "certificate": certificate, @@ -546,7 +570,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, match: Literal["any", "all"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -583,10 +607,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_certificates", + path_template("/zones/{zone_id}/custom_certificates", zone_id=zone_id), page=AsyncV4PagePaginationArray[CustomCertificate], options=make_request_options( extra_headers=extra_headers, @@ -610,7 +636,7 @@ async def delete( self, custom_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -634,6 +660,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_certificate_id: @@ -641,7 +669,11 @@ async def delete( f"Expected a non-empty value for `custom_certificate_id` but received {custom_certificate_id!r}" ) return await self._delete( - f"/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + path_template( + "/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + zone_id=zone_id, + custom_certificate_id=custom_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -658,7 +690,7 @@ async def edit( self, custom_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, bundle_method: BundleMethod | Omit = omit, certificate: str | Omit = omit, custom_csr_id: str | Omit = omit, @@ -725,6 +757,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_certificate_id: @@ -732,7 +766,11 @@ async def edit( f"Expected a non-empty value for `custom_certificate_id` but received {custom_certificate_id!r}" ) return await self._patch( - f"/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + path_template( + "/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + zone_id=zone_id, + custom_certificate_id=custom_certificate_id, + ), body=await async_maybe_transform( { "bundle_method": bundle_method, @@ -759,7 +797,7 @@ async def get( self, custom_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -785,6 +823,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_certificate_id: @@ -792,7 +832,11 @@ async def get( f"Expected a non-empty value for `custom_certificate_id` but received {custom_certificate_id!r}" ) return await self._get( - f"/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + path_template( + "/zones/{zone_id}/custom_certificates/{custom_certificate_id}", + zone_id=zone_id, + custom_certificate_id=custom_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/custom_certificates/prioritize.py b/src/cloudflare/resources/custom_certificates/prioritize.py index dcc12005ba6..d6d77932c0b 100644 --- a/src/cloudflare/resources/custom_certificates/prioritize.py +++ b/src/cloudflare/resources/custom_certificates/prioritize.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> PrioritizeResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, certificates: Iterable[prioritize_update_params.Certificate], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -74,10 +74,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_certificates/prioritize", + path_template("/zones/{zone_id}/custom_certificates/prioritize", zone_id=zone_id), page=SyncSinglePage[CustomCertificate], body=maybe_transform({"certificates": certificates}, prioritize_update_params.PrioritizeUpdateParams), options=make_request_options( @@ -111,7 +113,7 @@ def with_streaming_response(self) -> AsyncPrioritizeResourceWithStreamingRespons def update( self, *, - zone_id: str, + zone_id: str | None = None, certificates: Iterable[prioritize_update_params.Certificate], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -138,10 +140,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_certificates/prioritize", + path_template("/zones/{zone_id}/custom_certificates/prioritize", zone_id=zone_id), page=AsyncSinglePage[CustomCertificate], body=maybe_transform({"certificates": certificates}, prioritize_update_params.PrioritizeUpdateParams), options=make_request_options( diff --git a/src/cloudflare/resources/custom_hostnames/api.md b/src/cloudflare/resources/custom_hostnames/api.md new file mode 100644 index 00000000000..7848b1579b3 --- /dev/null +++ b/src/cloudflare/resources/custom_hostnames/api.md @@ -0,0 +1,61 @@ +# CustomHostnames + +Types: + +```python +from cloudflare.types.custom_hostnames import ( + BundleMethod, + CustomHostname, + DCVMethod, + DomainValidationType, + CustomHostnameCreateResponse, + CustomHostnameListResponse, + CustomHostnameDeleteResponse, + CustomHostnameEditResponse, + CustomHostnameGetResponse, +) +``` + +Methods: + +- 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[CustomHostnameEditResponse] +- client.custom_hostnames.get(custom_hostname_id, \*, zone_id) -> Optional[CustomHostnameGetResponse] + +## FallbackOrigin + +Types: + +```python +from cloudflare.types.custom_hostnames import ( + FallbackOriginUpdateResponse, + FallbackOriginDeleteResponse, + FallbackOriginGetResponse, +) +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/custom_hostnames/certificate_pack/certificates.py b/src/cloudflare/resources/custom_hostnames/certificate_pack/certificates.py index d3df9504b42..33f066ba039 100644 --- a/src/cloudflare/resources/custom_hostnames/certificate_pack/certificates.py +++ b/src/cloudflare/resources/custom_hostnames/certificate_pack/certificates.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def update( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, custom_hostname_id: str, certificate_pack_id: str, custom_certificate: str, @@ -88,6 +88,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: @@ -99,7 +101,13 @@ def update( if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._put( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}/certificate_pack/{certificate_pack_id}/certificates/{certificate_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}/certificate_pack/{certificate_pack_id}/certificates/{certificate_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + certificate_pack_id=certificate_pack_id, + certificate_id=certificate_id, + ), body=maybe_transform( { "custom_certificate": custom_certificate, @@ -121,7 +129,7 @@ def delete( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, custom_hostname_id: str, certificate_pack_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -154,6 +162,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: @@ -165,7 +175,13 @@ def delete( if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._delete( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}/certificate_pack/{certificate_pack_id}/certificates/{certificate_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}/certificate_pack/{certificate_pack_id}/certificates/{certificate_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + certificate_pack_id=certificate_pack_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -197,7 +213,7 @@ async def update( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, custom_hostname_id: str, certificate_pack_id: str, custom_certificate: str, @@ -236,6 +252,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: @@ -247,7 +265,13 @@ async def update( if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._put( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}/certificate_pack/{certificate_pack_id}/certificates/{certificate_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}/certificate_pack/{certificate_pack_id}/certificates/{certificate_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + certificate_pack_id=certificate_pack_id, + certificate_id=certificate_id, + ), body=await async_maybe_transform( { "custom_certificate": custom_certificate, @@ -269,7 +293,7 @@ async def delete( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, custom_hostname_id: str, certificate_pack_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -302,6 +326,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: @@ -313,7 +339,13 @@ async def delete( if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._delete( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}/certificate_pack/{certificate_pack_id}/certificates/{certificate_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}/certificate_pack/{certificate_pack_id}/certificates/{certificate_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + certificate_pack_id=certificate_pack_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/custom_hostnames/custom_hostnames.py b/src/cloudflare/resources/custom_hostnames/custom_hostnames.py index cf596fb4c4a..52c33ff0284 100644 --- a/src/cloudflare/resources/custom_hostnames/custom_hostnames.py +++ b/src/cloudflare/resources/custom_hostnames/custom_hostnames.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -81,7 +81,7 @@ def with_streaming_response(self) -> CustomHostnamesResourceWithStreamingRespons def create( self, *, - zone_id: str, + zone_id: str | None = None, hostname: str, custom_metadata: Dict[str, str] | Omit = omit, ssl: custom_hostname_create_params.SSL | Omit = omit, @@ -122,10 +122,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_hostnames", + path_template("/zones/{zone_id}/custom_hostnames", zone_id=zone_id), body=maybe_transform( { "hostname": hostname, @@ -147,7 +149,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, id: str | Omit = omit, certificate_authority: Literal["google", "lets_encrypt", "ssl_com"] | Omit = omit, custom_origin_server: str | Omit = omit, @@ -246,10 +248,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_hostnames", + path_template("/zones/{zone_id}/custom_hostnames", zone_id=zone_id), page=SyncV4PagePaginationArray[CustomHostnameListResponse], options=make_request_options( extra_headers=extra_headers, @@ -281,7 +285,7 @@ def delete( self, custom_hostname_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -306,12 +310,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: raise ValueError(f"Expected a non-empty value for `custom_hostname_id` but received {custom_hostname_id!r}") return self._delete( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -322,7 +332,7 @@ def edit( self, custom_hostname_id: str, *, - zone_id: str, + zone_id: str | None = None, custom_metadata: Dict[str, str] | Omit = omit, custom_origin_server: str | Omit = omit, custom_origin_sni: str | Omit = omit, @@ -371,12 +381,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: raise ValueError(f"Expected a non-empty value for `custom_hostname_id` but received {custom_hostname_id!r}") return self._patch( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + ), body=maybe_transform( { "custom_metadata": custom_metadata, @@ -400,7 +416,7 @@ def get( self, custom_hostname_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -425,12 +441,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: raise ValueError(f"Expected a non-empty value for `custom_hostname_id` but received {custom_hostname_id!r}") return self._get( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -473,7 +495,7 @@ def with_streaming_response(self) -> AsyncCustomHostnamesResourceWithStreamingRe async def create( self, *, - zone_id: str, + zone_id: str | None = None, hostname: str, custom_metadata: Dict[str, str] | Omit = omit, ssl: custom_hostname_create_params.SSL | Omit = omit, @@ -514,10 +536,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_hostnames", + path_template("/zones/{zone_id}/custom_hostnames", zone_id=zone_id), body=await async_maybe_transform( { "hostname": hostname, @@ -539,7 +563,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, id: str | Omit = omit, certificate_authority: Literal["google", "lets_encrypt", "ssl_com"] | Omit = omit, custom_origin_server: str | Omit = omit, @@ -638,10 +662,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_hostnames", + path_template("/zones/{zone_id}/custom_hostnames", zone_id=zone_id), page=AsyncV4PagePaginationArray[CustomHostnameListResponse], options=make_request_options( extra_headers=extra_headers, @@ -673,7 +699,7 @@ async def delete( self, custom_hostname_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -698,12 +724,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: raise ValueError(f"Expected a non-empty value for `custom_hostname_id` but received {custom_hostname_id!r}") return await self._delete( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -714,7 +746,7 @@ async def edit( self, custom_hostname_id: str, *, - zone_id: str, + zone_id: str | None = None, custom_metadata: Dict[str, str] | Omit = omit, custom_origin_server: str | Omit = omit, custom_origin_sni: str | Omit = omit, @@ -763,12 +795,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: raise ValueError(f"Expected a non-empty value for `custom_hostname_id` but received {custom_hostname_id!r}") return await self._patch( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + ), body=await async_maybe_transform( { "custom_metadata": custom_metadata, @@ -792,7 +830,7 @@ async def get( self, custom_hostname_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -817,12 +855,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not custom_hostname_id: raise ValueError(f"Expected a non-empty value for `custom_hostname_id` but received {custom_hostname_id!r}") return await self._get( - f"/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + path_template( + "/zones/{zone_id}/custom_hostnames/{custom_hostname_id}", + zone_id=zone_id, + custom_hostname_id=custom_hostname_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/custom_hostnames/fallback_origin.py b/src/cloudflare/resources/custom_hostnames/fallback_origin.py index 97e7faf3aff..6fe315240e2 100644 --- a/src/cloudflare/resources/custom_hostnames/fallback_origin.py +++ b/src/cloudflare/resources/custom_hostnames/fallback_origin.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> FallbackOriginResourceWithStreamingResponse def update( self, *, - zone_id: str, + zone_id: str | None = None, origin: 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. @@ -76,10 +76,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/custom_hostnames/fallback_origin", + path_template("/zones/{zone_id}/custom_hostnames/fallback_origin", zone_id=zone_id), body=maybe_transform({"origin": origin}, fallback_origin_update_params.FallbackOriginUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -94,7 +96,7 @@ def update( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -118,10 +120,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_hostnames/fallback_origin", + path_template("/zones/{zone_id}/custom_hostnames/fallback_origin", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -135,7 +139,7 @@ def delete( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -159,10 +163,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/custom_hostnames/fallback_origin", + path_template("/zones/{zone_id}/custom_hostnames/fallback_origin", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -197,7 +203,7 @@ def with_streaming_response(self) -> AsyncFallbackOriginResourceWithStreamingRes async def update( self, *, - zone_id: str, + zone_id: str | None = None, origin: 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. @@ -224,10 +230,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/custom_hostnames/fallback_origin", + path_template("/zones/{zone_id}/custom_hostnames/fallback_origin", zone_id=zone_id), body=await async_maybe_transform( {"origin": origin}, fallback_origin_update_params.FallbackOriginUpdateParams ), @@ -244,7 +252,7 @@ async def update( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -268,10 +276,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_hostnames/fallback_origin", + path_template("/zones/{zone_id}/custom_hostnames/fallback_origin", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -285,7 +295,7 @@ async def delete( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -309,10 +319,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/custom_hostnames/fallback_origin", + path_template("/zones/{zone_id}/custom_hostnames/fallback_origin", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/custom_nameservers/__init__.py b/src/cloudflare/resources/custom_nameservers/__init__.py new file mode 100644 index 00000000000..04baa69fa2e --- /dev/null +++ b/src/cloudflare/resources/custom_nameservers/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .custom_nameservers import ( + CustomNameserversResource, + AsyncCustomNameserversResource, + CustomNameserversResourceWithRawResponse, + AsyncCustomNameserversResourceWithRawResponse, + CustomNameserversResourceWithStreamingResponse, + AsyncCustomNameserversResourceWithStreamingResponse, +) + +__all__ = [ + "CustomNameserversResource", + "AsyncCustomNameserversResource", + "CustomNameserversResourceWithRawResponse", + "AsyncCustomNameserversResourceWithRawResponse", + "CustomNameserversResourceWithStreamingResponse", + "AsyncCustomNameserversResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/custom_nameservers/api.md b/src/cloudflare/resources/custom_nameservers/api.md new file mode 100644 index 00000000000..9079a27479b --- /dev/null +++ b/src/cloudflare/resources/custom_nameservers/api.md @@ -0,0 +1,13 @@ +# CustomNameservers + +Types: + +```python +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] diff --git a/src/cloudflare/resources/custom_nameservers.py b/src/cloudflare/resources/custom_nameservers/custom_nameservers.py similarity index 86% rename from src/cloudflare/resources/custom_nameservers.py rename to src/cloudflare/resources/custom_nameservers/custom_nameservers.py index 6545ebd198c..3cdc53f6db7 100644 --- a/src/cloudflare/resources/custom_nameservers.py +++ b/src/cloudflare/resources/custom_nameservers/custom_nameservers.py @@ -6,22 +6,22 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, 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.custom_nameservers import custom_nameserver_create_params -from ..types.custom_nameservers.custom_nameserver import CustomNameserver -from ..types.custom_nameservers.custom_nameserver_delete_response import CustomNameserverDeleteResponse +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import AsyncPaginator, make_request_options +from ...types.custom_nameservers import custom_nameserver_create_params +from ...types.custom_nameservers.custom_nameserver import CustomNameserver +from ...types.custom_nameservers.custom_nameserver_delete_response import CustomNameserverDeleteResponse __all__ = ["CustomNameserversResource", "AsyncCustomNameserversResource"] @@ -49,7 +49,7 @@ def with_streaming_response(self) -> CustomNameserversResourceWithStreamingRespo def create( self, *, - account_id: str, + account_id: str | None = None, ns_name: str, ns_set: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,10 +77,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/custom_ns", + path_template("/accounts/{account_id}/custom_ns", account_id=account_id), body=maybe_transform( { "ns_name": ns_name, @@ -102,7 +104,7 @@ def delete( self, custom_ns_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -126,12 +128,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not custom_ns_id: raise ValueError(f"Expected a non-empty value for `custom_ns_id` but received {custom_ns_id!r}") return self._get_api_list( - f"/accounts/{account_id}/custom_ns/{custom_ns_id}", + path_template( + "/accounts/{account_id}/custom_ns/{custom_ns_id}", account_id=account_id, custom_ns_id=custom_ns_id + ), page=SyncSinglePage[CustomNameserverDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -143,7 +149,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -165,10 +171,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/custom_ns", + path_template("/accounts/{account_id}/custom_ns", account_id=account_id), page=SyncSinglePage[CustomNameserver], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -200,7 +208,7 @@ def with_streaming_response(self) -> AsyncCustomNameserversResourceWithStreaming async def create( self, *, - account_id: str, + account_id: str | None = None, ns_name: str, ns_set: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -228,10 +236,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/custom_ns", + path_template("/accounts/{account_id}/custom_ns", account_id=account_id), body=await async_maybe_transform( { "ns_name": ns_name, @@ -253,7 +263,7 @@ def delete( self, custom_ns_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -277,12 +287,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not custom_ns_id: raise ValueError(f"Expected a non-empty value for `custom_ns_id` but received {custom_ns_id!r}") return self._get_api_list( - f"/accounts/{account_id}/custom_ns/{custom_ns_id}", + path_template( + "/accounts/{account_id}/custom_ns/{custom_ns_id}", account_id=account_id, custom_ns_id=custom_ns_id + ), page=AsyncSinglePage[CustomNameserverDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -294,7 +308,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -316,10 +330,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/custom_ns", + path_template("/accounts/{account_id}/custom_ns", account_id=account_id), page=AsyncSinglePage[CustomNameserver], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/custom_pages/api.md b/src/cloudflare/resources/custom_pages/api.md new file mode 100644 index 00000000000..19546e842fc --- /dev/null +++ b/src/cloudflare/resources/custom_pages/api.md @@ -0,0 +1,38 @@ +# CustomPages + +Types: + +```python +from cloudflare.types.custom_pages import ( + CustomPageUpdateResponse, + CustomPageListResponse, + CustomPageGetResponse, +) +``` + +Methods: + +- 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] + +## Assets + +Types: + +```python +from cloudflare.types.custom_pages import ( + AssetCreateResponse, + AssetUpdateResponse, + AssetListResponse, + AssetGetResponse, +) +``` + +Methods: + +- client.custom_pages.assets.create(\*, account_id, zone_id, \*\*params) -> Optional[AssetCreateResponse] +- client.custom_pages.assets.update(asset_name, \*, account_id, zone_id, \*\*params) -> Optional[AssetUpdateResponse] +- client.custom_pages.assets.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[AssetListResponse] +- client.custom_pages.assets.delete(asset_name, \*, account_id, zone_id) -> None +- client.custom_pages.assets.get(asset_name, \*, account_id, zone_id) -> Optional[AssetGetResponse] diff --git a/src/cloudflare/resources/custom_pages/assets.py b/src/cloudflare/resources/custom_pages/assets.py index 015ed93d46e..ff10ccab5ab 100644 --- a/src/cloudflare/resources/custom_pages/assets.py +++ b/src/cloudflare/resources/custom_pages/assets.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -54,8 +54,8 @@ def create( description: str, name: str, url: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -86,6 +86,10 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -99,7 +103,11 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "description": description, @@ -124,8 +132,8 @@ def update( *, description: str, url: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -158,6 +166,10 @@ def update( """ if not asset_name: raise ValueError(f"Expected a non-empty value for `asset_name` but received {asset_name!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -171,7 +183,12 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._put( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + asset_name=asset_name, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "description": description, @@ -192,8 +209,8 @@ def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -219,6 +236,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -232,7 +253,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncV4PagePaginationArray[AssetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -254,8 +279,8 @@ def delete( self, asset_name: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -284,6 +309,10 @@ def delete( """ if not asset_name: raise ValueError(f"Expected a non-empty value for `asset_name` but received {asset_name!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -298,7 +327,12 @@ def delete( account_or_zone_id = zone_id extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + asset_name=asset_name, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -309,8 +343,8 @@ def get( self, asset_name: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -339,6 +373,10 @@ def get( """ if not asset_name: raise ValueError(f"Expected a non-empty value for `asset_name` but received {asset_name!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -352,7 +390,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + asset_name=asset_name, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -390,8 +433,8 @@ async def create( description: str, name: str, url: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -422,6 +465,10 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -435,7 +482,11 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "description": description, @@ -460,8 +511,8 @@ async def update( *, description: str, url: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -494,6 +545,10 @@ async def update( """ if not asset_name: raise ValueError(f"Expected a non-empty value for `asset_name` but received {asset_name!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -507,7 +562,12 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + asset_name=asset_name, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "description": description, @@ -528,8 +588,8 @@ async def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -555,6 +615,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -568,7 +632,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncV4PagePaginationArray[AssetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -590,8 +658,8 @@ async def delete( self, asset_name: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -620,6 +688,10 @@ async def delete( """ if not asset_name: raise ValueError(f"Expected a non-empty value for `asset_name` but received {asset_name!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -634,7 +706,12 @@ async def delete( account_or_zone_id = zone_id extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + asset_name=asset_name, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -645,8 +722,8 @@ async def get( self, asset_name: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -675,6 +752,10 @@ async def get( """ if not asset_name: raise ValueError(f"Expected a non-empty value for `asset_name` but received {asset_name!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -688,7 +769,12 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/assets/{asset_name}", + asset_name=asset_name, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/custom_pages/custom_pages.py b/src/cloudflare/resources/custom_pages/custom_pages.py index 3d7169bb8de..79f52ab25bf 100644 --- a/src/cloudflare/resources/custom_pages/custom_pages.py +++ b/src/cloudflare/resources/custom_pages/custom_pages.py @@ -15,8 +15,8 @@ AssetsResourceWithStreamingResponse, AsyncAssetsResourceWithStreamingResponse, ) -from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -77,8 +77,8 @@ def update( *, state: Literal["default", "customized"], url: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -110,6 +110,10 @@ def update( """ if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -123,7 +127,12 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._put( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/{identifier}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/{identifier}", + identifier=identifier, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "state": state, @@ -144,8 +153,8 @@ def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -169,6 +178,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -182,7 +195,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncSinglePage[CustomPageListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -205,8 +222,8 @@ def get( "waf_challenge", ], *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -234,6 +251,10 @@ def get( """ if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -247,7 +268,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/{identifier}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/{identifier}", + identifier=identifier, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -300,8 +326,8 @@ async def update( *, state: Literal["default", "customized"], url: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -333,6 +359,10 @@ async def update( """ if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -346,7 +376,12 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/{identifier}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/{identifier}", + identifier=identifier, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "state": state, @@ -367,8 +402,8 @@ async def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -392,6 +427,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -405,7 +444,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncSinglePage[CustomPageListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -428,8 +471,8 @@ async def get( "waf_challenge", ], *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -457,6 +500,10 @@ async def get( """ if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -470,7 +517,12 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/custom_pages/{identifier}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/custom_pages/{identifier}", + identifier=identifier, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/d1/api.md b/src/cloudflare/resources/d1/api.md new file mode 100644 index 00000000000..74dbc31770d --- /dev/null +++ b/src/cloudflare/resources/d1/api.md @@ -0,0 +1,47 @@ +# D1 + +Types: + +```python +from cloudflare.types.d1 import D1 +``` + +## Database + +Types: + +```python +from cloudflare.types.d1 import ( + QueryResult, + DatabaseListResponse, + DatabaseExportResponse, + DatabaseImportResponse, + DatabaseRawResponse, +) +``` + +Methods: + +- 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] + +### TimeTravel + +Types: + +```python +from cloudflare.types.d1.database import TimeTravelGetBookmarkResponse, TimeTravelRestoreResponse +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/d1/database/database.py b/src/cloudflare/resources/d1/database/database.py index 75d928a5a70..e46402bff46 100644 --- a/src/cloudflare/resources/d1/database/database.py +++ b/src/cloudflare/resources/d1/database/database.py @@ -8,7 +8,7 @@ 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 ...._utils import path_template, required_args, maybe_transform, async_maybe_transform from ...._compat import cached_property from ....types.d1 import ( database_raw_params, @@ -75,7 +75,7 @@ def with_streaming_response(self) -> DatabaseResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, jurisdiction: Literal["eu", "fedramp"] | Omit = omit, primary_location_hint: Literal["wnam", "enam", "weur", "eeur", "apac", "oc"] | Omit = omit, @@ -108,10 +108,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/d1/database", + path_template("/accounts/{account_id}/d1/database", account_id=account_id), body=maybe_transform( { "name": name, @@ -134,7 +136,7 @@ def update( self, database_id: str, *, - account_id: str, + account_id: str | None = None, read_replication: database_update_params.ReadReplication, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -161,12 +163,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._put( - f"/accounts/{account_id}/d1/database/{database_id}", + path_template( + "/accounts/{account_id}/d1/database/{database_id}", account_id=account_id, database_id=database_id + ), body=maybe_transform({"read_replication": read_replication}, database_update_params.DatabaseUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -181,7 +187,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -212,10 +218,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/d1/database", + path_template("/accounts/{account_id}/d1/database", account_id=account_id), page=SyncV4PagePaginationArray[DatabaseListResponse], options=make_request_options( extra_headers=extra_headers, @@ -238,7 +246,7 @@ def delete( self, database_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -262,12 +270,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._delete( - f"/accounts/{account_id}/d1/database/{database_id}", + path_template( + "/accounts/{account_id}/d1/database/{database_id}", account_id=account_id, database_id=database_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -282,7 +294,7 @@ def edit( self, database_id: str, *, - account_id: str, + account_id: str | None = None, read_replication: database_edit_params.ReadReplication | 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. @@ -309,12 +321,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._patch( - f"/accounts/{account_id}/d1/database/{database_id}", + path_template( + "/accounts/{account_id}/d1/database/{database_id}", account_id=account_id, database_id=database_id + ), body=maybe_transform({"read_replication": read_replication}, database_edit_params.DatabaseEditParams), options=make_request_options( extra_headers=extra_headers, @@ -330,7 +346,7 @@ def export( self, database_id: str, *, - account_id: str, + account_id: str | None = None, output_format: Literal["polling"], current_bookmark: str | Omit = omit, dump_options: database_export_params.DumpOptions | Omit = omit, @@ -366,12 +382,18 @@ def export( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._post( - f"/accounts/{account_id}/d1/database/{database_id}/export", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/export", + account_id=account_id, + database_id=database_id, + ), body=maybe_transform( { "output_format": output_format, @@ -394,7 +416,7 @@ def get( self, database_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -418,12 +440,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._get( - f"/accounts/{account_id}/d1/database/{database_id}", + path_template( + "/accounts/{account_id}/d1/database/{database_id}", account_id=account_id, database_id=database_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -439,7 +465,7 @@ def import_( self, database_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal["init"], etag: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -480,7 +506,7 @@ def import_( self, database_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal["ingest"], etag: str, filename: str, @@ -523,7 +549,7 @@ def import_( self, database_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal["poll"], current_bookmark: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -557,16 +583,12 @@ def import_( """ ... - @required_args( - ["account_id", "action", "etag"], - ["account_id", "action", "etag", "filename"], - ["account_id", "action", "current_bookmark"], - ) + @required_args(["action", "etag"], ["action", "etag", "filename"], ["action", "current_bookmark"]) def import_( self, database_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal["init"] | Literal["ingest"] | Literal["poll"], etag: str | Omit = omit, filename: str | Omit = omit, @@ -578,12 +600,18 @@ def import_( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatabaseImportResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._post( - f"/accounts/{account_id}/d1/database/{database_id}/import", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/import", + account_id=account_id, + database_id=database_id, + ), body=maybe_transform( { "action": action, @@ -608,7 +636,7 @@ def query( self, database_id: str, *, - account_id: str, + account_id: str | None = None, sql: str, params: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -644,7 +672,7 @@ def query( self, database_id: str, *, - account_id: str, + account_id: str | None = None, batch: Iterable[database_query_params.MultipleQueriesBatch], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -671,12 +699,12 @@ def query( """ ... - @required_args(["account_id", "sql"], ["account_id", "batch"]) + @required_args(["sql"], ["batch"]) def query( self, database_id: str, *, - account_id: str, + account_id: str | None = None, sql: str | Omit = omit, params: SequenceNotStr[str] | Omit = omit, batch: Iterable[database_query_params.MultipleQueriesBatch] | Omit = omit, @@ -687,12 +715,16 @@ def query( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[QueryResult]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._get_api_list( - f"/accounts/{account_id}/d1/database/{database_id}/query", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/query", account_id=account_id, database_id=database_id + ), page=SyncSinglePage[QueryResult], body=maybe_transform( { @@ -714,7 +746,7 @@ def raw( self, database_id: str, *, - account_id: str, + account_id: str | None = None, sql: str, params: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -752,7 +784,7 @@ def raw( self, database_id: str, *, - account_id: str, + account_id: str | None = None, batch: Iterable[database_raw_params.MultipleQueriesBatch], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -781,12 +813,12 @@ def raw( """ ... - @required_args(["account_id", "sql"], ["account_id", "batch"]) + @required_args(["sql"], ["batch"]) def raw( self, database_id: str, *, - account_id: str, + account_id: str | None = None, sql: str | Omit = omit, params: SequenceNotStr[str] | Omit = omit, batch: Iterable[database_raw_params.MultipleQueriesBatch] | Omit = omit, @@ -797,12 +829,16 @@ def raw( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[DatabaseRawResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._get_api_list( - f"/accounts/{account_id}/d1/database/{database_id}/raw", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/raw", account_id=account_id, database_id=database_id + ), page=SyncSinglePage[DatabaseRawResponse], body=maybe_transform( { @@ -847,7 +883,7 @@ def with_streaming_response(self) -> AsyncDatabaseResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, jurisdiction: Literal["eu", "fedramp"] | Omit = omit, primary_location_hint: Literal["wnam", "enam", "weur", "eeur", "apac", "oc"] | Omit = omit, @@ -880,10 +916,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/d1/database", + path_template("/accounts/{account_id}/d1/database", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -906,7 +944,7 @@ async def update( self, database_id: str, *, - account_id: str, + account_id: str | None = None, read_replication: database_update_params.ReadReplication, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -933,12 +971,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return await self._put( - f"/accounts/{account_id}/d1/database/{database_id}", + path_template( + "/accounts/{account_id}/d1/database/{database_id}", account_id=account_id, database_id=database_id + ), body=await async_maybe_transform( {"read_replication": read_replication}, database_update_params.DatabaseUpdateParams ), @@ -955,7 +997,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -986,10 +1028,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/d1/database", + path_template("/accounts/{account_id}/d1/database", account_id=account_id), page=AsyncV4PagePaginationArray[DatabaseListResponse], options=make_request_options( extra_headers=extra_headers, @@ -1012,7 +1056,7 @@ async def delete( self, database_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1036,12 +1080,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return await self._delete( - f"/accounts/{account_id}/d1/database/{database_id}", + path_template( + "/accounts/{account_id}/d1/database/{database_id}", account_id=account_id, database_id=database_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1056,7 +1104,7 @@ async def edit( self, database_id: str, *, - account_id: str, + account_id: str | None = None, read_replication: database_edit_params.ReadReplication | 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. @@ -1083,12 +1131,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return await self._patch( - f"/accounts/{account_id}/d1/database/{database_id}", + path_template( + "/accounts/{account_id}/d1/database/{database_id}", account_id=account_id, database_id=database_id + ), body=await async_maybe_transform( {"read_replication": read_replication}, database_edit_params.DatabaseEditParams ), @@ -1106,7 +1158,7 @@ async def export( self, database_id: str, *, - account_id: str, + account_id: str | None = None, output_format: Literal["polling"], current_bookmark: str | Omit = omit, dump_options: database_export_params.DumpOptions | Omit = omit, @@ -1142,12 +1194,18 @@ async def export( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return await self._post( - f"/accounts/{account_id}/d1/database/{database_id}/export", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/export", + account_id=account_id, + database_id=database_id, + ), body=await async_maybe_transform( { "output_format": output_format, @@ -1170,7 +1228,7 @@ async def get( self, database_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1194,12 +1252,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return await self._get( - f"/accounts/{account_id}/d1/database/{database_id}", + path_template( + "/accounts/{account_id}/d1/database/{database_id}", account_id=account_id, database_id=database_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1215,7 +1277,7 @@ async def import_( self, database_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal["init"], etag: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1256,7 +1318,7 @@ async def import_( self, database_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal["ingest"], etag: str, filename: str, @@ -1299,7 +1361,7 @@ async def import_( self, database_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal["poll"], current_bookmark: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1333,16 +1395,12 @@ async def import_( """ ... - @required_args( - ["account_id", "action", "etag"], - ["account_id", "action", "etag", "filename"], - ["account_id", "action", "current_bookmark"], - ) + @required_args(["action", "etag"], ["action", "etag", "filename"], ["action", "current_bookmark"]) async def import_( self, database_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal["init"] | Literal["ingest"] | Literal["poll"], etag: str | Omit = omit, filename: str | Omit = omit, @@ -1354,12 +1412,18 @@ async def import_( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatabaseImportResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return await self._post( - f"/accounts/{account_id}/d1/database/{database_id}/import", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/import", + account_id=account_id, + database_id=database_id, + ), body=await async_maybe_transform( { "action": action, @@ -1384,7 +1448,7 @@ def query( self, database_id: str, *, - account_id: str, + account_id: str | None = None, sql: str, params: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1420,7 +1484,7 @@ def query( self, database_id: str, *, - account_id: str, + account_id: str | None = None, batch: Iterable[database_query_params.MultipleQueriesBatch], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -1447,12 +1511,12 @@ def query( """ ... - @required_args(["account_id", "sql"], ["account_id", "batch"]) + @required_args(["sql"], ["batch"]) def query( self, database_id: str, *, - account_id: str, + account_id: str | None = None, sql: str | Omit = omit, params: SequenceNotStr[str] | Omit = omit, batch: Iterable[database_query_params.MultipleQueriesBatch] | Omit = omit, @@ -1463,12 +1527,16 @@ def query( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[QueryResult, AsyncSinglePage[QueryResult]]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._get_api_list( - f"/accounts/{account_id}/d1/database/{database_id}/query", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/query", account_id=account_id, database_id=database_id + ), page=AsyncSinglePage[QueryResult], body=maybe_transform( { @@ -1490,7 +1558,7 @@ def raw( self, database_id: str, *, - account_id: str, + account_id: str | None = None, sql: str, params: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1528,7 +1596,7 @@ def raw( self, database_id: str, *, - account_id: str, + account_id: str | None = None, batch: Iterable[database_raw_params.MultipleQueriesBatch], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -1557,12 +1625,12 @@ def raw( """ ... - @required_args(["account_id", "sql"], ["account_id", "batch"]) + @required_args(["sql"], ["batch"]) def raw( self, database_id: str, *, - account_id: str, + account_id: str | None = None, sql: str | Omit = omit, params: SequenceNotStr[str] | Omit = omit, batch: Iterable[database_raw_params.MultipleQueriesBatch] | Omit = omit, @@ -1573,12 +1641,16 @@ def raw( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[DatabaseRawResponse, AsyncSinglePage[DatabaseRawResponse]]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._get_api_list( - f"/accounts/{account_id}/d1/database/{database_id}/raw", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/raw", account_id=account_id, database_id=database_id + ), page=AsyncSinglePage[DatabaseRawResponse], body=maybe_transform( { diff --git a/src/cloudflare/resources/d1/database/time_travel.py b/src/cloudflare/resources/d1/database/time_travel.py index a3f6c68447d..666fbab7fbb 100644 --- a/src/cloudflare/resources/d1/database/time_travel.py +++ b/src/cloudflare/resources/d1/database/time_travel.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def get_bookmark( self, database_id: str, *, - account_id: str, + account_id: str | None = None, timestamp: 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. @@ -80,12 +80,18 @@ def get_bookmark( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._get( - f"/accounts/{account_id}/d1/database/{database_id}/time_travel/bookmark", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/time_travel/bookmark", + account_id=account_id, + database_id=database_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -103,7 +109,7 @@ def restore( self, database_id: str, *, - account_id: str, + account_id: str | None = None, bookmark: str | Omit = omit, timestamp: 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. @@ -135,12 +141,18 @@ def restore( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return self._post( - f"/accounts/{account_id}/d1/database/{database_id}/time_travel/restore", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/time_travel/restore", + account_id=account_id, + database_id=database_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -183,7 +195,7 @@ async def get_bookmark( self, database_id: str, *, - account_id: str, + account_id: str | None = None, timestamp: 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. @@ -213,12 +225,18 @@ async def get_bookmark( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return await self._get( - f"/accounts/{account_id}/d1/database/{database_id}/time_travel/bookmark", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/time_travel/bookmark", + account_id=account_id, + database_id=database_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -236,7 +254,7 @@ async def restore( self, database_id: str, *, - account_id: str, + account_id: str | None = None, bookmark: str | Omit = omit, timestamp: 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. @@ -268,12 +286,18 @@ async def restore( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not database_id: raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") return await self._post( - f"/accounts/{account_id}/d1/database/{database_id}/time_travel/restore", + path_template( + "/accounts/{account_id}/d1/database/{database_id}/time_travel/restore", + account_id=account_id, + database_id=database_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dcv_delegation/__init__.py b/src/cloudflare/resources/dcv_delegation/__init__.py new file mode 100644 index 00000000000..28d821d9210 --- /dev/null +++ b/src/cloudflare/resources/dcv_delegation/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .dcv_delegation import ( + DCVDelegationResource, + AsyncDCVDelegationResource, + DCVDelegationResourceWithRawResponse, + AsyncDCVDelegationResourceWithRawResponse, + DCVDelegationResourceWithStreamingResponse, + AsyncDCVDelegationResourceWithStreamingResponse, +) + +__all__ = [ + "DCVDelegationResource", + "AsyncDCVDelegationResource", + "DCVDelegationResourceWithRawResponse", + "AsyncDCVDelegationResourceWithRawResponse", + "DCVDelegationResourceWithStreamingResponse", + "AsyncDCVDelegationResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/dcv_delegation/api.md b/src/cloudflare/resources/dcv_delegation/api.md new file mode 100644 index 00000000000..b24764b09a3 --- /dev/null +++ b/src/cloudflare/resources/dcv_delegation/api.md @@ -0,0 +1,11 @@ +# DCVDelegation + +Types: + +```python +from cloudflare.types.dcv_delegation import DCVDelegationUUID +``` + +Methods: + +- client.dcv_delegation.get(\*, zone_id) -> Optional[DCVDelegationUUID] diff --git a/src/cloudflare/resources/dcv_delegation.py b/src/cloudflare/resources/dcv_delegation/dcv_delegation.py similarity index 88% rename from src/cloudflare/resources/dcv_delegation.py rename to src/cloudflare/resources/dcv_delegation/dcv_delegation.py index f421bf26ac2..df1dc2f8e60 100644 --- a/src/cloudflare/resources/dcv_delegation.py +++ b/src/cloudflare/resources/dcv_delegation/dcv_delegation.py @@ -6,18 +6,19 @@ import httpx -from .._types import Body, Query, Headers, NotGiven, not_given -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template +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.dcv_delegation.dcv_delegation_uuid import DCVDelegationUUID +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.dcv_delegation.dcv_delegation_uuid import DCVDelegationUUID __all__ = ["DCVDelegationResource", "AsyncDCVDelegationResource"] @@ -45,7 +46,7 @@ def with_streaming_response(self) -> DCVDelegationResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,10 +69,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/dcv_delegation/uuid", + path_template("/zones/{zone_id}/dcv_delegation/uuid", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -106,7 +109,7 @@ def with_streaming_response(self) -> AsyncDCVDelegationResourceWithStreamingResp async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -129,10 +132,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/dcv_delegation/uuid", + path_template("/zones/{zone_id}/dcv_delegation/uuid", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/diagnostics/api.md b/src/cloudflare/resources/diagnostics/api.md new file mode 100644 index 00000000000..f3058910ae9 --- /dev/null +++ b/src/cloudflare/resources/diagnostics/api.md @@ -0,0 +1,36 @@ +# Diagnostics + +## Traceroutes + +Types: + +```python +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.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] diff --git a/src/cloudflare/resources/diagnostics/endpoint_healthchecks.py b/src/cloudflare/resources/diagnostics/endpoint_healthchecks.py index 0bba3422e7d..84b91e5da26 100644 --- a/src/cloudflare/resources/diagnostics/endpoint_healthchecks.py +++ b/src/cloudflare/resources/diagnostics/endpoint_healthchecks.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> EndpointHealthchecksResourceWithStreamingRe def create( self, *, - account_id: str, + account_id: str | None = None, check_type: Literal["icmp"], endpoint: str, name: str | Omit = omit, @@ -83,10 +83,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks", + path_template("/accounts/{account_id}/diagnostics/endpoint-healthchecks", account_id=account_id), body=maybe_transform( { "check_type": check_type, @@ -111,7 +113,7 @@ def update( self, id: str, *, - account_id: str, + account_id: str | None = None, check_type: Literal["icmp"], endpoint: str, name: str | Omit = omit, @@ -144,12 +146,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks/{id}", + path_template( + "/accounts/{account_id}/diagnostics/endpoint-healthchecks/{id}", account_id=account_id, id=id + ), body=maybe_transform( { "check_type": check_type, @@ -173,7 +179,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -195,10 +201,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks", + path_template("/accounts/{account_id}/diagnostics/endpoint-healthchecks", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -215,7 +223,7 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -239,12 +247,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks/{id}", + path_template( + "/accounts/{account_id}/diagnostics/endpoint-healthchecks/{id}", account_id=account_id, id=id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -255,7 +267,7 @@ def get( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -279,12 +291,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks/{id}", + path_template( + "/accounts/{account_id}/diagnostics/endpoint-healthchecks/{id}", account_id=account_id, id=id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -319,7 +335,7 @@ def with_streaming_response(self) -> AsyncEndpointHealthchecksResourceWithStream async def create( self, *, - account_id: str, + account_id: str | None = None, check_type: Literal["icmp"], endpoint: str, name: str | Omit = omit, @@ -350,10 +366,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks", + path_template("/accounts/{account_id}/diagnostics/endpoint-healthchecks", account_id=account_id), body=await async_maybe_transform( { "check_type": check_type, @@ -378,7 +396,7 @@ async def update( self, id: str, *, - account_id: str, + account_id: str | None = None, check_type: Literal["icmp"], endpoint: str, name: str | Omit = omit, @@ -411,12 +429,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks/{id}", + path_template( + "/accounts/{account_id}/diagnostics/endpoint-healthchecks/{id}", account_id=account_id, id=id + ), body=await async_maybe_transform( { "check_type": check_type, @@ -440,7 +462,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -462,10 +484,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks", + path_template("/accounts/{account_id}/diagnostics/endpoint-healthchecks", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -482,7 +506,7 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -506,12 +530,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks/{id}", + path_template( + "/accounts/{account_id}/diagnostics/endpoint-healthchecks/{id}", account_id=account_id, id=id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -522,7 +550,7 @@ async def get( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -546,12 +574,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/endpoint-healthchecks/{id}", + path_template( + "/accounts/{account_id}/diagnostics/endpoint-healthchecks/{id}", account_id=account_id, id=id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/diagnostics/traceroutes.py b/src/cloudflare/resources/diagnostics/traceroutes.py index 115fbfcfeb8..dfe0db671f6 100644 --- a/src/cloudflare/resources/diagnostics/traceroutes.py +++ b/src/cloudflare/resources/diagnostics/traceroutes.py @@ -5,7 +5,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +45,7 @@ def with_streaming_response(self) -> TraceroutesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, targets: SequenceNotStr[str], colos: SequenceNotStr[str] | Omit = omit, options: traceroute_create_params.Options | Omit = omit, @@ -73,10 +73,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/traceroute", + path_template("/accounts/{account_id}/diagnostics/traceroute", account_id=account_id), page=SyncSinglePage[Traceroute], body=maybe_transform( { @@ -117,7 +119,7 @@ def with_streaming_response(self) -> AsyncTraceroutesResourceWithStreamingRespon def create( self, *, - account_id: str, + account_id: str | None = None, targets: SequenceNotStr[str], colos: SequenceNotStr[str] | Omit = omit, options: traceroute_create_params.Options | Omit = omit, @@ -145,10 +147,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/diagnostics/traceroute", + path_template("/accounts/{account_id}/diagnostics/traceroute", account_id=account_id), page=AsyncSinglePage[Traceroute], body=maybe_transform( { diff --git a/src/cloudflare/resources/dns/analytics/reports/bytimes.py b/src/cloudflare/resources/dns/analytics/reports/bytimes.py index ea25529f907..fec9a17fbba 100644 --- a/src/cloudflare/resources/dns/analytics/reports/bytimes.py +++ b/src/cloudflare/resources/dns/analytics/reports/bytimes.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> BytimesResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, dimensions: str | Omit = omit, filters: str | Omit = omit, limit: int | Omit = omit, @@ -101,10 +101,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/dns_analytics/report/bytime", + path_template("/zones/{zone_id}/dns_analytics/report/bytime", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -152,7 +154,7 @@ def with_streaming_response(self) -> AsyncBytimesResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, dimensions: str | Omit = omit, filters: str | Omit = omit, limit: int | Omit = omit, @@ -204,10 +206,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/dns_analytics/report/bytime", + path_template("/zones/{zone_id}/dns_analytics/report/bytime", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/analytics/reports/reports.py b/src/cloudflare/resources/dns/analytics/reports/reports.py index 2d1379eb601..822f16ac4a1 100644 --- a/src/cloudflare/resources/dns/analytics/reports/reports.py +++ b/src/cloudflare/resources/dns/analytics/reports/reports.py @@ -16,7 +16,7 @@ AsyncBytimesResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -60,7 +60,7 @@ def with_streaming_response(self) -> ReportsResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, dimensions: str | Omit = omit, filters: str | Omit = omit, limit: int | Omit = omit, @@ -108,10 +108,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/dns_analytics/report", + path_template("/zones/{zone_id}/dns_analytics/report", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -162,7 +164,7 @@ def with_streaming_response(self) -> AsyncReportsResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, dimensions: str | Omit = omit, filters: str | Omit = omit, limit: int | Omit = omit, @@ -210,10 +212,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/dns_analytics/report", + path_template("/zones/{zone_id}/dns_analytics/report", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/api.md b/src/cloudflare/resources/dns/api.md new file mode 100644 index 00000000000..73fb955aeed --- /dev/null +++ b/src/cloudflare/resources/dns/api.md @@ -0,0 +1,266 @@ +# DNS + +## DNSSEC + +Types: + +```python +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: + +```python +from cloudflare.types.dns import ( + ARecord, + AAAARecord, + BatchPatch, + BatchPut, + CAARecord, + CERTRecord, + CNAMERecord, + DNSKEYRecord, + DSRecord, + HTTPSRecord, + LOCRecord, + MXRecord, + NAPTRRecord, + NSRecord, + PTRRecord, + Record, + RecordResponse, + RecordTags, + SMIMEARecord, + SRVRecord, + SSHFPRecord, + SVCBRecord, + TLSARecord, + TTL, + TXTRecord, + URIRecord, + RecordDeleteResponse, + RecordBatchResponse, + RecordExportResponse, + RecordImportResponse, + RecordScanResponse, + RecordScanReviewResponse, + RecordScanTriggerResponse, +) +``` + +Methods: + +- 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[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.settings import ZoneEditResponse, ZoneGetResponse +``` + +Methods: + +- client.dns.settings.zone.edit(\*, zone_id, \*\*params) -> Optional[ZoneEditResponse] +- client.dns.settings.zone.get(\*, zone_id) -> Optional[ZoneGetResponse] + +### Account + +Types: + +```python +from cloudflare.types.dns.settings import AccountEditResponse, AccountGetResponse +``` + +Methods: + +- client.dns.settings.account.edit(\*, account_id, \*\*params) -> Optional[AccountEditResponse] +- client.dns.settings.account.get(\*, account_id) -> Optional[AccountGetResponse] + +#### Views + +Types: + +```python +from cloudflare.types.dns.settings.account import ( + ViewCreateResponse, + ViewListResponse, + ViewDeleteResponse, + ViewEditResponse, + ViewGetResponse, +) +``` + +Methods: + +- 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 + +### Reports + +Types: + +```python +from cloudflare.types.dns.analytics import Report +``` + +Methods: + +- client.dns.analytics.reports.get(\*, zone_id, \*\*params) -> Optional[Report] + +#### Bytimes + +Types: + +```python +from cloudflare.types.dns.analytics.reports import ByTime +``` + +Methods: + +- client.dns.analytics.reports.bytimes.get(\*, zone_id, \*\*params) -> Optional[ByTime] + +## ZoneTransfers + +### ForceAXFR + +Types: + +```python +from cloudflare.types.dns.zone_transfers import ForceAXFR +``` + +Methods: + +- client.dns.zone_transfers.force_axfr.create(\*, zone_id, \*\*params) -> str + +### Incoming + +Types: + +```python +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] diff --git a/src/cloudflare/resources/dns/dnssec.py b/src/cloudflare/resources/dns/dnssec.py index a2b78039737..ac3e39bc4b0 100644 --- a/src/cloudflare/resources/dns/dnssec.py +++ b/src/cloudflare/resources/dns/dnssec.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> DNSSECResourceWithStreamingResponse: def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -71,10 +71,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dnssec", + path_template("/zones/{zone_id}/dnssec", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -88,7 +90,7 @@ def delete( def edit( self, *, - zone_id: str, + zone_id: str | None = None, dnssec_multi_signer: bool | Omit = omit, dnssec_presigned: bool | Omit = omit, dnssec_use_nsec3: bool | Omit = omit, @@ -143,10 +145,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dnssec", + path_template("/zones/{zone_id}/dnssec", zone_id=zone_id), body=maybe_transform( { "dnssec_multi_signer": dnssec_multi_signer, @@ -169,7 +173,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -191,10 +195,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/dnssec", + path_template("/zones/{zone_id}/dnssec", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,7 +235,7 @@ def with_streaming_response(self) -> AsyncDNSSECResourceWithStreamingResponse: async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -251,10 +257,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dnssec", + path_template("/zones/{zone_id}/dnssec", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -268,7 +276,7 @@ async def delete( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, dnssec_multi_signer: bool | Omit = omit, dnssec_presigned: bool | Omit = omit, dnssec_use_nsec3: bool | Omit = omit, @@ -323,10 +331,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dnssec", + path_template("/zones/{zone_id}/dnssec", zone_id=zone_id), body=await async_maybe_transform( { "dnssec_multi_signer": dnssec_multi_signer, @@ -349,7 +359,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -371,10 +381,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/dnssec", + path_template("/zones/{zone_id}/dnssec", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/records.py b/src/cloudflare/resources/dns/records.py index c73370adfa8..8a8dcf13d6b 100644 --- a/src/cloudflare/resources/dns/records.py +++ b/src/cloudflare/resources/dns/records.py @@ -9,7 +9,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -71,7 +71,7 @@ def with_streaming_response(self) -> RecordsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"], @@ -137,7 +137,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["AAAA"], @@ -203,7 +203,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CNAME"], @@ -266,7 +266,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["MX"], @@ -334,7 +334,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NS"], @@ -397,7 +397,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["OPENPGPKEY"], @@ -460,7 +460,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["PTR"], @@ -523,7 +523,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TXT"], @@ -591,7 +591,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CAA"], @@ -654,7 +654,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CERT"], @@ -717,7 +717,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DNSKEY"], @@ -780,7 +780,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DS"], @@ -843,7 +843,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["HTTPS"], @@ -906,7 +906,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["LOC"], @@ -969,7 +969,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NAPTR"], @@ -1032,7 +1032,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SMIMEA"], @@ -1095,7 +1095,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SRV"], @@ -1158,7 +1158,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SSHFP"], @@ -1221,7 +1221,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SVCB"], @@ -1284,7 +1284,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TLSA"], @@ -1347,7 +1347,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["URI"], @@ -1411,11 +1411,11 @@ def create( """ ... - @required_args(["zone_id", "name", "ttl", "type"]) + @required_args(["name", "ttl", "type"]) def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"] @@ -1488,12 +1488,14 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RecordResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[RecordResponse], self._post( - f"/zones/{zone_id}/dns_records", + path_template("/zones/{zone_id}/dns_records", zone_id=zone_id), body=maybe_transform( { "name": name, @@ -1528,7 +1530,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"], @@ -1597,7 +1599,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["AAAA"], @@ -1666,7 +1668,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CNAME"], @@ -1732,7 +1734,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["MX"], @@ -1803,7 +1805,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NS"], @@ -1869,7 +1871,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["OPENPGPKEY"], @@ -1935,7 +1937,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["PTR"], @@ -2001,7 +2003,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TXT"], @@ -2072,7 +2074,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CAA"], @@ -2138,7 +2140,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CERT"], @@ -2204,7 +2206,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DNSKEY"], @@ -2270,7 +2272,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DS"], @@ -2336,7 +2338,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["HTTPS"], @@ -2402,7 +2404,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["LOC"], @@ -2468,7 +2470,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NAPTR"], @@ -2534,7 +2536,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SMIMEA"], @@ -2600,7 +2602,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SRV"], @@ -2666,7 +2668,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SSHFP"], @@ -2732,7 +2734,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SVCB"], @@ -2798,7 +2800,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TLSA"], @@ -2864,7 +2866,7 @@ def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["URI"], @@ -2930,12 +2932,12 @@ def update( """ ... - @required_args(["zone_id", "name", "ttl", "type"]) + @required_args(["name", "ttl", "type"]) def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"] @@ -3008,6 +3010,8 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RecordResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not dns_record_id: @@ -3015,7 +3019,9 @@ def update( return cast( Optional[RecordResponse], self._put( - f"/zones/{zone_id}/dns_records/{dns_record_id}", + path_template( + "/zones/{zone_id}/dns_records/{dns_record_id}", zone_id=zone_id, dns_record_id=dns_record_id + ), body=maybe_transform( { "name": name, @@ -3048,7 +3054,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, comment: record_list_params.Comment | Omit = omit, content: record_list_params.Content | Omit = omit, direction: SortDirection | Omit = omit, @@ -3135,10 +3141,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records", + path_template("/zones/{zone_id}/dns_records", zone_id=zone_id), page=SyncV4PagePaginationArray[RecordResponse], options=make_request_options( extra_headers=extra_headers, @@ -3171,7 +3179,7 @@ def delete( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -3195,12 +3203,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not dns_record_id: raise ValueError(f"Expected a non-empty value for `dns_record_id` but received {dns_record_id!r}") return self._delete( - f"/zones/{zone_id}/dns_records/{dns_record_id}", + path_template("/zones/{zone_id}/dns_records/{dns_record_id}", zone_id=zone_id, dns_record_id=dns_record_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -3214,7 +3224,7 @@ def delete( def batch( self, *, - zone_id: str, + zone_id: str | None = None, deletes: Iterable[record_batch_params.Delete] | Omit = omit, patches: Iterable[BatchPatchParam] | Omit = omit, posts: Iterable[record_batch_params.Post] | Omit = omit, @@ -3256,10 +3266,12 @@ def batch( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/batch", + path_template("/zones/{zone_id}/dns_records/batch", zone_id=zone_id), body=maybe_transform( { "deletes": deletes, @@ -3284,7 +3296,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"], @@ -3353,7 +3365,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["AAAA"], @@ -3422,7 +3434,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CNAME"], @@ -3488,7 +3500,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["MX"], @@ -3559,7 +3571,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NS"], @@ -3625,7 +3637,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["OPENPGPKEY"], @@ -3691,7 +3703,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["PTR"], @@ -3757,7 +3769,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TXT"], @@ -3828,7 +3840,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CAA"], @@ -3894,7 +3906,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CERT"], @@ -3960,7 +3972,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DNSKEY"], @@ -4026,7 +4038,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DS"], @@ -4092,7 +4104,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["HTTPS"], @@ -4158,7 +4170,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["LOC"], @@ -4224,7 +4236,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NAPTR"], @@ -4290,7 +4302,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SMIMEA"], @@ -4356,7 +4368,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SRV"], @@ -4422,7 +4434,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SSHFP"], @@ -4488,7 +4500,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SVCB"], @@ -4554,7 +4566,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TLSA"], @@ -4620,7 +4632,7 @@ def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["URI"], @@ -4686,12 +4698,12 @@ def edit( """ ... - @required_args(["zone_id", "name", "ttl", "type"]) + @required_args(["name", "ttl", "type"]) def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"] @@ -4764,6 +4776,8 @@ def edit( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RecordResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not dns_record_id: @@ -4771,7 +4785,9 @@ def edit( return cast( Optional[RecordResponse], self._patch( - f"/zones/{zone_id}/dns_records/{dns_record_id}", + path_template( + "/zones/{zone_id}/dns_records/{dns_record_id}", zone_id=zone_id, dns_record_id=dns_record_id + ), body=maybe_transform( { "name": name, @@ -4804,7 +4820,7 @@ def edit( def export( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -4832,11 +4848,13 @@ def export( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {"Accept": "text/plain", **(extra_headers or {})} return self._get( - f"/zones/{zone_id}/dns_records/export", + path_template("/zones/{zone_id}/dns_records/export", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -4847,7 +4865,7 @@ def get( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -4871,6 +4889,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not dns_record_id: @@ -4878,7 +4898,9 @@ def get( return cast( Optional[RecordResponse], self._get( - f"/zones/{zone_id}/dns_records/{dns_record_id}", + path_template( + "/zones/{zone_id}/dns_records/{dns_record_id}", zone_id=zone_id, dns_record_id=dns_record_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -4895,7 +4917,7 @@ def get( def import_( self, *, - zone_id: str, + zone_id: str | None = None, file: str, proxied: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -4936,6 +4958,8 @@ def import_( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") # It should be noted that the actual Content-Type header that will be @@ -4943,7 +4967,7 @@ def import_( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( - f"/zones/{zone_id}/dns_records/import", + path_template("/zones/{zone_id}/dns_records/import", zone_id=zone_id), body=maybe_transform( { "file": file, @@ -4967,7 +4991,7 @@ def import_( def scan( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -4991,10 +5015,12 @@ def scan( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/scan", + path_template("/zones/{zone_id}/dns_records/scan", zone_id=zone_id), body=maybe_transform(body, record_scan_params.RecordScanParams), options=make_request_options( extra_headers=extra_headers, @@ -5009,7 +5035,7 @@ def scan( def scan_list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -5034,10 +5060,12 @@ def scan_list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/scan/review", + path_template("/zones/{zone_id}/dns_records/scan/review", zone_id=zone_id), page=SyncSinglePage[RecordResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -5048,7 +5076,7 @@ def scan_list( def scan_review( self, *, - zone_id: str, + zone_id: str | None = None, accepts: Iterable[record_scan_review_params.Accept] | Omit = omit, rejects: Iterable[record_scan_review_params.Reject] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -5075,10 +5103,12 @@ def scan_review( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/scan/review", + path_template("/zones/{zone_id}/dns_records/scan/review", zone_id=zone_id), body=maybe_transform( { "accepts": accepts, @@ -5099,7 +5129,7 @@ def scan_review( def scan_trigger( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -5125,10 +5155,12 @@ def scan_trigger( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/scan/trigger", + path_template("/zones/{zone_id}/dns_records/scan/trigger", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -5160,7 +5192,7 @@ def with_streaming_response(self) -> AsyncRecordsResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"], @@ -5226,7 +5258,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["AAAA"], @@ -5292,7 +5324,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CNAME"], @@ -5355,7 +5387,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["MX"], @@ -5423,7 +5455,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NS"], @@ -5486,7 +5518,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["OPENPGPKEY"], @@ -5549,7 +5581,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["PTR"], @@ -5612,7 +5644,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TXT"], @@ -5680,7 +5712,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CAA"], @@ -5743,7 +5775,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CERT"], @@ -5806,7 +5838,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DNSKEY"], @@ -5869,7 +5901,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DS"], @@ -5932,7 +5964,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["HTTPS"], @@ -5995,7 +6027,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["LOC"], @@ -6058,7 +6090,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NAPTR"], @@ -6121,7 +6153,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SMIMEA"], @@ -6184,7 +6216,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SRV"], @@ -6247,7 +6279,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SSHFP"], @@ -6310,7 +6342,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SVCB"], @@ -6373,7 +6405,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TLSA"], @@ -6436,7 +6468,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["URI"], @@ -6500,11 +6532,11 @@ async def create( """ ... - @required_args(["zone_id", "name", "ttl", "type"]) + @required_args(["name", "ttl", "type"]) async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"] @@ -6577,12 +6609,14 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RecordResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[RecordResponse], await self._post( - f"/zones/{zone_id}/dns_records", + path_template("/zones/{zone_id}/dns_records", zone_id=zone_id), body=await async_maybe_transform( { "name": name, @@ -6617,7 +6651,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"], @@ -6686,7 +6720,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["AAAA"], @@ -6755,7 +6789,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CNAME"], @@ -6821,7 +6855,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["MX"], @@ -6892,7 +6926,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NS"], @@ -6958,7 +6992,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["OPENPGPKEY"], @@ -7024,7 +7058,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["PTR"], @@ -7090,7 +7124,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TXT"], @@ -7161,7 +7195,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CAA"], @@ -7227,7 +7261,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CERT"], @@ -7293,7 +7327,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DNSKEY"], @@ -7359,7 +7393,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DS"], @@ -7425,7 +7459,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["HTTPS"], @@ -7491,7 +7525,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["LOC"], @@ -7557,7 +7591,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NAPTR"], @@ -7623,7 +7657,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SMIMEA"], @@ -7689,7 +7723,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SRV"], @@ -7755,7 +7789,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SSHFP"], @@ -7821,7 +7855,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SVCB"], @@ -7887,7 +7921,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TLSA"], @@ -7953,7 +7987,7 @@ async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["URI"], @@ -8019,12 +8053,12 @@ async def update( """ ... - @required_args(["zone_id", "name", "ttl", "type"]) + @required_args(["name", "ttl", "type"]) async def update( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"] @@ -8097,6 +8131,8 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RecordResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not dns_record_id: @@ -8104,7 +8140,9 @@ async def update( return cast( Optional[RecordResponse], await self._put( - f"/zones/{zone_id}/dns_records/{dns_record_id}", + path_template( + "/zones/{zone_id}/dns_records/{dns_record_id}", zone_id=zone_id, dns_record_id=dns_record_id + ), body=await async_maybe_transform( { "name": name, @@ -8137,7 +8175,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, comment: record_list_params.Comment | Omit = omit, content: record_list_params.Content | Omit = omit, direction: SortDirection | Omit = omit, @@ -8224,10 +8262,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records", + path_template("/zones/{zone_id}/dns_records", zone_id=zone_id), page=AsyncV4PagePaginationArray[RecordResponse], options=make_request_options( extra_headers=extra_headers, @@ -8260,7 +8300,7 @@ async def delete( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -8284,12 +8324,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not dns_record_id: raise ValueError(f"Expected a non-empty value for `dns_record_id` but received {dns_record_id!r}") return await self._delete( - f"/zones/{zone_id}/dns_records/{dns_record_id}", + path_template("/zones/{zone_id}/dns_records/{dns_record_id}", zone_id=zone_id, dns_record_id=dns_record_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -8303,7 +8345,7 @@ async def delete( async def batch( self, *, - zone_id: str, + zone_id: str | None = None, deletes: Iterable[record_batch_params.Delete] | Omit = omit, patches: Iterable[BatchPatchParam] | Omit = omit, posts: Iterable[record_batch_params.Post] | Omit = omit, @@ -8345,10 +8387,12 @@ async def batch( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/batch", + path_template("/zones/{zone_id}/dns_records/batch", zone_id=zone_id), body=await async_maybe_transform( { "deletes": deletes, @@ -8373,7 +8417,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"], @@ -8442,7 +8486,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["AAAA"], @@ -8511,7 +8555,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CNAME"], @@ -8577,7 +8621,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["MX"], @@ -8648,7 +8692,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NS"], @@ -8714,7 +8758,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["OPENPGPKEY"], @@ -8780,7 +8824,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["PTR"], @@ -8846,7 +8890,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TXT"], @@ -8917,7 +8961,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CAA"], @@ -8983,7 +9027,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["CERT"], @@ -9049,7 +9093,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DNSKEY"], @@ -9115,7 +9159,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["DS"], @@ -9181,7 +9225,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["HTTPS"], @@ -9247,7 +9291,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["LOC"], @@ -9313,7 +9357,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["NAPTR"], @@ -9379,7 +9423,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SMIMEA"], @@ -9445,7 +9489,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SRV"], @@ -9511,7 +9555,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SSHFP"], @@ -9577,7 +9621,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["SVCB"], @@ -9643,7 +9687,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["TLSA"], @@ -9709,7 +9753,7 @@ async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["URI"], @@ -9775,12 +9819,12 @@ async def edit( """ ... - @required_args(["zone_id", "name", "ttl", "type"]) + @required_args(["name", "ttl", "type"]) async def edit( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, name: str, ttl: TTLParam, type: Literal["A"] @@ -9853,6 +9897,8 @@ async def edit( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RecordResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not dns_record_id: @@ -9860,7 +9906,9 @@ async def edit( return cast( Optional[RecordResponse], await self._patch( - f"/zones/{zone_id}/dns_records/{dns_record_id}", + path_template( + "/zones/{zone_id}/dns_records/{dns_record_id}", zone_id=zone_id, dns_record_id=dns_record_id + ), body=await async_maybe_transform( { "name": name, @@ -9893,7 +9941,7 @@ async def edit( async def export( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -9921,11 +9969,13 @@ async def export( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {"Accept": "text/plain", **(extra_headers or {})} return await self._get( - f"/zones/{zone_id}/dns_records/export", + path_template("/zones/{zone_id}/dns_records/export", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -9936,7 +9986,7 @@ async def get( self, dns_record_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -9960,6 +10010,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not dns_record_id: @@ -9967,7 +10019,9 @@ async def get( return cast( Optional[RecordResponse], await self._get( - f"/zones/{zone_id}/dns_records/{dns_record_id}", + path_template( + "/zones/{zone_id}/dns_records/{dns_record_id}", zone_id=zone_id, dns_record_id=dns_record_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -9984,7 +10038,7 @@ async def get( async def import_( self, *, - zone_id: str, + zone_id: str | None = None, file: str, proxied: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -10025,6 +10079,8 @@ async def import_( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") # It should be noted that the actual Content-Type header that will be @@ -10032,7 +10088,7 @@ async def import_( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( - f"/zones/{zone_id}/dns_records/import", + path_template("/zones/{zone_id}/dns_records/import", zone_id=zone_id), body=await async_maybe_transform( { "file": file, @@ -10056,7 +10112,7 @@ async def import_( async def scan( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -10080,10 +10136,12 @@ async def scan( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/scan", + path_template("/zones/{zone_id}/dns_records/scan", zone_id=zone_id), body=await async_maybe_transform(body, record_scan_params.RecordScanParams), options=make_request_options( extra_headers=extra_headers, @@ -10098,7 +10156,7 @@ async def scan( def scan_list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -10123,10 +10181,12 @@ def scan_list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/scan/review", + path_template("/zones/{zone_id}/dns_records/scan/review", zone_id=zone_id), page=AsyncSinglePage[RecordResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -10137,7 +10197,7 @@ def scan_list( async def scan_review( self, *, - zone_id: str, + zone_id: str | None = None, accepts: Iterable[record_scan_review_params.Accept] | Omit = omit, rejects: Iterable[record_scan_review_params.Reject] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -10164,10 +10224,12 @@ async def scan_review( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/scan/review", + path_template("/zones/{zone_id}/dns_records/scan/review", zone_id=zone_id), body=await async_maybe_transform( { "accepts": accepts, @@ -10188,7 +10250,7 @@ async def scan_review( async def scan_trigger( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -10214,10 +10276,12 @@ async def scan_trigger( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_records/scan/trigger", + path_template("/zones/{zone_id}/dns_records/scan/trigger", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/dns/settings/account/account.py b/src/cloudflare/resources/dns/settings/account/account.py index 0dac25f716e..e2360d098cf 100644 --- a/src/cloudflare/resources/dns/settings/account/account.py +++ b/src/cloudflare/resources/dns/settings/account/account.py @@ -15,7 +15,7 @@ AsyncViewsResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -60,7 +60,7 @@ def with_streaming_response(self) -> AccountResourceWithStreamingResponse: def edit( self, *, - account_id: str, + account_id: str | None = None, zone_defaults: account_edit_params.ZoneDefaults | 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. @@ -83,10 +83,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/dns_settings", + path_template("/accounts/{account_id}/dns_settings", account_id=account_id), body=maybe_transform({"zone_defaults": zone_defaults}, account_edit_params.AccountEditParams), options=make_request_options( extra_headers=extra_headers, @@ -101,7 +103,7 @@ def edit( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,10 +125,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_settings", + path_template("/accounts/{account_id}/dns_settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -165,7 +169,7 @@ def with_streaming_response(self) -> AsyncAccountResourceWithStreamingResponse: async def edit( self, *, - account_id: str, + account_id: str | None = None, zone_defaults: account_edit_params.ZoneDefaults | 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. @@ -188,10 +192,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/dns_settings", + path_template("/accounts/{account_id}/dns_settings", account_id=account_id), body=await async_maybe_transform({"zone_defaults": zone_defaults}, account_edit_params.AccountEditParams), options=make_request_options( extra_headers=extra_headers, @@ -206,7 +212,7 @@ async def edit( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -228,10 +234,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_settings", + path_template("/accounts/{account_id}/dns_settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/settings/account/views.py b/src/cloudflare/resources/dns/settings/account/views.py index 9087a872c50..e5a2fd189fd 100644 --- a/src/cloudflare/resources/dns/settings/account/views.py +++ b/src/cloudflare/resources/dns/settings/account/views.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> ViewsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, zones: SequenceNotStr[str], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -81,10 +81,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_settings/views", + path_template("/accounts/{account_id}/dns_settings/views", account_id=account_id), body=maybe_transform( { "name": name, @@ -105,7 +107,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, name: view_list_params.Name | Omit = omit, @@ -151,10 +153,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_settings/views", + path_template("/accounts/{account_id}/dns_settings/views", account_id=account_id), page=SyncV4PagePaginationArray[ViewListResponse], options=make_request_options( extra_headers=extra_headers, @@ -182,7 +186,7 @@ def delete( self, view_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -206,12 +210,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not view_id: raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}") return self._delete( - f"/accounts/{account_id}/dns_settings/views/{view_id}", + path_template( + "/accounts/{account_id}/dns_settings/views/{view_id}", account_id=account_id, view_id=view_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -226,7 +234,7 @@ def edit( self, view_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, zones: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -256,12 +264,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not view_id: raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}") return self._patch( - f"/accounts/{account_id}/dns_settings/views/{view_id}", + path_template( + "/accounts/{account_id}/dns_settings/views/{view_id}", account_id=account_id, view_id=view_id + ), body=maybe_transform( { "name": name, @@ -283,7 +295,7 @@ def get( self, view_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -307,12 +319,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not view_id: raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}") return self._get( - f"/accounts/{account_id}/dns_settings/views/{view_id}", + path_template( + "/accounts/{account_id}/dns_settings/views/{view_id}", account_id=account_id, view_id=view_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -347,7 +363,7 @@ def with_streaming_response(self) -> AsyncViewsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, zones: SequenceNotStr[str], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -375,10 +391,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_settings/views", + path_template("/accounts/{account_id}/dns_settings/views", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -399,7 +417,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, name: view_list_params.Name | Omit = omit, @@ -445,10 +463,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_settings/views", + path_template("/accounts/{account_id}/dns_settings/views", account_id=account_id), page=AsyncV4PagePaginationArray[ViewListResponse], options=make_request_options( extra_headers=extra_headers, @@ -476,7 +496,7 @@ async def delete( self, view_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -500,12 +520,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not view_id: raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}") return await self._delete( - f"/accounts/{account_id}/dns_settings/views/{view_id}", + path_template( + "/accounts/{account_id}/dns_settings/views/{view_id}", account_id=account_id, view_id=view_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -520,7 +544,7 @@ async def edit( self, view_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, zones: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -550,12 +574,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not view_id: raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}") return await self._patch( - f"/accounts/{account_id}/dns_settings/views/{view_id}", + path_template( + "/accounts/{account_id}/dns_settings/views/{view_id}", account_id=account_id, view_id=view_id + ), body=await async_maybe_transform( { "name": name, @@ -577,7 +605,7 @@ async def get( self, view_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -601,12 +629,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not view_id: raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}") return await self._get( - f"/accounts/{account_id}/dns_settings/views/{view_id}", + path_template( + "/accounts/{account_id}/dns_settings/views/{view_id}", account_id=account_id, view_id=view_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/settings/zone.py b/src/cloudflare/resources/dns/settings/zone.py index e6192dd17c4..342dab2b381 100644 --- a/src/cloudflare/resources/dns/settings/zone.py +++ b/src/cloudflare/resources/dns/settings/zone.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> ZoneResourceWithStreamingResponse: def edit( self, *, - zone_id: str, + zone_id: str | None = None, flatten_all_cnames: bool | Omit = omit, foundation_dns: bool | Omit = omit, internal_dns: zone_edit_params.InternalDNS | Omit = omit, @@ -102,10 +102,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_settings", + path_template("/zones/{zone_id}/dns_settings", zone_id=zone_id), body=maybe_transform( { "flatten_all_cnames": flatten_all_cnames, @@ -133,7 +135,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -155,10 +157,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/dns_settings", + path_template("/zones/{zone_id}/dns_settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -193,7 +197,7 @@ def with_streaming_response(self) -> AsyncZoneResourceWithStreamingResponse: async def edit( self, *, - zone_id: str, + zone_id: str | None = None, flatten_all_cnames: bool | Omit = omit, foundation_dns: bool | Omit = omit, internal_dns: zone_edit_params.InternalDNS | Omit = omit, @@ -246,10 +250,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/dns_settings", + path_template("/zones/{zone_id}/dns_settings", zone_id=zone_id), body=await async_maybe_transform( { "flatten_all_cnames": flatten_all_cnames, @@ -277,7 +283,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -299,10 +305,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/dns_settings", + path_template("/zones/{zone_id}/dns_settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/zone_transfers/acls.py b/src/cloudflare/resources/dns/zone_transfers/acls.py index 1bc1881c3de..d18cbe3fed5 100644 --- a/src/cloudflare/resources/dns/zone_transfers/acls.py +++ b/src/cloudflare/resources/dns/zone_transfers/acls.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> ACLsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, ip_range: str, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -79,10 +79,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/acls", + path_template("/accounts/{account_id}/secondary_dns/acls", account_id=account_id), body=maybe_transform( { "ip_range": ip_range, @@ -104,7 +106,7 @@ def update( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, ip_range: str, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -134,12 +136,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return self._put( - f"/accounts/{account_id}/secondary_dns/acls/{acl_id}", + path_template("/accounts/{account_id}/secondary_dns/acls/{acl_id}", account_id=account_id, acl_id=acl_id), body=maybe_transform( { "ip_range": ip_range, @@ -160,7 +164,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -180,10 +184,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/acls", + path_template("/accounts/{account_id}/secondary_dns/acls", account_id=account_id), page=SyncSinglePage[ACL], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -195,7 +201,7 @@ def delete( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -215,12 +221,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return self._delete( - f"/accounts/{account_id}/secondary_dns/acls/{acl_id}", + path_template("/accounts/{account_id}/secondary_dns/acls/{acl_id}", account_id=account_id, acl_id=acl_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -235,7 +243,7 @@ def get( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -255,12 +263,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return self._get( - f"/accounts/{account_id}/secondary_dns/acls/{acl_id}", + path_template("/accounts/{account_id}/secondary_dns/acls/{acl_id}", account_id=account_id, acl_id=acl_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -295,7 +305,7 @@ def with_streaming_response(self) -> AsyncACLsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, ip_range: str, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -325,10 +335,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/acls", + path_template("/accounts/{account_id}/secondary_dns/acls", account_id=account_id), body=await async_maybe_transform( { "ip_range": ip_range, @@ -350,7 +362,7 @@ async def update( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, ip_range: str, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -380,12 +392,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return await self._put( - f"/accounts/{account_id}/secondary_dns/acls/{acl_id}", + path_template("/accounts/{account_id}/secondary_dns/acls/{acl_id}", account_id=account_id, acl_id=acl_id), body=await async_maybe_transform( { "ip_range": ip_range, @@ -406,7 +420,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -426,10 +440,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/acls", + path_template("/accounts/{account_id}/secondary_dns/acls", account_id=account_id), page=AsyncSinglePage[ACL], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -441,7 +457,7 @@ async def delete( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -461,12 +477,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return await self._delete( - f"/accounts/{account_id}/secondary_dns/acls/{acl_id}", + path_template("/accounts/{account_id}/secondary_dns/acls/{acl_id}", account_id=account_id, acl_id=acl_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -481,7 +499,7 @@ async def get( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -501,12 +519,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return await self._get( - f"/accounts/{account_id}/secondary_dns/acls/{acl_id}", + path_template("/accounts/{account_id}/secondary_dns/acls/{acl_id}", account_id=account_id, acl_id=acl_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/zone_transfers/force_axfr.py b/src/cloudflare/resources/dns/zone_transfers/force_axfr.py index a9d4f10976b..daef67deb44 100644 --- a/src/cloudflare/resources/dns/zone_transfers/force_axfr.py +++ b/src/cloudflare/resources/dns/zone_transfers/force_axfr.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> ForceAXFRResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -68,10 +68,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/force_axfr", + path_template("/zones/{zone_id}/secondary_dns/force_axfr", zone_id=zone_id), body=maybe_transform(body, force_axfr_create_params.ForceAXFRCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -107,7 +109,7 @@ def with_streaming_response(self) -> AsyncForceAXFRResourceWithStreamingResponse async def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -128,10 +130,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/force_axfr", + path_template("/zones/{zone_id}/secondary_dns/force_axfr", zone_id=zone_id), body=await async_maybe_transform(body, force_axfr_create_params.ForceAXFRCreateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/dns/zone_transfers/incoming.py b/src/cloudflare/resources/dns/zone_transfers/incoming.py index d2b75511030..6c133e1647c 100644 --- a/src/cloudflare/resources/dns/zone_transfers/incoming.py +++ b/src/cloudflare/resources/dns/zone_transfers/incoming.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> IncomingResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, auto_refresh_seconds: float, name: str, peers: SequenceNotStr[str], @@ -80,10 +80,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/incoming", + path_template("/zones/{zone_id}/secondary_dns/incoming", zone_id=zone_id), body=maybe_transform( { "auto_refresh_seconds": auto_refresh_seconds, @@ -105,7 +107,7 @@ def create( def update( self, *, - zone_id: str, + zone_id: str | None = None, auto_refresh_seconds: float, name: str, peers: SequenceNotStr[str], @@ -135,10 +137,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/secondary_dns/incoming", + path_template("/zones/{zone_id}/secondary_dns/incoming", zone_id=zone_id), body=maybe_transform( { "auto_refresh_seconds": auto_refresh_seconds, @@ -160,7 +164,7 @@ def update( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -180,10 +184,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/incoming", + path_template("/zones/{zone_id}/secondary_dns/incoming", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -197,7 +203,7 @@ def delete( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -217,10 +223,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/secondary_dns/incoming", + path_template("/zones/{zone_id}/secondary_dns/incoming", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -255,7 +263,7 @@ def with_streaming_response(self) -> AsyncIncomingResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, auto_refresh_seconds: float, name: str, peers: SequenceNotStr[str], @@ -285,10 +293,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/incoming", + path_template("/zones/{zone_id}/secondary_dns/incoming", zone_id=zone_id), body=await async_maybe_transform( { "auto_refresh_seconds": auto_refresh_seconds, @@ -310,7 +320,7 @@ async def create( async def update( self, *, - zone_id: str, + zone_id: str | None = None, auto_refresh_seconds: float, name: str, peers: SequenceNotStr[str], @@ -340,10 +350,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/secondary_dns/incoming", + path_template("/zones/{zone_id}/secondary_dns/incoming", zone_id=zone_id), body=await async_maybe_transform( { "auto_refresh_seconds": auto_refresh_seconds, @@ -365,7 +377,7 @@ async def update( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -385,10 +397,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/incoming", + path_template("/zones/{zone_id}/secondary_dns/incoming", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -402,7 +416,7 @@ async def delete( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -422,10 +436,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/secondary_dns/incoming", + path_template("/zones/{zone_id}/secondary_dns/incoming", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/zone_transfers/outgoing/outgoing.py b/src/cloudflare/resources/dns/zone_transfers/outgoing/outgoing.py index be827a34571..a01092cc529 100644 --- a/src/cloudflare/resources/dns/zone_transfers/outgoing/outgoing.py +++ b/src/cloudflare/resources/dns/zone_transfers/outgoing/outgoing.py @@ -15,7 +15,7 @@ AsyncStatusResourceWithStreamingResponse, ) from ....._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -71,7 +71,7 @@ def with_streaming_response(self) -> OutgoingResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, peers: SequenceNotStr[str], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -97,10 +97,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing", + path_template("/zones/{zone_id}/secondary_dns/outgoing", zone_id=zone_id), body=maybe_transform( { "name": name, @@ -121,7 +123,7 @@ def create( def update( self, *, - zone_id: str, + zone_id: str | None = None, name: str, peers: SequenceNotStr[str], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -147,10 +149,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/secondary_dns/outgoing", + path_template("/zones/{zone_id}/secondary_dns/outgoing", zone_id=zone_id), body=maybe_transform( { "name": name, @@ -171,7 +175,7 @@ def update( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -191,10 +195,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing", + path_template("/zones/{zone_id}/secondary_dns/outgoing", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -208,7 +214,7 @@ def delete( def disable( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -230,10 +236,12 @@ def disable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing/disable", + path_template("/zones/{zone_id}/secondary_dns/outgoing/disable", zone_id=zone_id), body=maybe_transform(body, outgoing_disable_params.OutgoingDisableParams), options=make_request_options( extra_headers=extra_headers, @@ -248,7 +256,7 @@ def disable( def enable( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -269,10 +277,12 @@ def enable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing/enable", + path_template("/zones/{zone_id}/secondary_dns/outgoing/enable", zone_id=zone_id), body=maybe_transform(body, outgoing_enable_params.OutgoingEnableParams), options=make_request_options( extra_headers=extra_headers, @@ -287,7 +297,7 @@ def enable( def force_notify( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -308,10 +318,12 @@ def force_notify( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing/force_notify", + path_template("/zones/{zone_id}/secondary_dns/outgoing/force_notify", zone_id=zone_id), body=maybe_transform(body, outgoing_force_notify_params.OutgoingForceNotifyParams), options=make_request_options( extra_headers=extra_headers, @@ -326,7 +338,7 @@ def force_notify( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -346,10 +358,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/secondary_dns/outgoing", + path_template("/zones/{zone_id}/secondary_dns/outgoing", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -388,7 +402,7 @@ def with_streaming_response(self) -> AsyncOutgoingResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, peers: SequenceNotStr[str], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -414,10 +428,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing", + path_template("/zones/{zone_id}/secondary_dns/outgoing", zone_id=zone_id), body=await async_maybe_transform( { "name": name, @@ -438,7 +454,7 @@ async def create( async def update( self, *, - zone_id: str, + zone_id: str | None = None, name: str, peers: SequenceNotStr[str], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -464,10 +480,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/secondary_dns/outgoing", + path_template("/zones/{zone_id}/secondary_dns/outgoing", zone_id=zone_id), body=await async_maybe_transform( { "name": name, @@ -488,7 +506,7 @@ async def update( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -508,10 +526,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing", + path_template("/zones/{zone_id}/secondary_dns/outgoing", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -525,7 +545,7 @@ async def delete( async def disable( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -547,10 +567,12 @@ async def disable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing/disable", + path_template("/zones/{zone_id}/secondary_dns/outgoing/disable", zone_id=zone_id), body=await async_maybe_transform(body, outgoing_disable_params.OutgoingDisableParams), options=make_request_options( extra_headers=extra_headers, @@ -565,7 +587,7 @@ async def disable( async def enable( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -586,10 +608,12 @@ async def enable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing/enable", + path_template("/zones/{zone_id}/secondary_dns/outgoing/enable", zone_id=zone_id), body=await async_maybe_transform(body, outgoing_enable_params.OutgoingEnableParams), options=make_request_options( extra_headers=extra_headers, @@ -604,7 +628,7 @@ async def enable( async def force_notify( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -625,10 +649,12 @@ async def force_notify( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/secondary_dns/outgoing/force_notify", + path_template("/zones/{zone_id}/secondary_dns/outgoing/force_notify", zone_id=zone_id), body=await async_maybe_transform(body, outgoing_force_notify_params.OutgoingForceNotifyParams), options=make_request_options( extra_headers=extra_headers, @@ -643,7 +669,7 @@ async def force_notify( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -663,10 +689,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/secondary_dns/outgoing", + path_template("/zones/{zone_id}/secondary_dns/outgoing", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/zone_transfers/outgoing/status.py b/src/cloudflare/resources/dns/zone_transfers/outgoing/status.py index 7fdfddd1406..b65a1022add 100644 --- a/src/cloudflare/resources/dns/zone_transfers/outgoing/status.py +++ b/src/cloudflare/resources/dns/zone_transfers/outgoing/status.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> StatusResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -65,10 +66,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/secondary_dns/outgoing/status", + path_template("/zones/{zone_id}/secondary_dns/outgoing/status", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -103,7 +106,7 @@ def with_streaming_response(self) -> AsyncStatusResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,10 +126,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/secondary_dns/outgoing/status", + path_template("/zones/{zone_id}/secondary_dns/outgoing/status", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/zone_transfers/peers.py b/src/cloudflare/resources/dns/zone_transfers/peers.py index 034156f7433..8df07e39084 100644 --- a/src/cloudflare/resources/dns/zone_transfers/peers.py +++ b/src/cloudflare/resources/dns/zone_transfers/peers.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> PeersResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -72,10 +72,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/peers", + path_template("/accounts/{account_id}/secondary_dns/peers", account_id=account_id), body=maybe_transform({"name": name}, peer_create_params.PeerCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -91,7 +93,7 @@ def update( self, peer_id: str, *, - account_id: str, + account_id: str | None = None, name: str, ip: str | Omit = omit, ixfr_enable: bool | Omit = omit, @@ -132,12 +134,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not peer_id: raise ValueError(f"Expected a non-empty value for `peer_id` but received {peer_id!r}") return self._put( - f"/accounts/{account_id}/secondary_dns/peers/{peer_id}", + path_template( + "/accounts/{account_id}/secondary_dns/peers/{peer_id}", account_id=account_id, peer_id=peer_id + ), body=maybe_transform( { "name": name, @@ -161,7 +167,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -181,10 +187,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/peers", + path_template("/accounts/{account_id}/secondary_dns/peers", account_id=account_id), page=SyncSinglePage[Peer], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -196,7 +204,7 @@ def delete( self, peer_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -216,12 +224,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not peer_id: raise ValueError(f"Expected a non-empty value for `peer_id` but received {peer_id!r}") return self._delete( - f"/accounts/{account_id}/secondary_dns/peers/{peer_id}", + path_template( + "/accounts/{account_id}/secondary_dns/peers/{peer_id}", account_id=account_id, peer_id=peer_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -236,7 +248,7 @@ def get( self, peer_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -256,12 +268,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not peer_id: raise ValueError(f"Expected a non-empty value for `peer_id` but received {peer_id!r}") return self._get( - f"/accounts/{account_id}/secondary_dns/peers/{peer_id}", + path_template( + "/accounts/{account_id}/secondary_dns/peers/{peer_id}", account_id=account_id, peer_id=peer_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -296,7 +312,7 @@ def with_streaming_response(self) -> AsyncPeersResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -319,10 +335,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/peers", + path_template("/accounts/{account_id}/secondary_dns/peers", account_id=account_id), body=await async_maybe_transform({"name": name}, peer_create_params.PeerCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -338,7 +356,7 @@ async def update( self, peer_id: str, *, - account_id: str, + account_id: str | None = None, name: str, ip: str | Omit = omit, ixfr_enable: bool | Omit = omit, @@ -379,12 +397,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not peer_id: raise ValueError(f"Expected a non-empty value for `peer_id` but received {peer_id!r}") return await self._put( - f"/accounts/{account_id}/secondary_dns/peers/{peer_id}", + path_template( + "/accounts/{account_id}/secondary_dns/peers/{peer_id}", account_id=account_id, peer_id=peer_id + ), body=await async_maybe_transform( { "name": name, @@ -408,7 +430,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -428,10 +450,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/peers", + path_template("/accounts/{account_id}/secondary_dns/peers", account_id=account_id), page=AsyncSinglePage[Peer], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -443,7 +467,7 @@ async def delete( self, peer_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -463,12 +487,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not peer_id: raise ValueError(f"Expected a non-empty value for `peer_id` but received {peer_id!r}") return await self._delete( - f"/accounts/{account_id}/secondary_dns/peers/{peer_id}", + path_template( + "/accounts/{account_id}/secondary_dns/peers/{peer_id}", account_id=account_id, peer_id=peer_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -483,7 +511,7 @@ async def get( self, peer_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -503,12 +531,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not peer_id: raise ValueError(f"Expected a non-empty value for `peer_id` but received {peer_id!r}") return await self._get( - f"/accounts/{account_id}/secondary_dns/peers/{peer_id}", + path_template( + "/accounts/{account_id}/secondary_dns/peers/{peer_id}", account_id=account_id, peer_id=peer_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns/zone_transfers/tsigs.py b/src/cloudflare/resources/dns/zone_transfers/tsigs.py index 8bb678709d2..77c1b54b16f 100644 --- a/src/cloudflare/resources/dns/zone_transfers/tsigs.py +++ b/src/cloudflare/resources/dns/zone_transfers/tsigs.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> TSIGsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, algo: str, name: str, secret: str, @@ -78,10 +78,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/tsigs", + path_template("/accounts/{account_id}/secondary_dns/tsigs", account_id=account_id), body=maybe_transform( { "algo": algo, @@ -104,7 +106,7 @@ def update( self, tsig_id: str, *, - account_id: str, + account_id: str | None = None, algo: str, name: str, secret: str, @@ -133,12 +135,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tsig_id: raise ValueError(f"Expected a non-empty value for `tsig_id` but received {tsig_id!r}") return self._put( - f"/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", + path_template( + "/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", account_id=account_id, tsig_id=tsig_id + ), body=maybe_transform( { "algo": algo, @@ -160,7 +166,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -180,10 +186,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/tsigs", + path_template("/accounts/{account_id}/secondary_dns/tsigs", account_id=account_id), page=SyncSinglePage[TSIG], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -195,7 +203,7 @@ def delete( self, tsig_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -215,12 +223,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tsig_id: raise ValueError(f"Expected a non-empty value for `tsig_id` but received {tsig_id!r}") return self._delete( - f"/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", + path_template( + "/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", account_id=account_id, tsig_id=tsig_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -235,7 +247,7 @@ def get( self, tsig_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -255,12 +267,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tsig_id: raise ValueError(f"Expected a non-empty value for `tsig_id` but received {tsig_id!r}") return self._get( - f"/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", + path_template( + "/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", account_id=account_id, tsig_id=tsig_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -295,7 +311,7 @@ def with_streaming_response(self) -> AsyncTSIGsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, algo: str, name: str, secret: str, @@ -324,10 +340,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/tsigs", + path_template("/accounts/{account_id}/secondary_dns/tsigs", account_id=account_id), body=await async_maybe_transform( { "algo": algo, @@ -350,7 +368,7 @@ async def update( self, tsig_id: str, *, - account_id: str, + account_id: str | None = None, algo: str, name: str, secret: str, @@ -379,12 +397,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tsig_id: raise ValueError(f"Expected a non-empty value for `tsig_id` but received {tsig_id!r}") return await self._put( - f"/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", + path_template( + "/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", account_id=account_id, tsig_id=tsig_id + ), body=await async_maybe_transform( { "algo": algo, @@ -406,7 +428,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -426,10 +448,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secondary_dns/tsigs", + path_template("/accounts/{account_id}/secondary_dns/tsigs", account_id=account_id), page=AsyncSinglePage[TSIG], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -441,7 +465,7 @@ async def delete( self, tsig_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -461,12 +485,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tsig_id: raise ValueError(f"Expected a non-empty value for `tsig_id` but received {tsig_id!r}") return await self._delete( - f"/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", + path_template( + "/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", account_id=account_id, tsig_id=tsig_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -481,7 +509,7 @@ async def get( self, tsig_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -501,12 +529,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tsig_id: raise ValueError(f"Expected a non-empty value for `tsig_id` but received {tsig_id!r}") return await self._get( - f"/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", + path_template( + "/accounts/{account_id}/secondary_dns/tsigs/{tsig_id}", account_id=account_id, tsig_id=tsig_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns_firewall/analytics/reports/bytimes.py b/src/cloudflare/resources/dns_firewall/analytics/reports/bytimes.py index ee2e650d980..597d0191891 100644 --- a/src/cloudflare/resources/dns_firewall/analytics/reports/bytimes.py +++ b/src/cloudflare/resources/dns_firewall/analytics/reports/bytimes.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -50,7 +50,7 @@ def get( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, dimensions: str | Omit = omit, filters: str | Omit = omit, limit: int | Omit = omit, @@ -104,12 +104,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return self._get( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report/bytime", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report/bytime", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -158,7 +164,7 @@ async def get( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, dimensions: str | Omit = omit, filters: str | Omit = omit, limit: int | Omit = omit, @@ -212,12 +218,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return await self._get( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report/bytime", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report/bytime", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns_firewall/analytics/reports/reports.py b/src/cloudflare/resources/dns_firewall/analytics/reports/reports.py index 00c7ccd859b..f3eb2cdb5e1 100644 --- a/src/cloudflare/resources/dns_firewall/analytics/reports/reports.py +++ b/src/cloudflare/resources/dns_firewall/analytics/reports/reports.py @@ -16,7 +16,7 @@ AsyncBytimesResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -61,7 +61,7 @@ def get( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, dimensions: str | Omit = omit, filters: str | Omit = omit, limit: int | Omit = omit, @@ -111,12 +111,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return self._get( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -168,7 +174,7 @@ async def get( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, dimensions: str | Omit = omit, filters: str | Omit = omit, limit: int | Omit = omit, @@ -218,12 +224,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return await self._get( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}/dns_analytics/report", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns_firewall/api.md b/src/cloudflare/resources/dns_firewall/api.md new file mode 100644 index 00000000000..fce0cca7341 --- /dev/null +++ b/src/cloudflare/resources/dns_firewall/api.md @@ -0,0 +1,51 @@ +# DNSFirewall + +Types: + +```python +from cloudflare.types.dns_firewall import ( + AttackMitigation, + FirewallIPs, + UpstreamIPs, + DNSFirewallCreateResponse, + DNSFirewallListResponse, + DNSFirewallDeleteResponse, + DNSFirewallEditResponse, + DNSFirewallGetResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/dns_firewall/dns_firewall.py b/src/cloudflare/resources/dns_firewall/dns_firewall.py index 4f3c7490cb4..bd2e75a3bf7 100644 --- a/src/cloudflare/resources/dns_firewall/dns_firewall.py +++ b/src/cloudflare/resources/dns_firewall/dns_firewall.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -82,7 +82,7 @@ def with_streaming_response(self) -> DNSFirewallResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, upstream_ips: SequenceNotStr[UpstreamIPs], attack_mitigation: Optional[AttackMitigationParam] | Omit = omit, @@ -157,10 +157,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_firewall", + path_template("/accounts/{account_id}/dns_firewall", account_id=account_id), body=maybe_transform( { "name": name, @@ -189,7 +191,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -217,10 +219,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_firewall", + path_template("/accounts/{account_id}/dns_firewall", account_id=account_id), page=SyncV4PagePaginationArray[DNSFirewallListResponse], options=make_request_options( extra_headers=extra_headers, @@ -242,7 +246,7 @@ def delete( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -266,12 +270,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return self._delete( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +296,7 @@ def edit( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, attack_mitigation: Optional[AttackMitigationParam] | Omit = omit, deprecate_any_requests: bool | Omit = omit, ecs_fallback: bool | Omit = omit, @@ -363,12 +373,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return self._patch( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), body=maybe_transform( { "attack_mitigation": attack_mitigation, @@ -398,7 +414,7 @@ def get( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -422,12 +438,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return self._get( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -470,7 +492,7 @@ def with_streaming_response(self) -> AsyncDNSFirewallResourceWithStreamingRespon async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, upstream_ips: SequenceNotStr[UpstreamIPs], attack_mitigation: Optional[AttackMitigationParam] | Omit = omit, @@ -545,10 +567,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_firewall", + path_template("/accounts/{account_id}/dns_firewall", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -577,7 +601,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -605,10 +629,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dns_firewall", + path_template("/accounts/{account_id}/dns_firewall", account_id=account_id), page=AsyncV4PagePaginationArray[DNSFirewallListResponse], options=make_request_options( extra_headers=extra_headers, @@ -630,7 +656,7 @@ async def delete( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -654,12 +680,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return await self._delete( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -674,7 +706,7 @@ async def edit( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, attack_mitigation: Optional[AttackMitigationParam] | Omit = omit, deprecate_any_requests: bool | Omit = omit, ecs_fallback: bool | Omit = omit, @@ -751,12 +783,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return await self._patch( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), body=await async_maybe_transform( { "attack_mitigation": attack_mitigation, @@ -786,7 +824,7 @@ async def get( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -810,12 +848,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return await self._get( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/dns_firewall/reverse_dns.py b/src/cloudflare/resources/dns_firewall/reverse_dns.py index bb4a2db63b0..20a3df39245 100644 --- a/src/cloudflare/resources/dns_firewall/reverse_dns.py +++ b/src/cloudflare/resources/dns_firewall/reverse_dns.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def edit( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, ptr: Dict[str, 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. @@ -76,12 +76,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return self._patch( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/reverse_dns", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}/reverse_dns", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), body=maybe_transform({"ptr": ptr}, reverse_dns_edit_params.ReverseDNSEditParams), options=make_request_options( extra_headers=extra_headers, @@ -97,7 +103,7 @@ def get( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -121,12 +127,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return self._get( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/reverse_dns", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}/reverse_dns", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -162,7 +174,7 @@ async def edit( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, ptr: Dict[str, 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. @@ -189,12 +201,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return await self._patch( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/reverse_dns", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}/reverse_dns", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), body=await async_maybe_transform({"ptr": ptr}, reverse_dns_edit_params.ReverseDNSEditParams), options=make_request_options( extra_headers=extra_headers, @@ -210,7 +228,7 @@ async def get( self, dns_firewall_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -234,12 +252,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dns_firewall_id: raise ValueError(f"Expected a non-empty value for `dns_firewall_id` but received {dns_firewall_id!r}") return await self._get( - f"/accounts/{account_id}/dns_firewall/{dns_firewall_id}/reverse_dns", + path_template( + "/accounts/{account_id}/dns_firewall/{dns_firewall_id}/reverse_dns", + account_id=account_id, + dns_firewall_id=dns_firewall_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/durable_objects/api.md b/src/cloudflare/resources/durable_objects/api.md new file mode 100644 index 00000000000..eb812ede616 --- /dev/null +++ b/src/cloudflare/resources/durable_objects/api.md @@ -0,0 +1,25 @@ +# DurableObjects + +## Namespaces + +Types: + +```python +from cloudflare.types.durable_objects import Namespace +``` + +Methods: + +- client.durable_objects.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Namespace] + +### Objects + +Types: + +```python +from cloudflare.types.durable_objects.namespaces import DurableObject +``` + +Methods: + +- client.durable_objects.namespaces.objects.list(id, \*, account_id, \*\*params) -> SyncCursorPaginationAfter[DurableObject] diff --git a/src/cloudflare/resources/durable_objects/namespaces/namespaces.py b/src/cloudflare/resources/durable_objects/namespaces/namespaces.py index b35378602bc..03c40d41df5 100644 --- a/src/cloudflare/resources/durable_objects/namespaces/namespaces.py +++ b/src/cloudflare/resources/durable_objects/namespaces/namespaces.py @@ -13,7 +13,7 @@ AsyncObjectsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -57,7 +57,7 @@ def with_streaming_response(self) -> NamespacesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -85,10 +85,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/durable_objects/namespaces", + path_template("/accounts/{account_id}/workers/durable_objects/namespaces", account_id=account_id), page=SyncV4PagePaginationArray[Namespace], options=make_request_options( extra_headers=extra_headers, @@ -134,7 +136,7 @@ def with_streaming_response(self) -> AsyncNamespacesResourceWithStreamingRespons def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -162,10 +164,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/durable_objects/namespaces", + path_template("/accounts/{account_id}/workers/durable_objects/namespaces", account_id=account_id), page=AsyncV4PagePaginationArray[Namespace], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/durable_objects/namespaces/objects.py b/src/cloudflare/resources/durable_objects/namespaces/objects.py index 64e42f7f928..9933ee3fb24 100644 --- a/src/cloudflare/resources/durable_objects/namespaces/objects.py +++ b/src/cloudflare/resources/durable_objects/namespaces/objects.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +46,7 @@ def list( self, id: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, limit: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -79,12 +79,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/durable_objects/namespaces/{id}/objects", + path_template( + "/accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects", account_id=account_id, id=id + ), page=SyncCursorPaginationAfter[DurableObject], options=make_request_options( extra_headers=extra_headers, @@ -127,7 +131,7 @@ def list( self, id: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, limit: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -160,12 +164,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/durable_objects/namespaces/{id}/objects", + path_template( + "/accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects", account_id=account_id, id=id + ), page=AsyncCursorPaginationAfter[DurableObject], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/email_routing/addresses.py b/src/cloudflare/resources/email_routing/addresses.py index 4cf6946ce13..206f7e5c22c 100644 --- a/src/cloudflare/resources/email_routing/addresses.py +++ b/src/cloudflare/resources/email_routing/addresses.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> AddressesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, email: 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. @@ -76,10 +76,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email/routing/addresses", + path_template("/accounts/{account_id}/email/routing/addresses", account_id=account_id), body=maybe_transform({"email": email}, address_create_params.AddressCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -94,7 +96,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -128,10 +130,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email/routing/addresses", + path_template("/accounts/{account_id}/email/routing/addresses", account_id=account_id), page=SyncV4PagePaginationArray[Address], options=make_request_options( extra_headers=extra_headers, @@ -155,7 +159,7 @@ def delete( self, destination_address_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -179,6 +183,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not destination_address_identifier: @@ -186,7 +192,11 @@ def delete( f"Expected a non-empty value for `destination_address_identifier` but received {destination_address_identifier!r}" ) return self._delete( - f"/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}", + path_template( + "/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}", + account_id=account_id, + destination_address_identifier=destination_address_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -201,7 +211,7 @@ def get( self, destination_address_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -225,6 +235,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not destination_address_identifier: @@ -232,7 +244,11 @@ def get( f"Expected a non-empty value for `destination_address_identifier` but received {destination_address_identifier!r}" ) return self._get( - f"/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}", + path_template( + "/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}", + account_id=account_id, + destination_address_identifier=destination_address_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -267,7 +283,7 @@ def with_streaming_response(self) -> AsyncAddressesResourceWithStreamingResponse async def create( self, *, - account_id: str, + account_id: str | None = None, email: 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. @@ -294,10 +310,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email/routing/addresses", + path_template("/accounts/{account_id}/email/routing/addresses", account_id=account_id), body=await async_maybe_transform({"email": email}, address_create_params.AddressCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -312,7 +330,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -346,10 +364,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email/routing/addresses", + path_template("/accounts/{account_id}/email/routing/addresses", account_id=account_id), page=AsyncV4PagePaginationArray[Address], options=make_request_options( extra_headers=extra_headers, @@ -373,7 +393,7 @@ async def delete( self, destination_address_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -397,6 +417,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not destination_address_identifier: @@ -404,7 +426,11 @@ async def delete( f"Expected a non-empty value for `destination_address_identifier` but received {destination_address_identifier!r}" ) return await self._delete( - f"/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}", + path_template( + "/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}", + account_id=account_id, + destination_address_identifier=destination_address_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -419,7 +445,7 @@ async def get( self, destination_address_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -443,6 +469,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not destination_address_identifier: @@ -450,7 +478,11 @@ async def get( f"Expected a non-empty value for `destination_address_identifier` but received {destination_address_identifier!r}" ) return await self._get( - f"/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}", + path_template( + "/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}", + account_id=account_id, + destination_address_identifier=destination_address_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_routing/api.md b/src/cloudflare/resources/email_routing/api.md new file mode 100644 index 00000000000..26a1d76019a --- /dev/null +++ b/src/cloudflare/resources/email_routing/api.md @@ -0,0 +1,77 @@ +# 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: + +```python +from cloudflare.types.email_routing import DNSRecord, DNSGetResponse +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.email_routing import Action, EmailRoutingRule, Matcher +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.email_routing.rules import ( + CatchAllAction, + CatchAllMatcher, + CatchAllUpdateResponse, + CatchAllGetResponse, +) +``` + +Methods: + +- client.email_routing.rules.catch_alls.update(\*, zone_id, \*\*params) -> Optional[CatchAllUpdateResponse] +- client.email_routing.rules.catch_alls.get(\*, zone_id) -> Optional[CatchAllGetResponse] + +## Addresses + +Types: + +```python +from cloudflare.types.email_routing import Address +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/email_routing/dns.py b/src/cloudflare/resources/email_routing/dns.py index 2dce6f176e8..87ade44d281 100644 --- a/src/cloudflare/resources/email_routing/dns.py +++ b/src/cloudflare/resources/email_routing/dns.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> DNSResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -76,10 +76,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/dns", + path_template("/zones/{zone_id}/email/routing/dns", zone_id=zone_id), body=maybe_transform({"name": name}, dns_create_params.DNSCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -94,7 +96,7 @@ def create( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -118,10 +120,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/dns", + path_template("/zones/{zone_id}/email/routing/dns", zone_id=zone_id), page=SyncSinglePage[DNSRecord], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -133,7 +137,7 @@ def delete( def edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -158,10 +162,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/dns", + path_template("/zones/{zone_id}/email/routing/dns", zone_id=zone_id), body=maybe_transform({"name": name}, dns_edit_params.DNSEditParams), options=make_request_options( extra_headers=extra_headers, @@ -176,7 +182,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, subdomain: 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. @@ -201,12 +207,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( DNSGetResponse, self._get( - f"/zones/{zone_id}/email/routing/dns", + path_template("/zones/{zone_id}/email/routing/dns", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -242,7 +250,7 @@ def with_streaming_response(self) -> AsyncDNSResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -268,10 +276,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/dns", + path_template("/zones/{zone_id}/email/routing/dns", zone_id=zone_id), body=await async_maybe_transform({"name": name}, dns_create_params.DNSCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -286,7 +296,7 @@ async def create( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -310,10 +320,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/dns", + path_template("/zones/{zone_id}/email/routing/dns", zone_id=zone_id), page=AsyncSinglePage[DNSRecord], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -325,7 +337,7 @@ def delete( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -350,10 +362,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/dns", + path_template("/zones/{zone_id}/email/routing/dns", zone_id=zone_id), body=await async_maybe_transform({"name": name}, dns_edit_params.DNSEditParams), options=make_request_options( extra_headers=extra_headers, @@ -368,7 +382,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, subdomain: 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. @@ -393,12 +407,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( DNSGetResponse, await self._get( - f"/zones/{zone_id}/email/routing/dns", + path_template("/zones/{zone_id}/email/routing/dns", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_routing/email_routing.py b/src/cloudflare/resources/email_routing/email_routing.py index 58e4029f429..815a491c888 100644 --- a/src/cloudflare/resources/email_routing/email_routing.py +++ b/src/cloudflare/resources/email_routing/email_routing.py @@ -16,7 +16,7 @@ AsyncDNSResourceWithStreamingResponse, ) from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from .addresses import ( AddressesResource, @@ -85,7 +85,7 @@ def with_streaming_response(self) -> EmailRoutingResourceWithStreamingResponse: def disable( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -110,10 +110,12 @@ def disable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/disable", + path_template("/zones/{zone_id}/email/routing/disable", zone_id=zone_id), body=maybe_transform(body, email_routing_disable_params.EmailRoutingDisableParams), options=make_request_options( extra_headers=extra_headers, @@ -129,7 +131,7 @@ def disable( def enable( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -153,10 +155,12 @@ def enable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/enable", + path_template("/zones/{zone_id}/email/routing/enable", zone_id=zone_id), body=maybe_transform(body, email_routing_enable_params.EmailRoutingEnableParams), options=make_request_options( extra_headers=extra_headers, @@ -171,7 +175,7 @@ def enable( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -193,10 +197,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/email/routing", + path_template("/zones/{zone_id}/email/routing", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -244,7 +250,7 @@ def with_streaming_response(self) -> AsyncEmailRoutingResourceWithStreamingRespo async def disable( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -269,10 +275,12 @@ async def disable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/disable", + path_template("/zones/{zone_id}/email/routing/disable", zone_id=zone_id), body=await async_maybe_transform(body, email_routing_disable_params.EmailRoutingDisableParams), options=make_request_options( extra_headers=extra_headers, @@ -288,7 +296,7 @@ async def disable( async def enable( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -312,10 +320,12 @@ async def enable( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/enable", + path_template("/zones/{zone_id}/email/routing/enable", zone_id=zone_id), body=await async_maybe_transform(body, email_routing_enable_params.EmailRoutingEnableParams), options=make_request_options( extra_headers=extra_headers, @@ -330,7 +340,7 @@ async def enable( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -352,10 +362,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/email/routing", + path_template("/zones/{zone_id}/email/routing", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_routing/rules/catch_alls.py b/src/cloudflare/resources/email_routing/rules/catch_alls.py index 396b4ce1893..960c1a9765c 100644 --- a/src/cloudflare/resources/email_routing/rules/catch_alls.py +++ b/src/cloudflare/resources/email_routing/rules/catch_alls.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> CatchAllsResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[CatchAllActionParam], matchers: Iterable[CatchAllMatcherParam], enabled: Literal[True, False] | Omit = omit, @@ -87,10 +87,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/email/routing/rules/catch_all", + path_template("/zones/{zone_id}/email/routing/rules/catch_all", zone_id=zone_id), body=maybe_transform( { "actions": actions, @@ -113,7 +115,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -135,10 +137,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/email/routing/rules/catch_all", + path_template("/zones/{zone_id}/email/routing/rules/catch_all", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -173,7 +177,7 @@ def with_streaming_response(self) -> AsyncCatchAllsResourceWithStreamingResponse async def update( self, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[CatchAllActionParam], matchers: Iterable[CatchAllMatcherParam], enabled: Literal[True, False] | Omit = omit, @@ -209,10 +213,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/email/routing/rules/catch_all", + path_template("/zones/{zone_id}/email/routing/rules/catch_all", zone_id=zone_id), body=await async_maybe_transform( { "actions": actions, @@ -235,7 +241,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -257,10 +263,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/email/routing/rules/catch_all", + path_template("/zones/{zone_id}/email/routing/rules/catch_all", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_routing/rules/rules.py b/src/cloudflare/resources/email_routing/rules/rules.py index 9cdcf86c493..f06fd3331e4 100644 --- a/src/cloudflare/resources/email_routing/rules/rules.py +++ b/src/cloudflare/resources/email_routing/rules/rules.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from .catch_alls import ( CatchAllsResource, @@ -63,7 +63,7 @@ def with_streaming_response(self) -> RulesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[ActionParam], matchers: Iterable[MatcherParam], enabled: Literal[True, False] | Omit = omit, @@ -103,10 +103,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/rules", + path_template("/zones/{zone_id}/email/routing/rules", zone_id=zone_id), body=maybe_transform( { "actions": actions, @@ -131,7 +133,7 @@ def update( self, rule_identifier: str, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[ActionParam], matchers: Iterable[MatcherParam], enabled: Literal[True, False] | Omit = omit, @@ -172,12 +174,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_identifier: raise ValueError(f"Expected a non-empty value for `rule_identifier` but received {rule_identifier!r}") return self._put( - f"/zones/{zone_id}/email/routing/rules/{rule_identifier}", + path_template( + "/zones/{zone_id}/email/routing/rules/{rule_identifier}", + zone_id=zone_id, + rule_identifier=rule_identifier, + ), body=maybe_transform( { "actions": actions, @@ -201,7 +209,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, enabled: Literal[True, False] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -232,10 +240,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/rules", + path_template("/zones/{zone_id}/email/routing/rules", zone_id=zone_id), page=SyncV4PagePaginationArray[EmailRoutingRule], options=make_request_options( extra_headers=extra_headers, @@ -258,7 +268,7 @@ def delete( self, rule_identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -282,12 +292,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_identifier: raise ValueError(f"Expected a non-empty value for `rule_identifier` but received {rule_identifier!r}") return self._delete( - f"/zones/{zone_id}/email/routing/rules/{rule_identifier}", + path_template( + "/zones/{zone_id}/email/routing/rules/{rule_identifier}", + zone_id=zone_id, + rule_identifier=rule_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -302,7 +318,7 @@ def get( self, rule_identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -326,12 +342,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_identifier: raise ValueError(f"Expected a non-empty value for `rule_identifier` but received {rule_identifier!r}") return self._get( - f"/zones/{zone_id}/email/routing/rules/{rule_identifier}", + path_template( + "/zones/{zone_id}/email/routing/rules/{rule_identifier}", + zone_id=zone_id, + rule_identifier=rule_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -370,7 +392,7 @@ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[ActionParam], matchers: Iterable[MatcherParam], enabled: Literal[True, False] | Omit = omit, @@ -410,10 +432,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/rules", + path_template("/zones/{zone_id}/email/routing/rules", zone_id=zone_id), body=await async_maybe_transform( { "actions": actions, @@ -438,7 +462,7 @@ async def update( self, rule_identifier: str, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[ActionParam], matchers: Iterable[MatcherParam], enabled: Literal[True, False] | Omit = omit, @@ -479,12 +503,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_identifier: raise ValueError(f"Expected a non-empty value for `rule_identifier` but received {rule_identifier!r}") return await self._put( - f"/zones/{zone_id}/email/routing/rules/{rule_identifier}", + path_template( + "/zones/{zone_id}/email/routing/rules/{rule_identifier}", + zone_id=zone_id, + rule_identifier=rule_identifier, + ), body=await async_maybe_transform( { "actions": actions, @@ -508,7 +538,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, enabled: Literal[True, False] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -539,10 +569,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/routing/rules", + path_template("/zones/{zone_id}/email/routing/rules", zone_id=zone_id), page=AsyncV4PagePaginationArray[EmailRoutingRule], options=make_request_options( extra_headers=extra_headers, @@ -565,7 +597,7 @@ async def delete( self, rule_identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -589,12 +621,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_identifier: raise ValueError(f"Expected a non-empty value for `rule_identifier` but received {rule_identifier!r}") return await self._delete( - f"/zones/{zone_id}/email/routing/rules/{rule_identifier}", + path_template( + "/zones/{zone_id}/email/routing/rules/{rule_identifier}", + zone_id=zone_id, + rule_identifier=rule_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -609,7 +647,7 @@ async def get( self, rule_identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -633,12 +671,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_identifier: raise ValueError(f"Expected a non-empty value for `rule_identifier` but received {rule_identifier!r}") return await self._get( - f"/zones/{zone_id}/email/routing/rules/{rule_identifier}", + path_template( + "/zones/{zone_id}/email/routing/rules/{rule_identifier}", + zone_id=zone_id, + rule_identifier=rule_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/api.md b/src/cloudflare/resources/email_security/api.md new file mode 100644 index 00000000000..53e335ba90a --- /dev/null +++ b/src/cloudflare/resources/email_security/api.md @@ -0,0 +1,232 @@ +# 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, \*\*params) -> 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, \*\*params) -> 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) -> 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] + +## Phishguard + +### Reports + +Types: + +```python +from cloudflare.types.email_security.phishguard import ReportListResponse +``` + +Methods: + +- client.email_security.phishguard.reports.list(\*, account_id, \*\*params) -> SyncSinglePage[ReportListResponse] + +## 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] diff --git a/src/cloudflare/resources/email_security/investigate/detections.py b/src/cloudflare/resources/email_security/investigate/detections.py index f3e5c978d25..b8db8f510b2 100644 --- a/src/cloudflare/resources/email_security/investigate/detections.py +++ b/src/cloudflare/resources/email_security/investigate/detections.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +47,7 @@ def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -71,12 +72,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/detections", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/detections", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -112,7 +119,7 @@ async def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -137,12 +144,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return await self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/detections", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/detections", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/investigate/investigate.py b/src/cloudflare/resources/email_security/investigate/investigate.py index 231c4678059..f161711f98d 100644 --- a/src/cloudflare/resources/email_security/investigate/investigate.py +++ b/src/cloudflare/resources/email_security/investigate/investigate.py @@ -49,7 +49,7 @@ AsyncReleaseResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from .detections import ( DetectionsResource, @@ -135,7 +135,7 @@ def with_streaming_response(self) -> InvestigateResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, action_log: bool | Omit = omit, alert_id: str | Omit = omit, cursor: str | Omit = omit, @@ -235,10 +235,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/investigate", + path_template("/accounts/{account_id}/email-security/investigate", account_id=account_id), page=SyncV4PagePaginationArray[InvestigateListResponse], options=make_request_options( extra_headers=extra_headers, @@ -277,7 +279,7 @@ def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, submission: 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. @@ -306,12 +308,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -375,7 +383,7 @@ def with_streaming_response(self) -> AsyncInvestigateResourceWithStreamingRespon def list( self, *, - account_id: str, + account_id: str | None = None, action_log: bool | Omit = omit, alert_id: str | Omit = omit, cursor: str | Omit = omit, @@ -475,10 +483,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/investigate", + path_template("/accounts/{account_id}/email-security/investigate", account_id=account_id), page=AsyncV4PagePaginationArray[InvestigateListResponse], options=make_request_options( extra_headers=extra_headers, @@ -517,7 +527,7 @@ async def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, submission: 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. @@ -546,12 +556,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return await self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/investigate/move.py b/src/cloudflare/resources/email_security/investigate/move.py index 7c3fbd9bebb..48b7b61f3f3 100644 --- a/src/cloudflare/resources/email_security/investigate/move.py +++ b/src/cloudflare/resources/email_security/investigate/move.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def create( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, destination: Literal[ "Inbox", "JunkEmail", "DeletedItems", "RecoverableItemsDeletions", "RecoverableItemsPurges" ], @@ -83,12 +83,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return self._post( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/move", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/move", + account_id=account_id, + postfix_id=postfix_id, + ), body=maybe_transform({"destination": destination}, move_create_params.MoveCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -104,7 +110,7 @@ def create( def bulk( self, *, - account_id: str, + account_id: str | None = None, destination: Literal[ "Inbox", "JunkEmail", "DeletedItems", "RecoverableItemsDeletions", "RecoverableItemsPurges" ], @@ -135,10 +141,12 @@ def bulk( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/investigate/move", + path_template("/accounts/{account_id}/email-security/investigate/move", account_id=account_id), page=SyncSinglePage[MoveBulkResponse], body=maybe_transform( { @@ -180,7 +188,7 @@ async def create( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, destination: Literal[ "Inbox", "JunkEmail", "DeletedItems", "RecoverableItemsDeletions", "RecoverableItemsPurges" ], @@ -212,12 +220,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return await self._post( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/move", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/move", + account_id=account_id, + postfix_id=postfix_id, + ), body=await async_maybe_transform({"destination": destination}, move_create_params.MoveCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -233,7 +247,7 @@ async def create( def bulk( self, *, - account_id: str, + account_id: str | None = None, destination: Literal[ "Inbox", "JunkEmail", "DeletedItems", "RecoverableItemsDeletions", "RecoverableItemsPurges" ], @@ -264,10 +278,12 @@ def bulk( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/investigate/move", + path_template("/accounts/{account_id}/email-security/investigate/move", account_id=account_id), page=AsyncSinglePage[MoveBulkResponse], body=maybe_transform( { diff --git a/src/cloudflare/resources/email_security/investigate/preview.py b/src/cloudflare/resources/email_security/investigate/preview.py index b7917861d64..6f67f27d05e 100644 --- a/src/cloudflare/resources/email_security/investigate/preview.py +++ b/src/cloudflare/resources/email_security/investigate/preview.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> PreviewResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, postfix_id: str, submission: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -78,10 +78,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/investigate/preview", + path_template("/accounts/{account_id}/email-security/investigate/preview", account_id=account_id), body=maybe_transform({"postfix_id": postfix_id}, preview_create_params.PreviewCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -98,7 +100,7 @@ def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,12 +125,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/preview", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/preview", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -163,7 +171,7 @@ def with_streaming_response(self) -> AsyncPreviewResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, postfix_id: str, submission: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -193,10 +201,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/investigate/preview", + path_template("/accounts/{account_id}/email-security/investigate/preview", account_id=account_id), body=await async_maybe_transform({"postfix_id": postfix_id}, preview_create_params.PreviewCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -215,7 +225,7 @@ async def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -240,12 +250,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return await self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/preview", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/preview", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/investigate/raw.py b/src/cloudflare/resources/email_security/investigate/raw.py index 473f6a6330e..1b65794d1dd 100644 --- a/src/cloudflare/resources/email_security/investigate/raw.py +++ b/src/cloudflare/resources/email_security/investigate/raw.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +47,7 @@ def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -70,12 +71,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/raw", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/raw", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -111,7 +118,7 @@ async def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -135,12 +142,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return await self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/raw", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/raw", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/investigate/reclassify.py b/src/cloudflare/resources/email_security/investigate/reclassify.py index fe83cd2ac58..43a36a3d1ef 100644 --- a/src/cloudflare/resources/email_security/investigate/reclassify.py +++ b/src/cloudflare/resources/email_security/investigate/reclassify.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def create( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, expected_disposition: Literal["NONE", "BULK", "MALICIOUS", "SPAM", "SPOOF", "SUSPICIOUS"], submission: bool | Omit = omit, eml_content: str | Omit = omit, @@ -82,12 +82,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return self._post( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/reclassify", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/reclassify", + account_id=account_id, + postfix_id=postfix_id, + ), body=maybe_transform( { "expected_disposition": expected_disposition, @@ -132,7 +138,7 @@ async def create( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, expected_disposition: Literal["NONE", "BULK", "MALICIOUS", "SPAM", "SPOOF", "SUSPICIOUS"], submission: bool | Omit = omit, eml_content: str | Omit = omit, @@ -166,12 +172,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return await self._post( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/reclassify", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/reclassify", + account_id=account_id, + postfix_id=postfix_id, + ), body=await async_maybe_transform( { "expected_disposition": expected_disposition, diff --git a/src/cloudflare/resources/email_security/investigate/release.py b/src/cloudflare/resources/email_security/investigate/release.py index 1fe506c920d..2bb1e0c9404 100644 --- a/src/cloudflare/resources/email_security/investigate/release.py +++ b/src/cloudflare/resources/email_security/investigate/release.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,7 +44,7 @@ def with_streaming_response(self) -> ReleaseResourceWithStreamingResponse: def bulk( self, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -70,10 +70,12 @@ def bulk( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/investigate/release", + path_template("/accounts/{account_id}/email-security/investigate/release", account_id=account_id), page=SyncSinglePage[ReleaseBulkResponse], body=maybe_transform(body, SequenceNotStr[str]), options=make_request_options( @@ -107,7 +109,7 @@ def with_streaming_response(self) -> AsyncReleaseResourceWithStreamingResponse: def bulk( self, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -133,10 +135,12 @@ def bulk( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/investigate/release", + path_template("/accounts/{account_id}/email-security/investigate/release", account_id=account_id), page=AsyncSinglePage[ReleaseBulkResponse], body=maybe_transform(body, SequenceNotStr[str]), options=make_request_options( diff --git a/src/cloudflare/resources/email_security/investigate/trace.py b/src/cloudflare/resources/email_security/investigate/trace.py index c9e5765b062..228dce7d129 100644 --- a/src/cloudflare/resources/email_security/investigate/trace.py +++ b/src/cloudflare/resources/email_security/investigate/trace.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, submission: 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. @@ -77,12 +77,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/trace", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/trace", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -119,7 +125,7 @@ async def get( self, postfix_id: str, *, - account_id: str, + account_id: str | None = None, submission: 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. @@ -148,12 +154,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not postfix_id: raise ValueError(f"Expected a non-empty value for `postfix_id` but received {postfix_id!r}") return await self._get( - f"/accounts/{account_id}/email-security/investigate/{postfix_id}/trace", + path_template( + "/accounts/{account_id}/email-security/investigate/{postfix_id}/trace", + account_id=account_id, + postfix_id=postfix_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/phishguard/reports.py b/src/cloudflare/resources/email_security/phishguard/reports.py index 14e10e977f3..5e77df7ac57 100644 --- a/src/cloudflare/resources/email_security/phishguard/reports.py +++ b/src/cloudflare/resources/email_security/phishguard/reports.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> ReportsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, end: Union[str, datetime] | Omit = omit, from_date: Union[str, date] | Omit = omit, start: Union[str, datetime] | Omit = omit, @@ -79,10 +79,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/phishguard/reports", + path_template("/accounts/{account_id}/email-security/phishguard/reports", account_id=account_id), page=SyncSinglePage[ReportListResponse], options=make_request_options( extra_headers=extra_headers, @@ -126,7 +128,7 @@ def with_streaming_response(self) -> AsyncReportsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, end: Union[str, datetime] | Omit = omit, from_date: Union[str, date] | Omit = omit, start: Union[str, datetime] | Omit = omit, @@ -157,10 +159,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/phishguard/reports", + path_template("/accounts/{account_id}/email-security/phishguard/reports", account_id=account_id), page=AsyncSinglePage[ReportListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/email_security/settings/allow_policies.py b/src/cloudflare/resources/email_security/settings/allow_policies.py index 05d886a4b0f..39aa95c39ab 100644 --- a/src/cloudflare/resources/email_security/settings/allow_policies.py +++ b/src/cloudflare/resources/email_security/settings/allow_policies.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -57,7 +57,7 @@ def with_streaming_response(self) -> AllowPoliciesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, is_acceptable_sender: bool, is_exempt_recipient: bool, is_regex: bool, @@ -102,10 +102,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/allow_policies", + path_template("/accounts/{account_id}/email-security/settings/allow_policies", account_id=account_id), body=maybe_transform( { "is_acceptable_sender": is_acceptable_sender, @@ -135,7 +137,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, is_acceptable_sender: bool | Omit = omit, is_exempt_recipient: bool | Omit = omit, @@ -183,10 +185,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/allow_policies", + path_template("/accounts/{account_id}/email-security/settings/allow_policies", account_id=account_id), page=SyncV4PagePaginationArray[AllowPolicyListResponse], options=make_request_options( extra_headers=extra_headers, @@ -220,7 +224,7 @@ def delete( self, policy_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -246,10 +250,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/allow_policies/{policy_id}", + path_template( + "/accounts/{account_id}/email-security/settings/allow_policies/{policy_id}", + account_id=account_id, + policy_id=policy_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -264,7 +274,7 @@ def edit( self, policy_id: int, *, - account_id: str, + account_id: str | None = None, comments: Optional[str] | Omit = omit, is_acceptable_sender: Optional[bool] | Omit = omit, is_exempt_recipient: Optional[bool] | Omit = omit, @@ -308,10 +318,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/email-security/settings/allow_policies/{policy_id}", + path_template( + "/accounts/{account_id}/email-security/settings/allow_policies/{policy_id}", + account_id=account_id, + policy_id=policy_id, + ), body=maybe_transform( { "comments": comments, @@ -339,7 +355,7 @@ def get( self, policy_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -364,10 +380,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/allow_policies/{policy_id}", + path_template( + "/accounts/{account_id}/email-security/settings/allow_policies/{policy_id}", + account_id=account_id, + policy_id=policy_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -402,7 +424,7 @@ def with_streaming_response(self) -> AsyncAllowPoliciesResourceWithStreamingResp async def create( self, *, - account_id: str, + account_id: str | None = None, is_acceptable_sender: bool, is_exempt_recipient: bool, is_regex: bool, @@ -447,10 +469,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/allow_policies", + path_template("/accounts/{account_id}/email-security/settings/allow_policies", account_id=account_id), body=await async_maybe_transform( { "is_acceptable_sender": is_acceptable_sender, @@ -480,7 +504,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, is_acceptable_sender: bool | Omit = omit, is_exempt_recipient: bool | Omit = omit, @@ -528,10 +552,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/allow_policies", + path_template("/accounts/{account_id}/email-security/settings/allow_policies", account_id=account_id), page=AsyncV4PagePaginationArray[AllowPolicyListResponse], options=make_request_options( extra_headers=extra_headers, @@ -565,7 +591,7 @@ async def delete( self, policy_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -591,10 +617,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/allow_policies/{policy_id}", + path_template( + "/accounts/{account_id}/email-security/settings/allow_policies/{policy_id}", + account_id=account_id, + policy_id=policy_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -609,7 +641,7 @@ async def edit( self, policy_id: int, *, - account_id: str, + account_id: str | None = None, comments: Optional[str] | Omit = omit, is_acceptable_sender: Optional[bool] | Omit = omit, is_exempt_recipient: Optional[bool] | Omit = omit, @@ -653,10 +685,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/email-security/settings/allow_policies/{policy_id}", + path_template( + "/accounts/{account_id}/email-security/settings/allow_policies/{policy_id}", + account_id=account_id, + policy_id=policy_id, + ), body=await async_maybe_transform( { "comments": comments, @@ -684,7 +722,7 @@ async def get( self, policy_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -709,10 +747,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/allow_policies/{policy_id}", + path_template( + "/accounts/{account_id}/email-security/settings/allow_policies/{policy_id}", + account_id=account_id, + policy_id=policy_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/settings/block_senders.py b/src/cloudflare/resources/email_security/settings/block_senders.py index c4f72b56dc6..47336dbdcf6 100644 --- a/src/cloudflare/resources/email_security/settings/block_senders.py +++ b/src/cloudflare/resources/email_security/settings/block_senders.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -57,7 +57,7 @@ def with_streaming_response(self) -> BlockSendersResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, is_regex: bool, pattern: str, pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"], @@ -84,10 +84,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/block_senders", + path_template("/accounts/{account_id}/email-security/settings/block_senders", account_id=account_id), body=maybe_transform( { "is_regex": is_regex, @@ -110,7 +112,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["pattern", "created_at"] | Omit = omit, page: int | Omit = omit, @@ -151,10 +153,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/block_senders", + path_template("/accounts/{account_id}/email-security/settings/block_senders", account_id=account_id), page=SyncV4PagePaginationArray[BlockSenderListResponse], options=make_request_options( extra_headers=extra_headers, @@ -181,7 +185,7 @@ def delete( self, pattern_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -206,10 +210,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/block_senders/{pattern_id}", + path_template( + "/accounts/{account_id}/email-security/settings/block_senders/{pattern_id}", + account_id=account_id, + pattern_id=pattern_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -224,7 +234,7 @@ def edit( self, pattern_id: int, *, - account_id: str, + account_id: str | None = None, comments: Optional[str] | Omit = omit, is_regex: Optional[bool] | Omit = omit, pattern: Optional[str] | Omit = omit, @@ -252,10 +262,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/email-security/settings/block_senders/{pattern_id}", + path_template( + "/accounts/{account_id}/email-security/settings/block_senders/{pattern_id}", + account_id=account_id, + pattern_id=pattern_id, + ), body=maybe_transform( { "comments": comments, @@ -279,7 +295,7 @@ def get( self, pattern_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -304,10 +320,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/block_senders/{pattern_id}", + path_template( + "/accounts/{account_id}/email-security/settings/block_senders/{pattern_id}", + account_id=account_id, + pattern_id=pattern_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -342,7 +364,7 @@ def with_streaming_response(self) -> AsyncBlockSendersResourceWithStreamingRespo async def create( self, *, - account_id: str, + account_id: str | None = None, is_regex: bool, pattern: str, pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"], @@ -369,10 +391,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/block_senders", + path_template("/accounts/{account_id}/email-security/settings/block_senders", account_id=account_id), body=await async_maybe_transform( { "is_regex": is_regex, @@ -395,7 +419,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["pattern", "created_at"] | Omit = omit, page: int | Omit = omit, @@ -436,10 +460,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/block_senders", + path_template("/accounts/{account_id}/email-security/settings/block_senders", account_id=account_id), page=AsyncV4PagePaginationArray[BlockSenderListResponse], options=make_request_options( extra_headers=extra_headers, @@ -466,7 +492,7 @@ async def delete( self, pattern_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -491,10 +517,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/block_senders/{pattern_id}", + path_template( + "/accounts/{account_id}/email-security/settings/block_senders/{pattern_id}", + account_id=account_id, + pattern_id=pattern_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -509,7 +541,7 @@ async def edit( self, pattern_id: int, *, - account_id: str, + account_id: str | None = None, comments: Optional[str] | Omit = omit, is_regex: Optional[bool] | Omit = omit, pattern: Optional[str] | Omit = omit, @@ -537,10 +569,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/email-security/settings/block_senders/{pattern_id}", + path_template( + "/accounts/{account_id}/email-security/settings/block_senders/{pattern_id}", + account_id=account_id, + pattern_id=pattern_id, + ), body=await async_maybe_transform( { "comments": comments, @@ -564,7 +602,7 @@ async def get( self, pattern_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -589,10 +627,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/block_senders/{pattern_id}", + path_template( + "/accounts/{account_id}/email-security/settings/block_senders/{pattern_id}", + account_id=account_id, + pattern_id=pattern_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/settings/domains.py b/src/cloudflare/resources/email_security/settings/domains.py index cfe78def266..bf3671f0b5f 100644 --- a/src/cloudflare/resources/email_security/settings/domains.py +++ b/src/cloudflare/resources/email_security/settings/domains.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> DomainsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, active_delivery_mode: Literal["DIRECT", "BCC", "JOURNAL", "API", "RETRO_SCAN"] | Omit = omit, allowed_delivery_mode: Literal["DIRECT", "BCC", "JOURNAL", "API", "RETRO_SCAN"] | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, @@ -104,10 +104,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/domains", + path_template("/accounts/{account_id}/email-security/settings/domains", account_id=account_id), page=SyncV4PagePaginationArray[DomainListResponse], options=make_request_options( extra_headers=extra_headers, @@ -136,7 +138,7 @@ def delete( self, domain_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -160,10 +162,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/domains/{domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/domains/{domain_id}", + account_id=account_id, + domain_id=domain_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -177,7 +185,7 @@ def delete( def bulk_delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -200,10 +208,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/domains", + path_template("/accounts/{account_id}/email-security/settings/domains", account_id=account_id), page=SyncSinglePage[DomainBulkDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -216,7 +226,7 @@ def edit( self, domain_id: int, *, - account_id: str, + account_id: str | None = None, ip_restrictions: SequenceNotStr[str], allowed_delivery_modes: List[Literal["DIRECT", "BCC", "JOURNAL", "API", "RETRO_SCAN"]] | Omit = omit, domain: str | Omit = omit, @@ -265,10 +275,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/email-security/settings/domains/{domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/domains/{domain_id}", + account_id=account_id, + domain_id=domain_id, + ), body=maybe_transform( { "ip_restrictions": ip_restrictions, @@ -299,7 +315,7 @@ def get( self, domain_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -323,10 +339,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/domains/{domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/domains/{domain_id}", + account_id=account_id, + domain_id=domain_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -361,7 +383,7 @@ def with_streaming_response(self) -> AsyncDomainsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, active_delivery_mode: Literal["DIRECT", "BCC", "JOURNAL", "API", "RETRO_SCAN"] | Omit = omit, allowed_delivery_mode: Literal["DIRECT", "BCC", "JOURNAL", "API", "RETRO_SCAN"] | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, @@ -412,10 +434,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/domains", + path_template("/accounts/{account_id}/email-security/settings/domains", account_id=account_id), page=AsyncV4PagePaginationArray[DomainListResponse], options=make_request_options( extra_headers=extra_headers, @@ -444,7 +468,7 @@ async def delete( self, domain_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -468,10 +492,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/domains/{domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/domains/{domain_id}", + account_id=account_id, + domain_id=domain_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -485,7 +515,7 @@ async def delete( def bulk_delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -508,10 +538,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/domains", + path_template("/accounts/{account_id}/email-security/settings/domains", account_id=account_id), page=AsyncSinglePage[DomainBulkDeleteResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -524,7 +556,7 @@ async def edit( self, domain_id: int, *, - account_id: str, + account_id: str | None = None, ip_restrictions: SequenceNotStr[str], allowed_delivery_modes: List[Literal["DIRECT", "BCC", "JOURNAL", "API", "RETRO_SCAN"]] | Omit = omit, domain: str | Omit = omit, @@ -573,10 +605,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/email-security/settings/domains/{domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/domains/{domain_id}", + account_id=account_id, + domain_id=domain_id, + ), body=await async_maybe_transform( { "ip_restrictions": ip_restrictions, @@ -607,7 +645,7 @@ async def get( self, domain_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -631,10 +669,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/domains/{domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/domains/{domain_id}", + account_id=account_id, + domain_id=domain_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/settings/impersonation_registry.py b/src/cloudflare/resources/email_security/settings/impersonation_registry.py index 988929ff74d..4e550771f42 100644 --- a/src/cloudflare/resources/email_security/settings/impersonation_registry.py +++ b/src/cloudflare/resources/email_security/settings/impersonation_registry.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -57,7 +57,7 @@ def with_streaming_response(self) -> ImpersonationRegistryResourceWithStreamingR def create( self, *, - account_id: str, + account_id: str | None = None, email: str, is_email_regex: bool, name: str, @@ -82,10 +82,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/impersonation_registry", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry", account_id=account_id + ), body=maybe_transform( { "email": email, @@ -107,7 +111,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["name", "email", "created_at"] | Omit = omit, page: int | Omit = omit, @@ -148,10 +152,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/impersonation_registry", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry", account_id=account_id + ), page=SyncV4PagePaginationArray[ImpersonationRegistryListResponse], options=make_request_options( extra_headers=extra_headers, @@ -177,7 +185,7 @@ def delete( self, display_name_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -199,10 +207,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/impersonation_registry/{display_name_id}", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry/{display_name_id}", + account_id=account_id, + display_name_id=display_name_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -217,7 +231,7 @@ def edit( self, display_name_id: int, *, - account_id: str, + account_id: str | None = None, email: Optional[str] | Omit = omit, is_email_regex: Optional[bool] | Omit = omit, name: Optional[str] | Omit = omit, @@ -242,10 +256,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/email-security/settings/impersonation_registry/{display_name_id}", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry/{display_name_id}", + account_id=account_id, + display_name_id=display_name_id, + ), body=maybe_transform( { "email": email, @@ -268,7 +288,7 @@ def get( self, display_name_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -290,10 +310,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/impersonation_registry/{display_name_id}", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry/{display_name_id}", + account_id=account_id, + display_name_id=display_name_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -328,7 +354,7 @@ def with_streaming_response(self) -> AsyncImpersonationRegistryResourceWithStrea async def create( self, *, - account_id: str, + account_id: str | None = None, email: str, is_email_regex: bool, name: str, @@ -353,10 +379,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/impersonation_registry", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry", account_id=account_id + ), body=await async_maybe_transform( { "email": email, @@ -378,7 +408,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["name", "email", "created_at"] | Omit = omit, page: int | Omit = omit, @@ -421,10 +451,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/impersonation_registry", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry", account_id=account_id + ), page=AsyncV4PagePaginationArray[ImpersonationRegistryListResponse], options=make_request_options( extra_headers=extra_headers, @@ -450,7 +484,7 @@ async def delete( self, display_name_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -472,10 +506,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/impersonation_registry/{display_name_id}", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry/{display_name_id}", + account_id=account_id, + display_name_id=display_name_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -490,7 +530,7 @@ async def edit( self, display_name_id: int, *, - account_id: str, + account_id: str | None = None, email: Optional[str] | Omit = omit, is_email_regex: Optional[bool] | Omit = omit, name: Optional[str] | Omit = omit, @@ -515,10 +555,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/email-security/settings/impersonation_registry/{display_name_id}", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry/{display_name_id}", + account_id=account_id, + display_name_id=display_name_id, + ), body=await async_maybe_transform( { "email": email, @@ -541,7 +587,7 @@ async def get( self, display_name_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -563,10 +609,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/impersonation_registry/{display_name_id}", + path_template( + "/accounts/{account_id}/email-security/settings/impersonation_registry/{display_name_id}", + account_id=account_id, + display_name_id=display_name_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/settings/trusted_domains.py b/src/cloudflare/resources/email_security/settings/trusted_domains.py index e79b273cc4e..5e992975201 100644 --- a/src/cloudflare/resources/email_security/settings/trusted_domains.py +++ b/src/cloudflare/resources/email_security/settings/trusted_domains.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import required_args, maybe_transform, async_maybe_transform +from ...._utils import path_template, required_args, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -58,7 +58,7 @@ def with_streaming_response(self) -> TrustedDomainsResourceWithStreamingResponse def create( self, *, - account_id: str, + account_id: str | None = None, is_recent: bool, is_regex: bool, is_similarity: bool, @@ -98,7 +98,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[trusted_domain_create_params.Variant1Body], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -124,11 +124,11 @@ def create( """ ... - @required_args(["account_id", "is_recent", "is_regex", "is_similarity", "pattern"], ["account_id", "body"]) + @required_args(["is_recent", "is_regex", "is_similarity", "pattern"], ["body"]) def create( self, *, - account_id: str, + account_id: str | None = None, is_recent: bool | Omit = omit, is_regex: bool | Omit = omit, is_similarity: bool | Omit = omit, @@ -142,12 +142,14 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( TrustedDomainCreateResponse, self._post( - f"/accounts/{account_id}/email-security/settings/trusted_domains", + path_template("/accounts/{account_id}/email-security/settings/trusted_domains", account_id=account_id), body=maybe_transform( { "is_recent": is_recent, @@ -175,7 +177,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, is_recent: bool | Omit = omit, is_similarity: bool | Omit = omit, @@ -217,10 +219,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/trusted_domains", + path_template("/accounts/{account_id}/email-security/settings/trusted_domains", account_id=account_id), page=SyncV4PagePaginationArray[TrustedDomainListResponse], options=make_request_options( extra_headers=extra_headers, @@ -248,7 +252,7 @@ def delete( self, trusted_domain_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -273,10 +277,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/trusted_domains/{trusted_domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + account_id=account_id, + trusted_domain_id=trusted_domain_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -291,7 +301,7 @@ def edit( self, trusted_domain_id: int, *, - account_id: str, + account_id: str | None = None, comments: str | Omit = omit, is_recent: bool | Omit = omit, is_regex: bool | Omit = omit, @@ -326,10 +336,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + account_id=account_id, + trusted_domain_id=trusted_domain_id, + ), body=maybe_transform( { "comments": comments, @@ -354,7 +370,7 @@ def get( self, trusted_domain_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -378,10 +394,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/trusted_domains/{trusted_domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + account_id=account_id, + trusted_domain_id=trusted_domain_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -417,7 +439,7 @@ def with_streaming_response(self) -> AsyncTrustedDomainsResourceWithStreamingRes async def create( self, *, - account_id: str, + account_id: str | None = None, is_recent: bool, is_regex: bool, is_similarity: bool, @@ -457,7 +479,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[trusted_domain_create_params.Variant1Body], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -483,11 +505,11 @@ async def create( """ ... - @required_args(["account_id", "is_recent", "is_regex", "is_similarity", "pattern"], ["account_id", "body"]) + @required_args(["is_recent", "is_regex", "is_similarity", "pattern"], ["body"]) async def create( self, *, - account_id: str, + account_id: str | None = None, is_recent: bool | Omit = omit, is_regex: bool | Omit = omit, is_similarity: bool | Omit = omit, @@ -501,12 +523,14 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( TrustedDomainCreateResponse, await self._post( - f"/accounts/{account_id}/email-security/settings/trusted_domains", + path_template("/accounts/{account_id}/email-security/settings/trusted_domains", account_id=account_id), body=await async_maybe_transform( { "is_recent": is_recent, @@ -534,7 +558,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, is_recent: bool | Omit = omit, is_similarity: bool | Omit = omit, @@ -576,10 +600,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/trusted_domains", + path_template("/accounts/{account_id}/email-security/settings/trusted_domains", account_id=account_id), page=AsyncV4PagePaginationArray[TrustedDomainListResponse], options=make_request_options( extra_headers=extra_headers, @@ -607,7 +633,7 @@ async def delete( self, trusted_domain_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -632,10 +658,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/trusted_domains/{trusted_domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + account_id=account_id, + trusted_domain_id=trusted_domain_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -650,7 +682,7 @@ async def edit( self, trusted_domain_id: int, *, - account_id: str, + account_id: str | None = None, comments: str | Omit = omit, is_recent: bool | Omit = omit, is_regex: bool | Omit = omit, @@ -685,10 +717,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + account_id=account_id, + trusted_domain_id=trusted_domain_id, + ), body=await async_maybe_transform( { "comments": comments, @@ -713,7 +751,7 @@ async def get( self, trusted_domain_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -737,10 +775,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/settings/trusted_domains/{trusted_domain_id}", + path_template( + "/accounts/{account_id}/email-security/settings/trusted_domains/{trusted_domain_id}", + account_id=account_id, + trusted_domain_id=trusted_domain_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/email_security/submissions.py b/src/cloudflare/resources/email_security/submissions.py index 685b8ee74de..11919010317 100644 --- a/src/cloudflare/resources/email_security/submissions.py +++ b/src/cloudflare/resources/email_security/submissions.py @@ -9,7 +9,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> SubmissionsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, customer_status: Literal["escalated", "reviewed", "unreviewed"] | Omit = omit, end: Union[str, datetime] | Omit = omit, original_disposition: Literal["MALICIOUS", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "NONE"] | Omit = omit, @@ -92,10 +92,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/submissions", + path_template("/accounts/{account_id}/email-security/submissions", account_id=account_id), page=SyncV4PagePaginationArray[SubmissionListResponse], options=make_request_options( extra_headers=extra_headers, @@ -147,7 +149,7 @@ def with_streaming_response(self) -> AsyncSubmissionsResourceWithStreamingRespon def list( self, *, - account_id: str, + account_id: str | None = None, customer_status: Literal["escalated", "reviewed", "unreviewed"] | Omit = omit, end: Union[str, datetime] | Omit = omit, original_disposition: Literal["MALICIOUS", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "NONE"] | Omit = omit, @@ -190,10 +192,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email-security/submissions", + path_template("/accounts/{account_id}/email-security/submissions", account_id=account_id), page=AsyncV4PagePaginationArray[SubmissionListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/email_sending/api.md b/src/cloudflare/resources/email_sending/api.md new file mode 100644 index 00000000000..6191587ecd7 --- /dev/null +++ b/src/cloudflare/resources/email_sending/api.md @@ -0,0 +1,38 @@ +# EmailSending + +Types: + +```python +from cloudflare.types.email_sending import EmailSendingSendResponse, EmailSendingSendRawResponse +``` + +Methods: + +- client.email_sending.send(\*, account_id, \*\*params) -> EmailSendingSendResponse +- client.email_sending.send_raw(\*, account_id, \*\*params) -> EmailSendingSendRawResponse + +## Subdomains + +Types: + +```python +from cloudflare.types.email_sending import ( + SubdomainCreateResponse, + SubdomainListResponse, + SubdomainDeleteResponse, + SubdomainGetResponse, +) +``` + +Methods: + +- client.email_sending.subdomains.create(\*, zone_id, \*\*params) -> Optional[SubdomainCreateResponse] +- client.email_sending.subdomains.list(\*, zone_id) -> SyncSinglePage[SubdomainListResponse] +- client.email_sending.subdomains.delete(subdomain_id, \*, zone_id) -> SubdomainDeleteResponse +- client.email_sending.subdomains.get(subdomain_id, \*, zone_id) -> Optional[SubdomainGetResponse] + +### DNS + +Methods: + +- client.email_sending.subdomains.dns.get(subdomain_id, \*, zone_id) -> SyncSinglePage[DNSRecord] diff --git a/src/cloudflare/resources/email_sending/email_sending.py b/src/cloudflare/resources/email_sending/email_sending.py index 3ad31db53bd..7b3ad4b6657 100644 --- a/src/cloudflare/resources/email_sending/email_sending.py +++ b/src/cloudflare/resources/email_sending/email_sending.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -60,7 +60,7 @@ def with_streaming_response(self) -> EmailSendingResourceWithStreamingResponse: def send( self, *, - account_id: str, + account_id: str | None = None, from_: email_sending_send_params.From, subject: str, to: Union[str, SequenceNotStr[str]], @@ -112,10 +112,12 @@ def send( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email/sending/send", + path_template("/accounts/{account_id}/email/sending/send", account_id=account_id), body=maybe_transform( { "from_": from_, @@ -144,7 +146,7 @@ def send( def send_raw( self, *, - account_id: str, + account_id: str | None = None, from_: str, mime_message: str, recipients: SequenceNotStr[str], @@ -178,10 +180,12 @@ def send_raw( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email/sending/send_raw", + path_template("/accounts/{account_id}/email/sending/send_raw", account_id=account_id), body=maybe_transform( { "from_": from_, @@ -228,7 +232,7 @@ def with_streaming_response(self) -> AsyncEmailSendingResourceWithStreamingRespo async def send( self, *, - account_id: str, + account_id: str | None = None, from_: email_sending_send_params.From, subject: str, to: Union[str, SequenceNotStr[str]], @@ -280,10 +284,12 @@ async def send( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email/sending/send", + path_template("/accounts/{account_id}/email/sending/send", account_id=account_id), body=await async_maybe_transform( { "from_": from_, @@ -312,7 +318,7 @@ async def send( async def send_raw( self, *, - account_id: str, + account_id: str | None = None, from_: str, mime_message: str, recipients: SequenceNotStr[str], @@ -346,10 +352,12 @@ async def send_raw( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/email/sending/send_raw", + path_template("/accounts/{account_id}/email/sending/send_raw", account_id=account_id), body=await async_maybe_transform( { "from_": from_, diff --git a/src/cloudflare/resources/email_sending/subdomains/dns.py b/src/cloudflare/resources/email_sending/subdomains/dns.py index 9e7ecfd5e43..41e26a5d9ac 100644 --- a/src/cloudflare/resources/email_sending/subdomains/dns.py +++ b/src/cloudflare/resources/email_sending/subdomains/dns.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,7 +45,7 @@ def get( self, subdomain_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,12 +69,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not subdomain_id: raise ValueError(f"Expected a non-empty value for `subdomain_id` but received {subdomain_id!r}") return self._get_api_list( - f"/zones/{zone_id}/email/sending/subdomains/{subdomain_id}/dns", + path_template( + "/zones/{zone_id}/email/sending/subdomains/{subdomain_id}/dns", + zone_id=zone_id, + subdomain_id=subdomain_id, + ), page=SyncSinglePage[DNSRecord], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -106,7 +113,7 @@ def get( self, subdomain_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -130,12 +137,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not subdomain_id: raise ValueError(f"Expected a non-empty value for `subdomain_id` but received {subdomain_id!r}") return self._get_api_list( - f"/zones/{zone_id}/email/sending/subdomains/{subdomain_id}/dns", + path_template( + "/zones/{zone_id}/email/sending/subdomains/{subdomain_id}/dns", + zone_id=zone_id, + subdomain_id=subdomain_id, + ), page=AsyncSinglePage[DNSRecord], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/email_sending/subdomains/subdomains.py b/src/cloudflare/resources/email_sending/subdomains/subdomains.py index 083a4fe4267..3b28495a235 100644 --- a/src/cloudflare/resources/email_sending/subdomains/subdomains.py +++ b/src/cloudflare/resources/email_sending/subdomains/subdomains.py @@ -15,7 +15,7 @@ AsyncDNSResourceWithStreamingResponse, ) from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -63,7 +63,7 @@ def with_streaming_response(self) -> SubdomainsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -90,10 +90,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/sending/subdomains", + path_template("/zones/{zone_id}/email/sending/subdomains", zone_id=zone_id), body=maybe_transform({"name": name}, subdomain_create_params.SubdomainCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -108,7 +110,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -130,10 +132,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/sending/subdomains", + path_template("/zones/{zone_id}/email/sending/subdomains", zone_id=zone_id), page=SyncSinglePage[SubdomainListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -145,7 +149,7 @@ def delete( self, subdomain_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -171,12 +175,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not subdomain_id: raise ValueError(f"Expected a non-empty value for `subdomain_id` but received {subdomain_id!r}") return self._delete( - f"/zones/{zone_id}/email/sending/subdomains/{subdomain_id}", + path_template( + "/zones/{zone_id}/email/sending/subdomains/{subdomain_id}", zone_id=zone_id, subdomain_id=subdomain_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -187,7 +195,7 @@ def get( self, subdomain_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -211,12 +219,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not subdomain_id: raise ValueError(f"Expected a non-empty value for `subdomain_id` but received {subdomain_id!r}") return self._get( - f"/zones/{zone_id}/email/sending/subdomains/{subdomain_id}", + path_template( + "/zones/{zone_id}/email/sending/subdomains/{subdomain_id}", zone_id=zone_id, subdomain_id=subdomain_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -255,7 +267,7 @@ def with_streaming_response(self) -> AsyncSubdomainsResourceWithStreamingRespons async def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -282,10 +294,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/sending/subdomains", + path_template("/zones/{zone_id}/email/sending/subdomains", zone_id=zone_id), body=await async_maybe_transform({"name": name}, subdomain_create_params.SubdomainCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -300,7 +314,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -322,10 +336,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/email/sending/subdomains", + path_template("/zones/{zone_id}/email/sending/subdomains", zone_id=zone_id), page=AsyncSinglePage[SubdomainListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -337,7 +353,7 @@ async def delete( self, subdomain_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -363,12 +379,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not subdomain_id: raise ValueError(f"Expected a non-empty value for `subdomain_id` but received {subdomain_id!r}") return await self._delete( - f"/zones/{zone_id}/email/sending/subdomains/{subdomain_id}", + path_template( + "/zones/{zone_id}/email/sending/subdomains/{subdomain_id}", zone_id=zone_id, subdomain_id=subdomain_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -379,7 +399,7 @@ async def get( self, subdomain_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -403,12 +423,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not subdomain_id: raise ValueError(f"Expected a non-empty value for `subdomain_id` but received {subdomain_id!r}") return await self._get( - f"/zones/{zone_id}/email/sending/subdomains/{subdomain_id}", + path_template( + "/zones/{zone_id}/email/sending/subdomains/{subdomain_id}", zone_id=zone_id, subdomain_id=subdomain_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/filters/__init__.py b/src/cloudflare/resources/filters/__init__.py new file mode 100644 index 00000000000..5848a002330 --- /dev/null +++ b/src/cloudflare/resources/filters/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .filters import ( + FiltersResource, + AsyncFiltersResource, + FiltersResourceWithRawResponse, + AsyncFiltersResourceWithRawResponse, + FiltersResourceWithStreamingResponse, + AsyncFiltersResourceWithStreamingResponse, +) + +__all__ = [ + "FiltersResource", + "AsyncFiltersResource", + "FiltersResourceWithRawResponse", + "AsyncFiltersResourceWithRawResponse", + "FiltersResourceWithStreamingResponse", + "AsyncFiltersResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/filters/api.md b/src/cloudflare/resources/filters/api.md new file mode 100644 index 00000000000..a3ba2433e21 --- /dev/null +++ b/src/cloudflare/resources/filters/api.md @@ -0,0 +1,17 @@ +# Filters + +Types: + +```python +from cloudflare.types.filters import FirewallFilter, FilterDeleteResponse, FilterBulkDeleteResponse +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/filters.py b/src/cloudflare/resources/filters/filters.py similarity index 90% rename from src/cloudflare/resources/filters.py rename to src/cloudflare/resources/filters/filters.py index 9ecfd9dc3ab..06deebfb11f 100644 --- a/src/cloudflare/resources/filters.py +++ b/src/cloudflare/resources/filters/filters.py @@ -7,29 +7,29 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import path_template, 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, SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from .._base_client import AsyncPaginator, make_request_options -from ..types.filters import ( +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage, SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.filters import ( filter_list_params, filter_update_params, filter_bulk_delete_params, filter_bulk_update_params, ) -from ..types.filters.firewall_filter import FirewallFilter -from ..types.filters.firewall_filter_param import FirewallFilterParam -from ..types.filters.filter_delete_response import FilterDeleteResponse -from ..types.filters.filter_bulk_delete_response import FilterBulkDeleteResponse +from ...types.filters.firewall_filter import FirewallFilter +from ...types.filters.firewall_filter_param import FirewallFilterParam +from ...types.filters.filter_delete_response import FilterDeleteResponse +from ...types.filters.filter_bulk_delete_response import FilterBulkDeleteResponse __all__ = ["FiltersResource", "AsyncFiltersResource"] @@ -60,7 +60,7 @@ def with_streaming_response(self) -> FiltersResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[FirewallFilterParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -83,10 +83,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/filters", + path_template("/zones/{zone_id}/filters", zone_id=zone_id), page=SyncSinglePage[FirewallFilter], body=maybe_transform(body, Iterable[FirewallFilterParam]), options=make_request_options( @@ -103,7 +105,7 @@ def update( self, filter_id: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, expression: str | Omit = omit, paused: bool | Omit = omit, @@ -140,12 +142,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not filter_id: raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") return self._put( - f"/zones/{zone_id}/filters/{filter_id}", + path_template("/zones/{zone_id}/filters/{filter_id}", zone_id=zone_id, filter_id=filter_id), body=maybe_transform( { "description": description, @@ -171,7 +175,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, id: str | Omit = omit, description: str | Omit = omit, expression: str | Omit = omit, @@ -216,10 +220,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/filters", + path_template("/zones/{zone_id}/filters", zone_id=zone_id), page=SyncV4PagePaginationArray[FirewallFilter], options=make_request_options( extra_headers=extra_headers, @@ -249,7 +255,7 @@ def delete( self, filter_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -273,12 +279,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not filter_id: raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") return self._delete( - f"/zones/{zone_id}/filters/{filter_id}", + path_template("/zones/{zone_id}/filters/{filter_id}", zone_id=zone_id, filter_id=filter_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -295,7 +303,7 @@ def delete( def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, id: 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. @@ -318,10 +326,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/filters", + path_template("/zones/{zone_id}/filters", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -339,7 +349,7 @@ def bulk_delete( def bulk_update( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[filter_bulk_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. @@ -362,10 +372,12 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/filters", + path_template("/zones/{zone_id}/filters", zone_id=zone_id), page=SyncSinglePage[FirewallFilter], body=maybe_transform(body, Iterable[filter_bulk_update_params.Body]), options=make_request_options( @@ -382,7 +394,7 @@ def get( self, filter_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -406,12 +418,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not filter_id: raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") return self._get( - f"/zones/{zone_id}/filters/{filter_id}", + path_template("/zones/{zone_id}/filters/{filter_id}", zone_id=zone_id, filter_id=filter_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -449,7 +463,7 @@ def with_streaming_response(self) -> AsyncFiltersResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[FirewallFilterParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -472,10 +486,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/filters", + path_template("/zones/{zone_id}/filters", zone_id=zone_id), page=AsyncSinglePage[FirewallFilter], body=maybe_transform(body, Iterable[FirewallFilterParam]), options=make_request_options( @@ -492,7 +508,7 @@ async def update( self, filter_id: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, expression: str | Omit = omit, paused: bool | Omit = omit, @@ -529,12 +545,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not filter_id: raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") return await self._put( - f"/zones/{zone_id}/filters/{filter_id}", + path_template("/zones/{zone_id}/filters/{filter_id}", zone_id=zone_id, filter_id=filter_id), body=await async_maybe_transform( { "description": description, @@ -560,7 +578,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, id: str | Omit = omit, description: str | Omit = omit, expression: str | Omit = omit, @@ -605,10 +623,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/filters", + path_template("/zones/{zone_id}/filters", zone_id=zone_id), page=AsyncV4PagePaginationArray[FirewallFilter], options=make_request_options( extra_headers=extra_headers, @@ -638,7 +658,7 @@ async def delete( self, filter_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -662,12 +682,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not filter_id: raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") return await self._delete( - f"/zones/{zone_id}/filters/{filter_id}", + path_template("/zones/{zone_id}/filters/{filter_id}", zone_id=zone_id, filter_id=filter_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -684,7 +706,7 @@ async def delete( async def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, id: 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. @@ -707,10 +729,12 @@ async def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/filters", + path_template("/zones/{zone_id}/filters", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -728,7 +752,7 @@ async def bulk_delete( def bulk_update( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[filter_bulk_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. @@ -751,10 +775,12 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/filters", + path_template("/zones/{zone_id}/filters", zone_id=zone_id), page=AsyncSinglePage[FirewallFilter], body=maybe_transform(body, Iterable[filter_bulk_update_params.Body]), options=make_request_options( @@ -771,7 +797,7 @@ async def get( self, filter_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -795,12 +821,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not filter_id: raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") return await self._get( - f"/zones/{zone_id}/filters/{filter_id}", + path_template("/zones/{zone_id}/filters/{filter_id}", zone_id=zone_id, filter_id=filter_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/firewall/access_rules.py b/src/cloudflare/resources/firewall/access_rules.py index ed893e5a5b3..177fe87b6b0 100644 --- a/src/cloudflare/resources/firewall/access_rules.py +++ b/src/cloudflare/resources/firewall/access_rules.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -55,8 +55,8 @@ def create( *, configuration: access_rule_create_params.Configuration, mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, notes: 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. @@ -92,6 +92,10 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -105,7 +109,11 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "configuration": configuration, @@ -127,8 +135,8 @@ def create( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, configuration: access_rule_list_params.Configuration | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, @@ -180,6 +188,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -193,7 +205,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncV4PagePaginationArray[AccessRuleListResponse], options=make_request_options( extra_headers=extra_headers, @@ -221,8 +237,8 @@ def delete( self, rule_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -252,6 +268,10 @@ def delete( """ if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -265,7 +285,12 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -282,8 +307,8 @@ def edit( *, configuration: access_rule_edit_params.Configuration, mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, notes: 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. @@ -320,6 +345,10 @@ def edit( """ if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -333,7 +362,12 @@ def edit( account_or_zone = "zones" account_or_zone_id = zone_id return self._patch( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "configuration": configuration, @@ -356,8 +390,8 @@ def get( self, rule_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -385,6 +419,10 @@ def get( """ if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -398,7 +436,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -435,8 +478,8 @@ async def create( *, configuration: access_rule_create_params.Configuration, mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, notes: 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. @@ -472,6 +515,10 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -485,7 +532,11 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "configuration": configuration, @@ -507,8 +558,8 @@ async def create( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, configuration: access_rule_list_params.Configuration | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, @@ -560,6 +611,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -573,7 +628,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncV4PagePaginationArray[AccessRuleListResponse], options=make_request_options( extra_headers=extra_headers, @@ -601,8 +660,8 @@ async def delete( self, rule_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -632,6 +691,10 @@ async def delete( """ if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -645,7 +708,12 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -662,8 +730,8 @@ async def edit( *, configuration: access_rule_edit_params.Configuration, mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, notes: 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. @@ -700,6 +768,10 @@ async def edit( """ if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -713,7 +785,12 @@ async def edit( account_or_zone = "zones" account_or_zone_id = zone_id return await self._patch( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "configuration": configuration, @@ -736,8 +813,8 @@ async def get( self, rule_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -765,6 +842,10 @@ async def get( """ if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -778,7 +859,12 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/firewall/api.md b/src/cloudflare/resources/firewall/api.md new file mode 100644 index 00000000000..fe26c15bb3c --- /dev/null +++ b/src/cloudflare/resources/firewall/api.md @@ -0,0 +1,164 @@ +# Firewall + +## Lockdowns + +Types: + +```python +from cloudflare.types.firewall import ( + Configuration, + Lockdown, + LockdownCIDRConfiguration, + LockdownIPConfiguration, + LockdownURL, + LockdownDeleteResponse, +) +``` + +Methods: + +- 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 DeletedFilter, FirewallRule, Product +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.firewall import ( + AccessRuleCIDRConfiguration, + AccessRuleIPConfiguration, + ASNConfiguration, + CountryConfiguration, + IPV6Configuration, + AccessRuleCreateResponse, + AccessRuleListResponse, + AccessRuleDeleteResponse, + AccessRuleEditResponse, + AccessRuleGetResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.firewall import ( + UARuleCreateResponse, + UARuleUpdateResponse, + UARuleListResponse, + UARuleDeleteResponse, + UARuleGetResponse, +) +``` + +Methods: + +- 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 + +### Overrides + +Types: + +```python +from cloudflare.types.firewall.waf import ( + Override, + OverrideURL, + RewriteAction, + WAFRule, + OverrideDeleteResponse, +) +``` + +Methods: + +- 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 PackageGetResponse +``` + +Methods: + +- client.firewall.waf.packages.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[object] +- client.firewall.waf.packages.get(package_id, \*, zone_id) -> PackageGetResponse + +#### Groups + +Types: + +```python +from cloudflare.types.firewall.waf.packages import Group, GroupEditResponse, GroupGetResponse +``` + +Methods: + +- client.firewall.waf.packages.groups.list(package_id, \*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Group] +- client.firewall.waf.packages.groups.edit(group_id, \*, zone_id, package_id, \*\*params) -> GroupEditResponse +- client.firewall.waf.packages.groups.get(group_id, \*, zone_id, package_id) -> GroupGetResponse + +#### Rules + +Types: + +```python +from cloudflare.types.firewall.waf.packages import ( + AllowedModesAnomaly, + WAFRuleGroup, + RuleListResponse, + RuleEditResponse, + RuleGetResponse, +) +``` + +Methods: + +- client.firewall.waf.packages.rules.list(package_id, \*, zone_id, \*\*params) -> SyncV4PagePaginationArray[RuleListResponse] +- client.firewall.waf.packages.rules.edit(rule_id, \*, zone_id, package_id, \*\*params) -> RuleEditResponse +- client.firewall.waf.packages.rules.get(rule_id, \*, zone_id, package_id) -> RuleGetResponse diff --git a/src/cloudflare/resources/firewall/lockdowns.py b/src/cloudflare/resources/firewall/lockdowns.py index 5204a546420..8d1a41c8d2e 100644 --- a/src/cloudflare/resources/firewall/lockdowns.py +++ b/src/cloudflare/resources/firewall/lockdowns.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> LockdownsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, configurations: ConfigurationParam, urls: SequenceNotStr[OverrideURL], description: str | Omit = omit, @@ -96,10 +96,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/lockdowns", + path_template("/zones/{zone_id}/firewall/lockdowns", zone_id=zone_id), body=maybe_transform( { "configurations": configurations, @@ -124,7 +126,7 @@ def update( self, lock_downs_id: str, *, - zone_id: str, + zone_id: str | None = None, configurations: ConfigurationParam, urls: SequenceNotStr[OverrideURL], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -158,12 +160,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not lock_downs_id: raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") return self._put( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", + path_template( + "/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", zone_id=zone_id, lock_downs_id=lock_downs_id + ), body=maybe_transform( { "configurations": configurations, @@ -184,7 +190,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, created_on: Union[str, datetime] | Omit = omit, description: str | Omit = omit, description_search: str | Omit = omit, @@ -244,10 +250,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/lockdowns", + path_template("/zones/{zone_id}/firewall/lockdowns", zone_id=zone_id), page=SyncV4PagePaginationArray[Lockdown], options=make_request_options( extra_headers=extra_headers, @@ -278,7 +286,7 @@ def delete( self, lock_downs_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -302,12 +310,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not lock_downs_id: raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") return self._delete( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", + path_template( + "/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", zone_id=zone_id, lock_downs_id=lock_downs_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -322,7 +334,7 @@ def get( self, lock_downs_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -346,12 +358,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not lock_downs_id: raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") return self._get( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", + path_template( + "/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", zone_id=zone_id, lock_downs_id=lock_downs_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -386,7 +402,7 @@ def with_streaming_response(self) -> AsyncLockdownsResourceWithStreamingResponse async def create( self, *, - zone_id: str, + zone_id: str | None = None, configurations: ConfigurationParam, urls: SequenceNotStr[OverrideURL], description: str | Omit = omit, @@ -430,10 +446,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/lockdowns", + path_template("/zones/{zone_id}/firewall/lockdowns", zone_id=zone_id), body=await async_maybe_transform( { "configurations": configurations, @@ -458,7 +476,7 @@ async def update( self, lock_downs_id: str, *, - zone_id: str, + zone_id: str | None = None, configurations: ConfigurationParam, urls: SequenceNotStr[OverrideURL], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -492,12 +510,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not lock_downs_id: raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") return await self._put( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", + path_template( + "/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", zone_id=zone_id, lock_downs_id=lock_downs_id + ), body=await async_maybe_transform( { "configurations": configurations, @@ -518,7 +540,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, created_on: Union[str, datetime] | Omit = omit, description: str | Omit = omit, description_search: str | Omit = omit, @@ -578,10 +600,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/lockdowns", + path_template("/zones/{zone_id}/firewall/lockdowns", zone_id=zone_id), page=AsyncV4PagePaginationArray[Lockdown], options=make_request_options( extra_headers=extra_headers, @@ -612,7 +636,7 @@ async def delete( self, lock_downs_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -636,12 +660,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not lock_downs_id: raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") return await self._delete( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", + path_template( + "/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", zone_id=zone_id, lock_downs_id=lock_downs_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -656,7 +684,7 @@ async def get( self, lock_downs_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -680,12 +708,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not lock_downs_id: raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") return await self._get( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", + path_template( + "/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", zone_id=zone_id, lock_downs_id=lock_downs_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/firewall/rules.py b/src/cloudflare/resources/firewall/rules.py index cfa893c5cc1..16d00154c10 100644 --- a/src/cloudflare/resources/firewall/rules.py +++ b/src/cloudflare/resources/firewall/rules.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -59,7 +59,7 @@ def with_streaming_response(self) -> RulesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, action: rule_create_params.Action, filter: FirewallFilterParam, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -86,10 +86,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=SyncSinglePage[FirewallRule], body=maybe_transform( { @@ -112,7 +114,7 @@ def update( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, action: rule_update_params.Action, filter: FirewallFilterParam, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -141,12 +143,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._put( - f"/zones/{zone_id}/firewall/rules/{rule_id}", + path_template("/zones/{zone_id}/firewall/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), body=maybe_transform( { "action": action, @@ -170,7 +174,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, id: str | Omit = omit, action: str | Omit = omit, description: str | Omit = omit, @@ -212,10 +216,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=SyncV4PagePaginationArray[FirewallRule], options=make_request_options( extra_headers=extra_headers, @@ -244,7 +250,7 @@ def delete( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -268,12 +274,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._delete( - f"/zones/{zone_id}/firewall/rules/{rule_id}", + path_template("/zones/{zone_id}/firewall/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -290,7 +298,7 @@ def delete( def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -312,10 +320,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=SyncSinglePage[FirewallRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -330,7 +340,7 @@ def bulk_delete( def bulk_edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -353,10 +363,12 @@ def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=SyncSinglePage[FirewallRule], body=maybe_transform(body, rule_bulk_edit_params.RuleBulkEditParams), options=make_request_options( @@ -372,7 +384,7 @@ def bulk_edit( def bulk_update( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -395,10 +407,12 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=SyncSinglePage[FirewallRule], body=maybe_transform(body, rule_bulk_update_params.RuleBulkUpdateParams), options=make_request_options( @@ -415,7 +429,7 @@ def edit( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -439,12 +453,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get_api_list( - f"/zones/{zone_id}/firewall/rules/{rule_id}", + path_template("/zones/{zone_id}/firewall/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), page=SyncSinglePage[FirewallRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -460,7 +476,7 @@ def get( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -484,12 +500,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get( - f"/zones/{zone_id}/firewall/rules/{rule_id}", + path_template("/zones/{zone_id}/firewall/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -527,7 +545,7 @@ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, action: rule_create_params.Action, filter: FirewallFilterParam, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -554,10 +572,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=AsyncSinglePage[FirewallRule], body=maybe_transform( { @@ -580,7 +600,7 @@ async def update( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, action: rule_update_params.Action, filter: FirewallFilterParam, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -609,12 +629,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._put( - f"/zones/{zone_id}/firewall/rules/{rule_id}", + path_template("/zones/{zone_id}/firewall/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), body=await async_maybe_transform( { "action": action, @@ -638,7 +660,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, id: str | Omit = omit, action: str | Omit = omit, description: str | Omit = omit, @@ -680,10 +702,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=AsyncV4PagePaginationArray[FirewallRule], options=make_request_options( extra_headers=extra_headers, @@ -712,7 +736,7 @@ async def delete( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -736,12 +760,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._delete( - f"/zones/{zone_id}/firewall/rules/{rule_id}", + path_template("/zones/{zone_id}/firewall/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -758,7 +784,7 @@ async def delete( def bulk_delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -780,10 +806,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=AsyncSinglePage[FirewallRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -798,7 +826,7 @@ def bulk_delete( def bulk_edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -821,10 +849,12 @@ def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=AsyncSinglePage[FirewallRule], body=maybe_transform(body, rule_bulk_edit_params.RuleBulkEditParams), options=make_request_options( @@ -840,7 +870,7 @@ def bulk_edit( def bulk_update( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -863,10 +893,12 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/rules", + path_template("/zones/{zone_id}/firewall/rules", zone_id=zone_id), page=AsyncSinglePage[FirewallRule], body=maybe_transform(body, rule_bulk_update_params.RuleBulkUpdateParams), options=make_request_options( @@ -883,7 +915,7 @@ def edit( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -907,12 +939,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get_api_list( - f"/zones/{zone_id}/firewall/rules/{rule_id}", + path_template("/zones/{zone_id}/firewall/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), page=AsyncSinglePage[FirewallRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -928,7 +962,7 @@ async def get( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -952,12 +986,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._get( - f"/zones/{zone_id}/firewall/rules/{rule_id}", + path_template("/zones/{zone_id}/firewall/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/firewall/ua_rules.py b/src/cloudflare/resources/firewall/ua_rules.py index d9e987a57c2..50b272c9076 100644 --- a/src/cloudflare/resources/firewall/ua_rules.py +++ b/src/cloudflare/resources/firewall/ua_rules.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> UARulesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, configuration: ua_rule_create_params.Configuration, mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], description: str | Omit = omit, @@ -86,10 +86,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/ua_rules", + path_template("/zones/{zone_id}/firewall/ua_rules", zone_id=zone_id), body=maybe_transform( { "configuration": configuration, @@ -113,7 +115,7 @@ def update( self, ua_rule_id: str, *, - zone_id: str, + zone_id: str | None = None, configuration: ua_rule_update_params.Configuration, mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], description: str | Omit = omit, @@ -150,12 +152,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not ua_rule_id: raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") return self._put( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", + path_template("/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", zone_id=zone_id, ua_rule_id=ua_rule_id), body=maybe_transform( { "configuration": configuration, @@ -178,7 +182,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, page: float | Omit = omit, paused: bool | Omit = omit, @@ -218,10 +222,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/ua_rules", + path_template("/zones/{zone_id}/firewall/ua_rules", zone_id=zone_id), page=SyncV4PagePaginationArray[UARuleListResponse], options=make_request_options( extra_headers=extra_headers, @@ -246,7 +252,7 @@ def delete( self, ua_rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -270,12 +276,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not ua_rule_id: raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") return self._delete( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", + path_template("/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", zone_id=zone_id, ua_rule_id=ua_rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -290,7 +298,7 @@ def get( self, ua_rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -314,12 +322,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not ua_rule_id: raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") return self._get( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", + path_template("/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", zone_id=zone_id, ua_rule_id=ua_rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -354,7 +364,7 @@ def with_streaming_response(self) -> AsyncUARulesResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, configuration: ua_rule_create_params.Configuration, mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], description: str | Omit = omit, @@ -387,10 +397,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/ua_rules", + path_template("/zones/{zone_id}/firewall/ua_rules", zone_id=zone_id), body=await async_maybe_transform( { "configuration": configuration, @@ -414,7 +426,7 @@ async def update( self, ua_rule_id: str, *, - zone_id: str, + zone_id: str | None = None, configuration: ua_rule_update_params.Configuration, mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], description: str | Omit = omit, @@ -451,12 +463,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not ua_rule_id: raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") return await self._put( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", + path_template("/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", zone_id=zone_id, ua_rule_id=ua_rule_id), body=await async_maybe_transform( { "configuration": configuration, @@ -479,7 +493,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, page: float | Omit = omit, paused: bool | Omit = omit, @@ -519,10 +533,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/ua_rules", + path_template("/zones/{zone_id}/firewall/ua_rules", zone_id=zone_id), page=AsyncV4PagePaginationArray[UARuleListResponse], options=make_request_options( extra_headers=extra_headers, @@ -547,7 +563,7 @@ async def delete( self, ua_rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -571,12 +587,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not ua_rule_id: raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") return await self._delete( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", + path_template("/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", zone_id=zone_id, ua_rule_id=ua_rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -591,7 +609,7 @@ async def get( self, ua_rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -615,12 +633,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not ua_rule_id: raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") return await self._get( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", + path_template("/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", zone_id=zone_id, ua_rule_id=ua_rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/firewall/waf/overrides.py b/src/cloudflare/resources/firewall/waf/overrides.py index b6a07f1ca89..c4408e27027 100644 --- a/src/cloudflare/resources/firewall/waf/overrides.py +++ b/src/cloudflare/resources/firewall/waf/overrides.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -58,7 +58,7 @@ def with_streaming_response(self) -> OverridesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, urls: SequenceNotStr[OverrideURL], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -88,10 +88,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/waf/overrides", + path_template("/zones/{zone_id}/firewall/waf/overrides", zone_id=zone_id), body=maybe_transform({"urls": urls}, override_create_params.OverrideCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -108,7 +110,7 @@ def update( self, overrides_id: str, *, - zone_id: str, + zone_id: str | None = None, id: str, rewrite_action: RewriteActionParam, rules: WAFRuleParam, @@ -154,12 +156,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not overrides_id: raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") return self._put( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", + path_template( + "/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", zone_id=zone_id, overrides_id=overrides_id + ), body=maybe_transform( { "id": id, @@ -183,7 +189,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -214,10 +220,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/waf/overrides", + path_template("/zones/{zone_id}/firewall/waf/overrides", zone_id=zone_id), page=SyncV4PagePaginationArray[Override], options=make_request_options( extra_headers=extra_headers, @@ -240,7 +248,7 @@ def delete( self, overrides_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -267,12 +275,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not overrides_id: raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") return self._delete( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", + path_template( + "/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", zone_id=zone_id, overrides_id=overrides_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -288,7 +300,7 @@ def get( self, overrides_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -315,12 +327,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not overrides_id: raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") return self._get( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", + path_template( + "/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", zone_id=zone_id, overrides_id=overrides_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -356,7 +372,7 @@ def with_streaming_response(self) -> AsyncOverridesResourceWithStreamingResponse async def create( self, *, - zone_id: str, + zone_id: str | None = None, urls: SequenceNotStr[OverrideURL], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -386,10 +402,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/waf/overrides", + path_template("/zones/{zone_id}/firewall/waf/overrides", zone_id=zone_id), body=await async_maybe_transform({"urls": urls}, override_create_params.OverrideCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -406,7 +424,7 @@ async def update( self, overrides_id: str, *, - zone_id: str, + zone_id: str | None = None, id: str, rewrite_action: RewriteActionParam, rules: WAFRuleParam, @@ -452,12 +470,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not overrides_id: raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") return await self._put( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", + path_template( + "/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", zone_id=zone_id, overrides_id=overrides_id + ), body=await async_maybe_transform( { "id": id, @@ -481,7 +503,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -512,10 +534,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/waf/overrides", + path_template("/zones/{zone_id}/firewall/waf/overrides", zone_id=zone_id), page=AsyncV4PagePaginationArray[Override], options=make_request_options( extra_headers=extra_headers, @@ -538,7 +562,7 @@ async def delete( self, overrides_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -565,12 +589,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not overrides_id: raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") return await self._delete( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", + path_template( + "/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", zone_id=zone_id, overrides_id=overrides_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -586,7 +614,7 @@ async def get( self, overrides_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -613,12 +641,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not overrides_id: raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") return await self._get( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", + path_template( + "/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", zone_id=zone_id, overrides_id=overrides_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/firewall/waf/packages/groups.py b/src/cloudflare/resources/firewall/waf/packages/groups.py index e6c16052876..3a424a2426b 100644 --- a/src/cloudflare/resources/firewall/waf/packages/groups.py +++ b/src/cloudflare/resources/firewall/waf/packages/groups.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -54,7 +54,7 @@ def list( self, package_id: str, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, mode: Literal["on", "off"] | Omit = omit, @@ -108,12 +108,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: raise ValueError(f"Expected a non-empty value for `package_id` but received {package_id!r}") return self._get_api_list( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/groups", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/groups", zone_id=zone_id, package_id=package_id + ), page=SyncV4PagePaginationArray[Group], options=make_request_options( extra_headers=extra_headers, @@ -142,7 +146,7 @@ def edit( self, group_id: str, *, - zone_id: str, + zone_id: str | None = None, package_id: str, mode: Literal["on", "off"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -178,6 +182,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -187,7 +193,12 @@ def edit( return cast( GroupEditResponse, self._patch( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/groups/{group_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/groups/{group_id}", + zone_id=zone_id, + package_id=package_id, + group_id=group_id, + ), body=maybe_transform({"mode": mode}, group_edit_params.GroupEditParams), options=make_request_options( extra_headers=extra_headers, @@ -207,7 +218,7 @@ def get( self, group_id: str, *, - zone_id: str, + zone_id: str | None = None, package_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. @@ -237,6 +248,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -246,7 +259,12 @@ def get( return cast( GroupGetResponse, self._get( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/groups/{group_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/groups/{group_id}", + zone_id=zone_id, + package_id=package_id, + group_id=group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +304,7 @@ def list( self, package_id: str, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, mode: Literal["on", "off"] | Omit = omit, @@ -340,12 +358,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: raise ValueError(f"Expected a non-empty value for `package_id` but received {package_id!r}") return self._get_api_list( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/groups", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/groups", zone_id=zone_id, package_id=package_id + ), page=AsyncV4PagePaginationArray[Group], options=make_request_options( extra_headers=extra_headers, @@ -374,7 +396,7 @@ async def edit( self, group_id: str, *, - zone_id: str, + zone_id: str | None = None, package_id: str, mode: Literal["on", "off"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -410,6 +432,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -419,7 +443,12 @@ async def edit( return cast( GroupEditResponse, await self._patch( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/groups/{group_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/groups/{group_id}", + zone_id=zone_id, + package_id=package_id, + group_id=group_id, + ), body=await async_maybe_transform({"mode": mode}, group_edit_params.GroupEditParams), options=make_request_options( extra_headers=extra_headers, @@ -439,7 +468,7 @@ async def get( self, group_id: str, *, - zone_id: str, + zone_id: str | None = None, package_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. @@ -469,6 +498,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -478,7 +509,12 @@ async def get( return cast( GroupGetResponse, await self._get( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/groups/{group_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/groups/{group_id}", + zone_id=zone_id, + package_id=package_id, + group_id=group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/firewall/waf/packages/packages.py b/src/cloudflare/resources/firewall/waf/packages/packages.py index 97a9afe75a4..61dd9ab6991 100644 --- a/src/cloudflare/resources/firewall/waf/packages/packages.py +++ b/src/cloudflare/resources/firewall/waf/packages/packages.py @@ -25,7 +25,7 @@ AsyncGroupsResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -74,7 +74,7 @@ def with_streaming_response(self) -> PackagesResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, name: str | Omit = omit, @@ -118,10 +118,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/waf/packages", + path_template("/zones/{zone_id}/firewall/waf/packages", zone_id=zone_id), page=SyncV4PagePaginationArray[object], options=make_request_options( extra_headers=extra_headers, @@ -148,7 +150,7 @@ def get( self, package_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -175,6 +177,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -182,7 +186,9 @@ def get( return cast( PackageGetResponse, self._get( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}", zone_id=zone_id, package_id=package_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -225,7 +231,7 @@ def with_streaming_response(self) -> AsyncPackagesResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, name: str | Omit = omit, @@ -269,10 +275,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/firewall/waf/packages", + path_template("/zones/{zone_id}/firewall/waf/packages", zone_id=zone_id), page=AsyncV4PagePaginationArray[object], options=make_request_options( extra_headers=extra_headers, @@ -299,7 +307,7 @@ async def get( self, package_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -326,6 +334,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -333,7 +343,9 @@ async def get( return cast( PackageGetResponse, await self._get( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}", zone_id=zone_id, package_id=package_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/firewall/waf/packages/rules.py b/src/cloudflare/resources/firewall/waf/packages/rules.py index c59f9780c36..5faf0a3458c 100644 --- a/src/cloudflare/resources/firewall/waf/packages/rules.py +++ b/src/cloudflare/resources/firewall/waf/packages/rules.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -54,7 +54,7 @@ def list( self, package_id: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, group_id: str | Omit = omit, @@ -110,12 +110,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: raise ValueError(f"Expected a non-empty value for `package_id` but received {package_id!r}") return self._get_api_list( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/rules", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/rules", zone_id=zone_id, package_id=package_id + ), page=SyncV4PagePaginationArray[RuleListResponse], options=make_request_options( extra_headers=extra_headers, @@ -145,7 +149,7 @@ def edit( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, package_id: str, mode: Literal["default", "disable", "simulate", "block", "challenge", "on", "off"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -180,6 +184,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -189,7 +195,12 @@ def edit( return cast( RuleEditResponse, self._patch( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/rules/{rule_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/rules/{rule_id}", + zone_id=zone_id, + package_id=package_id, + rule_id=rule_id, + ), body=maybe_transform({"mode": mode}, rule_edit_params.RuleEditParams), options=make_request_options( extra_headers=extra_headers, @@ -209,7 +220,7 @@ def get( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, package_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. @@ -239,6 +250,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -248,7 +261,12 @@ def get( return cast( RuleGetResponse, self._get( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/rules/{rule_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/rules/{rule_id}", + zone_id=zone_id, + package_id=package_id, + rule_id=rule_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -288,7 +306,7 @@ def list( self, package_id: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, group_id: str | Omit = omit, @@ -344,12 +362,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: raise ValueError(f"Expected a non-empty value for `package_id` but received {package_id!r}") return self._get_api_list( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/rules", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/rules", zone_id=zone_id, package_id=package_id + ), page=AsyncV4PagePaginationArray[RuleListResponse], options=make_request_options( extra_headers=extra_headers, @@ -379,7 +401,7 @@ async def edit( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, package_id: str, mode: Literal["default", "disable", "simulate", "block", "challenge", "on", "off"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -414,6 +436,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -423,7 +447,12 @@ async def edit( return cast( RuleEditResponse, await self._patch( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/rules/{rule_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/rules/{rule_id}", + zone_id=zone_id, + package_id=package_id, + rule_id=rule_id, + ), body=await async_maybe_transform({"mode": mode}, rule_edit_params.RuleEditParams), options=make_request_options( extra_headers=extra_headers, @@ -443,7 +472,7 @@ async def get( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, package_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. @@ -473,6 +502,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not package_id: @@ -482,7 +513,12 @@ async def get( return cast( RuleGetResponse, await self._get( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}/rules/{rule_id}", + path_template( + "/zones/{zone_id}/firewall/waf/packages/{package_id}/rules/{rule_id}", + zone_id=zone_id, + package_id=package_id, + rule_id=rule_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/fraud/__init__.py b/src/cloudflare/resources/fraud/__init__.py new file mode 100644 index 00000000000..deff5249c45 --- /dev/null +++ b/src/cloudflare/resources/fraud/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .fraud import ( + FraudResource, + AsyncFraudResource, + FraudResourceWithRawResponse, + AsyncFraudResourceWithRawResponse, + FraudResourceWithStreamingResponse, + AsyncFraudResourceWithStreamingResponse, +) + +__all__ = [ + "FraudResource", + "AsyncFraudResource", + "FraudResourceWithRawResponse", + "AsyncFraudResourceWithRawResponse", + "FraudResourceWithStreamingResponse", + "AsyncFraudResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/fraud/api.md b/src/cloudflare/resources/fraud/api.md new file mode 100644 index 00000000000..0d79090da23 --- /dev/null +++ b/src/cloudflare/resources/fraud/api.md @@ -0,0 +1,12 @@ +# Fraud + +Types: + +```python +from cloudflare.types.fraud import FraudSettings +``` + +Methods: + +- client.fraud.update(\*, zone_id, \*\*params) -> Optional[FraudSettings] +- client.fraud.get(\*, zone_id) -> Optional[FraudSettings] diff --git a/src/cloudflare/resources/fraud.py b/src/cloudflare/resources/fraud/fraud.py similarity index 89% rename from src/cloudflare/resources/fraud.py rename to src/cloudflare/resources/fraud/fraud.py index 0d4c657d1c8..dc07da5a299 100644 --- a/src/cloudflare/resources/fraud.py +++ b/src/cloudflare/resources/fraud/fraud.py @@ -7,20 +7,20 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import path_template, 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 ..types.fraud import fraud_update_params -from .._base_client import make_request_options -from ..types.fraud.fraud_settings import FraudSettings +from ..._wrappers import ResultWrapper +from ...types.fraud import fraud_update_params +from ..._base_client import make_request_options +from ...types.fraud.fraud_settings import FraudSettings __all__ = ["FraudResource", "AsyncFraudResource"] @@ -48,7 +48,7 @@ def with_streaming_response(self) -> FraudResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, user_profiles: Literal["enabled", "disabled"] | Omit = omit, username_expressions: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -87,10 +87,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/fraud_detection/settings", + path_template("/zones/{zone_id}/fraud_detection/settings", zone_id=zone_id), body=maybe_transform( { "user_profiles": user_profiles, @@ -111,7 +113,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -133,10 +135,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/fraud_detection/settings", + path_template("/zones/{zone_id}/fraud_detection/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -171,7 +175,7 @@ def with_streaming_response(self) -> AsyncFraudResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, user_profiles: Literal["enabled", "disabled"] | Omit = omit, username_expressions: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -210,10 +214,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/fraud_detection/settings", + path_template("/zones/{zone_id}/fraud_detection/settings", zone_id=zone_id), body=await async_maybe_transform( { "user_profiles": user_profiles, @@ -234,7 +240,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -256,10 +262,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/fraud_detection/settings", + path_template("/zones/{zone_id}/fraud_detection/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/google_tag_gateway/api.md b/src/cloudflare/resources/google_tag_gateway/api.md new file mode 100644 index 00000000000..baf06e806ad --- /dev/null +++ b/src/cloudflare/resources/google_tag_gateway/api.md @@ -0,0 +1,14 @@ +# GoogleTagGateway + +## Config + +Types: + +```python +from cloudflare.types.google_tag_gateway import Config +``` + +Methods: + +- client.google_tag_gateway.config.update(\*, zone_id, \*\*params) -> Optional[Config] +- client.google_tag_gateway.config.get(\*, zone_id) -> Optional[Config] diff --git a/src/cloudflare/resources/google_tag_gateway/config.py b/src/cloudflare/resources/google_tag_gateway/config.py index 1417f2e9a64..e63218b6ab5 100644 --- a/src/cloudflare/resources/google_tag_gateway/config.py +++ b/src/cloudflare/resources/google_tag_gateway/config.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> ConfigResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, enabled: bool, endpoint: str, hide_original_ip: bool, @@ -87,10 +87,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/settings/google-tag-gateway/config", + path_template("/zones/{zone_id}/settings/google-tag-gateway/config", zone_id=zone_id), body=maybe_transform( { "enabled": enabled, @@ -114,7 +116,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -136,10 +138,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/settings/google-tag-gateway/config", + path_template("/zones/{zone_id}/settings/google-tag-gateway/config", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -174,7 +178,7 @@ def with_streaming_response(self) -> AsyncConfigResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, enabled: bool, endpoint: str, hide_original_ip: bool, @@ -214,10 +218,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/settings/google-tag-gateway/config", + path_template("/zones/{zone_id}/settings/google-tag-gateway/config", zone_id=zone_id), body=await async_maybe_transform( { "enabled": enabled, @@ -241,7 +247,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -263,10 +269,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/settings/google-tag-gateway/config", + path_template("/zones/{zone_id}/settings/google-tag-gateway/config", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/healthchecks/api.md b/src/cloudflare/resources/healthchecks/api.md new file mode 100644 index 00000000000..37de0e26c36 --- /dev/null +++ b/src/cloudflare/resources/healthchecks/api.md @@ -0,0 +1,37 @@ +# Healthchecks + +Types: + +```python +from cloudflare.types.healthchecks import ( + CheckRegion, + Healthcheck, + HTTPConfiguration, + QueryHealthcheck, + TCPConfiguration, + HealthcheckDeleteResponse, +) +``` + +Methods: + +- client.healthchecks.create(\*, zone_id, \*\*params) -> Healthcheck +- client.healthchecks.update(healthcheck_id, \*, zone_id, \*\*params) -> 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 + +## Previews + +Types: + +```python +from cloudflare.types.healthchecks import PreviewDeleteResponse +``` + +Methods: + +- client.healthchecks.previews.create(\*, zone_id, \*\*params) -> Healthcheck +- client.healthchecks.previews.delete(healthcheck_id, \*, zone_id) -> PreviewDeleteResponse +- client.healthchecks.previews.get(healthcheck_id, \*, zone_id) -> Healthcheck diff --git a/src/cloudflare/resources/healthchecks/healthchecks.py b/src/cloudflare/resources/healthchecks/healthchecks.py index 0b4d04b4036..33fc59a4f7e 100644 --- a/src/cloudflare/resources/healthchecks/healthchecks.py +++ b/src/cloudflare/resources/healthchecks/healthchecks.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .previews import ( PreviewsResource, AsyncPreviewsResource, @@ -69,7 +69,7 @@ def with_streaming_response(self) -> HealthchecksResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, address: str, name: str, check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -138,10 +138,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/healthchecks", + path_template("/zones/{zone_id}/healthchecks", zone_id=zone_id), body=maybe_transform( { "address": address, @@ -174,7 +176,7 @@ def update( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, address: str, name: str, check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -245,12 +247,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return self._put( - f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), body=maybe_transform( { "address": address, @@ -282,7 +288,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -310,10 +316,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/healthchecks", + path_template("/zones/{zone_id}/healthchecks", zone_id=zone_id), page=SyncV4PagePaginationArray[Healthcheck], options=make_request_options( extra_headers=extra_headers, @@ -335,7 +343,7 @@ def delete( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -359,12 +367,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return self._delete( - f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -379,7 +391,7 @@ def edit( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, address: str, name: str, check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -450,12 +462,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return self._patch( - f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), body=maybe_transform( { "address": address, @@ -488,7 +504,7 @@ def get( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -512,12 +528,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return self._get( - f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -556,7 +576,7 @@ def with_streaming_response(self) -> AsyncHealthchecksResourceWithStreamingRespo async def create( self, *, - zone_id: str, + zone_id: str | None = None, address: str, name: str, check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -625,10 +645,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/healthchecks", + path_template("/zones/{zone_id}/healthchecks", zone_id=zone_id), body=await async_maybe_transform( { "address": address, @@ -661,7 +683,7 @@ async def update( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, address: str, name: str, check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -732,12 +754,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return await self._put( - f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), body=await async_maybe_transform( { "address": address, @@ -769,7 +795,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -797,10 +823,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/healthchecks", + path_template("/zones/{zone_id}/healthchecks", zone_id=zone_id), page=AsyncV4PagePaginationArray[Healthcheck], options=make_request_options( extra_headers=extra_headers, @@ -822,7 +850,7 @@ async def delete( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -846,12 +874,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return await self._delete( - f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -866,7 +898,7 @@ async def edit( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, address: str, name: str, check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -937,12 +969,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return await self._patch( - f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), body=await async_maybe_transform( { "address": address, @@ -975,7 +1011,7 @@ async def get( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -999,12 +1035,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return await self._get( - f"/zones/{zone_id}/healthchecks/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/healthchecks/previews.py b/src/cloudflare/resources/healthchecks/previews.py index a5e5c0cb278..fd691b0446c 100644 --- a/src/cloudflare/resources/healthchecks/previews.py +++ b/src/cloudflare/resources/healthchecks/previews.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> PreviewsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, address: str, name: str, check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -120,10 +120,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/healthchecks/preview", + path_template("/zones/{zone_id}/healthchecks/preview", zone_id=zone_id), body=maybe_transform( { "address": address, @@ -156,7 +158,7 @@ def delete( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -180,12 +182,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return self._delete( - f"/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -200,7 +206,7 @@ def get( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -224,12 +230,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return self._get( - f"/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -264,7 +274,7 @@ def with_streaming_response(self) -> AsyncPreviewsResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, address: str, name: str, check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -333,10 +343,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/healthchecks/preview", + path_template("/zones/{zone_id}/healthchecks/preview", zone_id=zone_id), body=await async_maybe_transform( { "address": address, @@ -369,7 +381,7 @@ async def delete( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -393,12 +405,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return await self._delete( - f"/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -413,7 +429,7 @@ async def get( self, healthcheck_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -437,12 +453,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not healthcheck_id: raise ValueError(f"Expected a non-empty value for `healthcheck_id` but received {healthcheck_id!r}") return await self._get( - f"/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", + path_template( + "/zones/{zone_id}/healthchecks/preview/{healthcheck_id}", zone_id=zone_id, healthcheck_id=healthcheck_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/hostnames/api.md b/src/cloudflare/resources/hostnames/api.md new file mode 100644 index 00000000000..f59ae297ec7 --- /dev/null +++ b/src/cloudflare/resources/hostnames/api.md @@ -0,0 +1,22 @@ +# Hostnames + +## Settings + +### TLS + +Types: + +```python +from cloudflare.types.hostnames.settings import ( + Setting, + SettingValue, + TLSDeleteResponse, + TLSGetResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/hostnames/settings/tls.py b/src/cloudflare/resources/hostnames/settings/tls.py index 188f5c24d61..79b55ac7573 100644 --- a/src/cloudflare/resources/hostnames/settings/tls.py +++ b/src/cloudflare/resources/hostnames/settings/tls.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -53,7 +53,7 @@ def update( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, setting_id: Literal["ciphers", "min_tls_version", "http2"], value: SettingValueParam, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -98,6 +98,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: @@ -105,7 +107,12 @@ def update( if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return self._put( - f"/zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}", + path_template( + "/zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}", + zone_id=zone_id, + setting_id=setting_id, + hostname=hostname, + ), body=maybe_transform({"value": value}, tls_update_params.TLSUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -121,7 +128,7 @@ def delete( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, setting_id: Literal["ciphers", "min_tls_version", "http2"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -155,6 +162,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: @@ -162,7 +171,12 @@ def delete( if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return self._delete( - f"/zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}", + path_template( + "/zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}", + zone_id=zone_id, + setting_id=setting_id, + hostname=hostname, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -177,7 +191,7 @@ def get( self, setting_id: Literal["ciphers", "min_tls_version", "http2"], *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -208,12 +222,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: raise ValueError(f"Expected a non-empty value for `setting_id` but received {setting_id!r}") return self._get_api_list( - f"/zones/{zone_id}/hostnames/settings/{setting_id}", + path_template("/zones/{zone_id}/hostnames/settings/{setting_id}", zone_id=zone_id, setting_id=setting_id), page=SyncSinglePage[TLSGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -246,7 +262,7 @@ async def update( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, setting_id: Literal["ciphers", "min_tls_version", "http2"], value: SettingValueParam, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -291,6 +307,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: @@ -298,7 +316,12 @@ async def update( if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return await self._put( - f"/zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}", + path_template( + "/zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}", + zone_id=zone_id, + setting_id=setting_id, + hostname=hostname, + ), body=await async_maybe_transform({"value": value}, tls_update_params.TLSUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -314,7 +337,7 @@ async def delete( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, setting_id: Literal["ciphers", "min_tls_version", "http2"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -348,6 +371,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: @@ -355,7 +380,12 @@ async def delete( if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return await self._delete( - f"/zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}", + path_template( + "/zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}", + zone_id=zone_id, + setting_id=setting_id, + hostname=hostname, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -370,7 +400,7 @@ def get( self, setting_id: Literal["ciphers", "min_tls_version", "http2"], *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -401,12 +431,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: raise ValueError(f"Expected a non-empty value for `setting_id` but received {setting_id!r}") return self._get_api_list( - f"/zones/{zone_id}/hostnames/settings/{setting_id}", + path_template("/zones/{zone_id}/hostnames/settings/{setting_id}", zone_id=zone_id, setting_id=setting_id), page=AsyncSinglePage[TLSGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/hyperdrive/api.md b/src/cloudflare/resources/hyperdrive/api.md new file mode 100644 index 00000000000..ebfd5770e35 --- /dev/null +++ b/src/cloudflare/resources/hyperdrive/api.md @@ -0,0 +1,18 @@ +# 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 diff --git a/src/cloudflare/resources/hyperdrive/configs.py b/src/cloudflare/resources/hyperdrive/configs.py index 97afa16a313..84fa3a6c713 100644 --- a/src/cloudflare/resources/hyperdrive/configs.py +++ b/src/cloudflare/resources/hyperdrive/configs.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> ConfigsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, origin: config_create_params.Origin, caching: config_create_params.Caching | Omit = omit, @@ -88,10 +88,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/hyperdrive/configs", + path_template("/accounts/{account_id}/hyperdrive/configs", account_id=account_id), body=maybe_transform( { "name": name, @@ -116,7 +118,7 @@ def update( self, hyperdrive_id: str, *, - account_id: str, + account_id: str | None = None, name: str, origin: config_update_params.Origin, caching: config_update_params.Caching | Omit = omit, @@ -158,12 +160,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hyperdrive_id: raise ValueError(f"Expected a non-empty value for `hyperdrive_id` but received {hyperdrive_id!r}") return self._put( - f"/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + path_template( + "/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + account_id=account_id, + hyperdrive_id=hyperdrive_id, + ), body=maybe_transform( { "name": name, @@ -187,7 +195,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -209,10 +217,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/hyperdrive/configs", + path_template("/accounts/{account_id}/hyperdrive/configs", account_id=account_id), page=SyncSinglePage[Hyperdrive], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -224,7 +234,7 @@ def delete( self, hyperdrive_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -248,12 +258,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hyperdrive_id: raise ValueError(f"Expected a non-empty value for `hyperdrive_id` but received {hyperdrive_id!r}") return self._delete( - f"/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + path_template( + "/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + account_id=account_id, + hyperdrive_id=hyperdrive_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -268,7 +284,7 @@ def edit( self, hyperdrive_id: str, *, - account_id: str, + account_id: str | None = None, caching: config_edit_params.Caching | Omit = omit, mtls: config_edit_params.MTLS | Omit = omit, name: str | Omit = omit, @@ -316,12 +332,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hyperdrive_id: raise ValueError(f"Expected a non-empty value for `hyperdrive_id` but received {hyperdrive_id!r}") return self._patch( - f"/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + path_template( + "/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + account_id=account_id, + hyperdrive_id=hyperdrive_id, + ), body=maybe_transform( { "caching": caching, @@ -346,7 +368,7 @@ def get( self, hyperdrive_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -370,12 +392,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hyperdrive_id: raise ValueError(f"Expected a non-empty value for `hyperdrive_id` but received {hyperdrive_id!r}") return self._get( - f"/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + path_template( + "/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + account_id=account_id, + hyperdrive_id=hyperdrive_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -410,7 +438,7 @@ def with_streaming_response(self) -> AsyncConfigsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, origin: config_create_params.Origin, caching: config_create_params.Caching | Omit = omit, @@ -450,10 +478,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/hyperdrive/configs", + path_template("/accounts/{account_id}/hyperdrive/configs", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -478,7 +508,7 @@ async def update( self, hyperdrive_id: str, *, - account_id: str, + account_id: str | None = None, name: str, origin: config_update_params.Origin, caching: config_update_params.Caching | Omit = omit, @@ -520,12 +550,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hyperdrive_id: raise ValueError(f"Expected a non-empty value for `hyperdrive_id` but received {hyperdrive_id!r}") return await self._put( - f"/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + path_template( + "/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + account_id=account_id, + hyperdrive_id=hyperdrive_id, + ), body=await async_maybe_transform( { "name": name, @@ -549,7 +585,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -571,10 +607,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/hyperdrive/configs", + path_template("/accounts/{account_id}/hyperdrive/configs", account_id=account_id), page=AsyncSinglePage[Hyperdrive], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -586,7 +624,7 @@ async def delete( self, hyperdrive_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -610,12 +648,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hyperdrive_id: raise ValueError(f"Expected a non-empty value for `hyperdrive_id` but received {hyperdrive_id!r}") return await self._delete( - f"/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + path_template( + "/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + account_id=account_id, + hyperdrive_id=hyperdrive_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -630,7 +674,7 @@ async def edit( self, hyperdrive_id: str, *, - account_id: str, + account_id: str | None = None, caching: config_edit_params.Caching | Omit = omit, mtls: config_edit_params.MTLS | Omit = omit, name: str | Omit = omit, @@ -678,12 +722,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hyperdrive_id: raise ValueError(f"Expected a non-empty value for `hyperdrive_id` but received {hyperdrive_id!r}") return await self._patch( - f"/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + path_template( + "/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + account_id=account_id, + hyperdrive_id=hyperdrive_id, + ), body=await async_maybe_transform( { "caching": caching, @@ -708,7 +758,7 @@ async def get( self, hyperdrive_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -732,12 +782,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hyperdrive_id: raise ValueError(f"Expected a non-empty value for `hyperdrive_id` but received {hyperdrive_id!r}") return await self._get( - f"/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + path_template( + "/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}", + account_id=account_id, + hyperdrive_id=hyperdrive_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/iam/api.md b/src/cloudflare/resources/iam/api.md new file mode 100644 index 00000000000..94951c4357b --- /dev/null +++ b/src/cloudflare/resources/iam/api.md @@ -0,0 +1,102 @@ +# IAM + +## PermissionGroups + +Types: + +```python +from cloudflare.types.iam import PermissionGroupListResponse, PermissionGroupGetResponse +``` + +Methods: + +- client.iam.permission_groups.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[PermissionGroupListResponse] +- client.iam.permission_groups.get(permission_group_id, \*, account_id) -> Optional[PermissionGroupGetResponse] + +## ResourceGroups + +Types: + +```python +from cloudflare.types.iam import ( + ResourceGroupCreateResponse, + ResourceGroupUpdateResponse, + ResourceGroupListResponse, + ResourceGroupDeleteResponse, + ResourceGroupGetResponse, +) +``` + +Methods: + +- 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] + +## UserGroups + +Types: + +```python +from cloudflare.types.iam import ( + UserGroupCreateResponse, + UserGroupUpdateResponse, + UserGroupListResponse, + UserGroupDeleteResponse, + UserGroupGetResponse, +) +``` + +Methods: + +- 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] + +### Members + +Types: + +```python +from cloudflare.types.iam.user_groups import ( + MemberCreateResponse, + MemberUpdateResponse, + MemberListResponse, + MemberDeleteResponse, +) +``` + +Methods: + +- 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] + +## SSO + +Types: + +```python +from cloudflare.types.iam import ( + SSOCreateResponse, + SSOUpdateResponse, + SSOListResponse, + SSODeleteResponse, + SSOBeginVerificationResponse, + SSOGetResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/iam/permission_groups.py b/src/cloudflare/resources/iam/permission_groups.py index 712f5d8da74..b8beeacc942 100644 --- a/src/cloudflare/resources/iam/permission_groups.py +++ b/src/cloudflare/resources/iam/permission_groups.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> PermissionGroupsResourceWithStreamingRespon def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, label: str | Omit = omit, name: str | Omit = omit, @@ -86,10 +86,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/permission_groups", + path_template("/accounts/{account_id}/iam/permission_groups", account_id=account_id), page=SyncV4PagePaginationArray[PermissionGroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -114,7 +116,7 @@ def get( self, permission_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -138,6 +140,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not permission_group_id: @@ -145,7 +149,11 @@ def get( f"Expected a non-empty value for `permission_group_id` but received {permission_group_id!r}" ) return self._get( - f"/accounts/{account_id}/iam/permission_groups/{permission_group_id}", + path_template( + "/accounts/{account_id}/iam/permission_groups/{permission_group_id}", + account_id=account_id, + permission_group_id=permission_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -180,7 +188,7 @@ def with_streaming_response(self) -> AsyncPermissionGroupsResourceWithStreamingR def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, label: str | Omit = omit, name: str | Omit = omit, @@ -217,10 +225,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/permission_groups", + path_template("/accounts/{account_id}/iam/permission_groups", account_id=account_id), page=AsyncV4PagePaginationArray[PermissionGroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -245,7 +255,7 @@ async def get( self, permission_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -269,6 +279,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not permission_group_id: @@ -276,7 +288,11 @@ async def get( f"Expected a non-empty value for `permission_group_id` but received {permission_group_id!r}" ) return await self._get( - f"/accounts/{account_id}/iam/permission_groups/{permission_group_id}", + path_template( + "/accounts/{account_id}/iam/permission_groups/{permission_group_id}", + account_id=account_id, + permission_group_id=permission_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/iam/resource_groups.py b/src/cloudflare/resources/iam/resource_groups.py index c312bf952ec..a1b0486abc5 100644 --- a/src/cloudflare/resources/iam/resource_groups.py +++ b/src/cloudflare/resources/iam/resource_groups.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> ResourceGroupsResourceWithStreamingResponse def create( self, *, - account_id: str, + account_id: str | None = None, name: str, scope: resource_group_create_params.Scope, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -80,10 +80,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/resource_groups", + path_template("/accounts/{account_id}/iam/resource_groups", account_id=account_id), body=maybe_transform( { "name": name, @@ -105,7 +107,7 @@ def update( self, resource_group_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, scope: resource_group_update_params.Scope | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -135,12 +137,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not resource_group_id: raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") return self._put( - f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + path_template( + "/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + account_id=account_id, + resource_group_id=resource_group_id, + ), body=maybe_transform( { "name": name, @@ -161,7 +169,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | 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. @@ -189,10 +197,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/resource_groups", + path_template("/accounts/{account_id}/iam/resource_groups", account_id=account_id), page=SyncSinglePage[ResourceGroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -214,7 +224,7 @@ def delete( self, resource_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -238,12 +248,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not resource_group_id: raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") return self._delete( - f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + path_template( + "/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + account_id=account_id, + resource_group_id=resource_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -258,7 +274,7 @@ def get( self, resource_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -282,12 +298,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not resource_group_id: raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") return self._get( - f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + path_template( + "/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + account_id=account_id, + resource_group_id=resource_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -322,7 +344,7 @@ def with_streaming_response(self) -> AsyncResourceGroupsResourceWithStreamingRes async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, scope: resource_group_create_params.Scope, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -350,10 +372,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/resource_groups", + path_template("/accounts/{account_id}/iam/resource_groups", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -375,7 +399,7 @@ async def update( self, resource_group_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, scope: resource_group_update_params.Scope | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -405,12 +429,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not resource_group_id: raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") return await self._put( - f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + path_template( + "/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + account_id=account_id, + resource_group_id=resource_group_id, + ), body=await async_maybe_transform( { "name": name, @@ -431,7 +461,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | 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. @@ -459,10 +489,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/resource_groups", + path_template("/accounts/{account_id}/iam/resource_groups", account_id=account_id), page=AsyncSinglePage[ResourceGroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -484,7 +516,7 @@ async def delete( self, resource_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -508,12 +540,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not resource_group_id: raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") return await self._delete( - f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + path_template( + "/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + account_id=account_id, + resource_group_id=resource_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -528,7 +566,7 @@ async def get( self, resource_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -552,12 +590,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not resource_group_id: raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") return await self._get( - f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + path_template( + "/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + account_id=account_id, + resource_group_id=resource_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/iam/sso.py b/src/cloudflare/resources/iam/sso.py index 3903e7639b5..9f2bba9b7f2 100644 --- a/src/cloudflare/resources/iam/sso.py +++ b/src/cloudflare/resources/iam/sso.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> SSOResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, email_domain: str, begin_verification: bool | Omit = omit, use_fedramp_language: bool | Omit = omit, @@ -84,10 +84,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/sso_connectors", + path_template("/accounts/{account_id}/sso_connectors", account_id=account_id), body=maybe_transform( { "email_domain": email_domain, @@ -110,7 +112,7 @@ def update( self, sso_connector_id: str, *, - account_id: str, + account_id: str | None = None, enabled: bool | Omit = omit, use_fedramp_language: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -140,12 +142,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sso_connector_id: raise ValueError(f"Expected a non-empty value for `sso_connector_id` but received {sso_connector_id!r}") return self._patch( - f"/accounts/{account_id}/sso_connectors/{sso_connector_id}", + path_template( + "/accounts/{account_id}/sso_connectors/{sso_connector_id}", + account_id=account_id, + sso_connector_id=sso_connector_id, + ), body=maybe_transform( { "enabled": enabled, @@ -166,7 +174,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -188,10 +196,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/sso_connectors", + path_template("/accounts/{account_id}/sso_connectors", account_id=account_id), page=SyncSinglePage[SSOListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -203,7 +213,7 @@ def delete( self, sso_connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -227,12 +237,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sso_connector_id: raise ValueError(f"Expected a non-empty value for `sso_connector_id` but received {sso_connector_id!r}") return self._delete( - f"/accounts/{account_id}/sso_connectors/{sso_connector_id}", + path_template( + "/accounts/{account_id}/sso_connectors/{sso_connector_id}", + account_id=account_id, + sso_connector_id=sso_connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -247,7 +263,7 @@ def begin_verification( self, sso_connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -271,12 +287,18 @@ def begin_verification( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sso_connector_id: raise ValueError(f"Expected a non-empty value for `sso_connector_id` but received {sso_connector_id!r}") return self._post( - f"/accounts/{account_id}/sso_connectors/{sso_connector_id}/begin_verification", + path_template( + "/accounts/{account_id}/sso_connectors/{sso_connector_id}/begin_verification", + account_id=account_id, + sso_connector_id=sso_connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -287,7 +309,7 @@ def get( self, sso_connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -311,12 +333,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sso_connector_id: raise ValueError(f"Expected a non-empty value for `sso_connector_id` but received {sso_connector_id!r}") return self._get( - f"/accounts/{account_id}/sso_connectors/{sso_connector_id}", + path_template( + "/accounts/{account_id}/sso_connectors/{sso_connector_id}", + account_id=account_id, + sso_connector_id=sso_connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -351,7 +379,7 @@ def with_streaming_response(self) -> AsyncSSOResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, email_domain: str, begin_verification: bool | Omit = omit, use_fedramp_language: bool | Omit = omit, @@ -382,10 +410,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/sso_connectors", + path_template("/accounts/{account_id}/sso_connectors", account_id=account_id), body=await async_maybe_transform( { "email_domain": email_domain, @@ -408,7 +438,7 @@ async def update( self, sso_connector_id: str, *, - account_id: str, + account_id: str | None = None, enabled: bool | Omit = omit, use_fedramp_language: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -438,12 +468,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sso_connector_id: raise ValueError(f"Expected a non-empty value for `sso_connector_id` but received {sso_connector_id!r}") return await self._patch( - f"/accounts/{account_id}/sso_connectors/{sso_connector_id}", + path_template( + "/accounts/{account_id}/sso_connectors/{sso_connector_id}", + account_id=account_id, + sso_connector_id=sso_connector_id, + ), body=await async_maybe_transform( { "enabled": enabled, @@ -464,7 +500,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -486,10 +522,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/sso_connectors", + path_template("/accounts/{account_id}/sso_connectors", account_id=account_id), page=AsyncSinglePage[SSOListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -501,7 +539,7 @@ async def delete( self, sso_connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -525,12 +563,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sso_connector_id: raise ValueError(f"Expected a non-empty value for `sso_connector_id` but received {sso_connector_id!r}") return await self._delete( - f"/accounts/{account_id}/sso_connectors/{sso_connector_id}", + path_template( + "/accounts/{account_id}/sso_connectors/{sso_connector_id}", + account_id=account_id, + sso_connector_id=sso_connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -545,7 +589,7 @@ async def begin_verification( self, sso_connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -569,12 +613,18 @@ async def begin_verification( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sso_connector_id: raise ValueError(f"Expected a non-empty value for `sso_connector_id` but received {sso_connector_id!r}") return await self._post( - f"/accounts/{account_id}/sso_connectors/{sso_connector_id}/begin_verification", + path_template( + "/accounts/{account_id}/sso_connectors/{sso_connector_id}/begin_verification", + account_id=account_id, + sso_connector_id=sso_connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -585,7 +635,7 @@ async def get( self, sso_connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -609,12 +659,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sso_connector_id: raise ValueError(f"Expected a non-empty value for `sso_connector_id` but received {sso_connector_id!r}") return await self._get( - f"/accounts/{account_id}/sso_connectors/{sso_connector_id}", + path_template( + "/accounts/{account_id}/sso_connectors/{sso_connector_id}", + account_id=account_id, + sso_connector_id=sso_connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/iam/user_groups/members.py b/src/cloudflare/resources/iam/user_groups/members.py index b7241b5c2c9..1e68197614f 100644 --- a/src/cloudflare/resources/iam/user_groups/members.py +++ b/src/cloudflare/resources/iam/user_groups/members.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def create( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[member_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. @@ -77,12 +77,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return self._post( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + account_id=account_id, + user_group_id=user_group_id, + ), body=maybe_transform(body, Iterable[member_create_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -98,7 +104,7 @@ def update( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[member_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. @@ -125,12 +131,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return self._get_api_list( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + account_id=account_id, + user_group_id=user_group_id, + ), page=SyncSinglePage[MemberUpdateResponse], body=maybe_transform(body, Iterable[member_update_params.Body]), options=make_request_options( @@ -144,7 +156,7 @@ def list( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -174,12 +186,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return self._get_api_list( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + account_id=account_id, + user_group_id=user_group_id, + ), page=SyncV4PagePaginationArray[MemberListResponse], options=make_request_options( extra_headers=extra_headers, @@ -201,7 +219,7 @@ def delete( self, member_id: str, *, - account_id: str, + account_id: str | None = None, user_group_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. @@ -228,6 +246,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: @@ -235,7 +255,12 @@ def delete( if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") return self._delete( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}/members/{member_id}", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}/members/{member_id}", + account_id=account_id, + user_group_id=user_group_id, + member_id=member_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -271,7 +296,7 @@ async def create( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[member_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. @@ -296,12 +321,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return await self._post( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + account_id=account_id, + user_group_id=user_group_id, + ), body=await async_maybe_transform(body, Iterable[member_create_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -317,7 +348,7 @@ def update( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[member_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. @@ -344,12 +375,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return self._get_api_list( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + account_id=account_id, + user_group_id=user_group_id, + ), page=AsyncSinglePage[MemberUpdateResponse], body=maybe_transform(body, Iterable[member_update_params.Body]), options=make_request_options( @@ -363,7 +400,7 @@ def list( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -393,12 +430,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return self._get_api_list( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}/members", + account_id=account_id, + user_group_id=user_group_id, + ), page=AsyncV4PagePaginationArray[MemberListResponse], options=make_request_options( extra_headers=extra_headers, @@ -420,7 +463,7 @@ async def delete( self, member_id: str, *, - account_id: str, + account_id: str | None = None, user_group_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. @@ -447,6 +490,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: @@ -454,7 +499,12 @@ async def delete( if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") return await self._delete( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}/members/{member_id}", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}/members/{member_id}", + account_id=account_id, + user_group_id=user_group_id, + member_id=member_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/iam/user_groups/user_groups.py b/src/cloudflare/resources/iam/user_groups/user_groups.py index d42f7d28b55..f85b87da287 100644 --- a/src/cloudflare/resources/iam/user_groups/user_groups.py +++ b/src/cloudflare/resources/iam/user_groups/user_groups.py @@ -15,7 +15,7 @@ AsyncMembersResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -64,7 +64,7 @@ def with_streaming_response(self) -> UserGroupsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, policies: Iterable[user_group_create_params.Policy], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -92,10 +92,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/user_groups", + path_template("/accounts/{account_id}/iam/user_groups", account_id=account_id), body=maybe_transform( { "name": name, @@ -117,7 +119,7 @@ def update( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, policies: Iterable[user_group_update_params.Policy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -147,12 +149,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return self._put( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}", + account_id=account_id, + user_group_id=user_group_id, + ), body=maybe_transform( { "name": name, @@ -173,7 +181,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, direction: str | Omit = omit, fuzzy_name: str | Omit = omit, @@ -214,10 +222,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/user_groups", + path_template("/accounts/{account_id}/iam/user_groups", account_id=account_id), page=SyncV4PagePaginationArray[UserGroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -243,7 +253,7 @@ def delete( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -267,12 +277,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return self._delete( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}", + account_id=account_id, + user_group_id=user_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -287,7 +303,7 @@ def get( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -311,12 +327,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return self._get( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}", + account_id=account_id, + user_group_id=user_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -355,7 +377,7 @@ def with_streaming_response(self) -> AsyncUserGroupsResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, policies: Iterable[user_group_create_params.Policy], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -383,10 +405,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/user_groups", + path_template("/accounts/{account_id}/iam/user_groups", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -408,7 +432,7 @@ async def update( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, policies: Iterable[user_group_update_params.Policy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -438,12 +462,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return await self._put( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}", + account_id=account_id, + user_group_id=user_group_id, + ), body=await async_maybe_transform( { "name": name, @@ -464,7 +494,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, direction: str | Omit = omit, fuzzy_name: str | Omit = omit, @@ -505,10 +535,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/iam/user_groups", + path_template("/accounts/{account_id}/iam/user_groups", account_id=account_id), page=AsyncV4PagePaginationArray[UserGroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -534,7 +566,7 @@ async def delete( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -558,12 +590,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return await self._delete( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}", + account_id=account_id, + user_group_id=user_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -578,7 +616,7 @@ async def get( self, user_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -602,12 +640,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_group_id: raise ValueError(f"Expected a non-empty value for `user_group_id` but received {user_group_id!r}") return await self._get( - f"/accounts/{account_id}/iam/user_groups/{user_group_id}", + path_template( + "/accounts/{account_id}/iam/user_groups/{user_group_id}", + account_id=account_id, + user_group_id=user_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/images/api.md b/src/cloudflare/resources/images/api.md new file mode 100644 index 00000000000..991a458a8e6 --- /dev/null +++ b/src/cloudflare/resources/images/api.md @@ -0,0 +1,95 @@ +# Images + +## V1 + +Types: + +```python +from cloudflare.types.images import Image, V1ListResponse, V1DeleteResponse +``` + +Methods: + +- client.images.v1.create(\*, account_id, \*\*params) -> Image +- client.images.v1.list(\*, account_id, \*\*params) -> SyncV4PagePagination[V1ListResponse] +- client.images.v1.delete(image_id, \*, account_id) -> V1DeleteResponse +- client.images.v1.edit(image_id, \*, account_id, \*\*params) -> Image +- client.images.v1.get(image_id, \*, account_id) -> Image + +### Keys + +Types: + +```python +from cloudflare.types.images.v1 import Key, KeyUpdateResponse, KeyListResponse, KeyDeleteResponse +``` + +Methods: + +- client.images.v1.keys.update(signing_key_name, \*, account_id) -> KeyUpdateResponse +- client.images.v1.keys.list(\*, account_id) -> KeyListResponse +- client.images.v1.keys.delete(signing_key_name, \*, account_id) -> KeyDeleteResponse + +### Stats + +Types: + +```python +from cloudflare.types.images.v1 import Stat +``` + +Methods: + +- client.images.v1.stats.get(\*, account_id) -> Stat + +### Variants + +Types: + +```python +from cloudflare.types.images.v1 import ( + Variant, + VariantCreateResponse, + VariantDeleteResponse, + VariantEditResponse, + VariantGetResponse, +) +``` + +Methods: + +- client.images.v1.variants.create(\*, account_id, \*\*params) -> VariantCreateResponse +- client.images.v1.variants.list(\*, account_id) -> Variant +- client.images.v1.variants.delete(variant_id, \*, account_id) -> VariantDeleteResponse +- client.images.v1.variants.edit(variant_id, \*, account_id, \*\*params) -> VariantEditResponse +- client.images.v1.variants.get(variant_id, \*, account_id) -> VariantGetResponse + +### Blobs + +Methods: + +- client.images.v1.blobs.get(image_id, \*, account_id) -> BinaryAPIResponse + +## V2 + +Types: + +```python +from cloudflare.types.images import V2ListResponse +``` + +Methods: + +- client.images.v2.list(\*, account_id, \*\*params) -> V2ListResponse + +### DirectUploads + +Types: + +```python +from cloudflare.types.images.v2 import DirectUploadCreateResponse +``` + +Methods: + +- client.images.v2.direct_uploads.create(\*, account_id, \*\*params) -> DirectUploadCreateResponse diff --git a/src/cloudflare/resources/images/v1/blobs.py b/src/cloudflare/resources/images/v1/blobs.py index 31ce1c36469..2374aceb403 100644 --- a/src/cloudflare/resources/images/v1/blobs.py +++ b/src/cloudflare/resources/images/v1/blobs.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +47,7 @@ def get( self, image_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -72,13 +73,15 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not image_id: raise ValueError(f"Expected a non-empty value for `image_id` but received {image_id!r}") extra_headers = {"Accept": "image/*", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/images/v1/{image_id}/blob", + path_template("/accounts/{account_id}/images/v1/{image_id}/blob", account_id=account_id, image_id=image_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -110,7 +113,7 @@ async def get( self, image_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -136,13 +139,15 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not image_id: raise ValueError(f"Expected a non-empty value for `image_id` but received {image_id!r}") extra_headers = {"Accept": "image/*", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/images/v1/{image_id}/blob", + path_template("/accounts/{account_id}/images/v1/{image_id}/blob", account_id=account_id, image_id=image_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/images/v1/keys.py b/src/cloudflare/resources/images/v1/keys.py index e90c7efde18..91645597482 100644 --- a/src/cloudflare/resources/images/v1/keys.py +++ b/src/cloudflare/resources/images/v1/keys.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +49,7 @@ def update( self, signing_key_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -71,12 +72,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not signing_key_name: raise ValueError(f"Expected a non-empty value for `signing_key_name` but received {signing_key_name!r}") return self._put( - f"/accounts/{account_id}/images/v1/keys/{signing_key_name}", + path_template( + "/accounts/{account_id}/images/v1/keys/{signing_key_name}", + account_id=account_id, + signing_key_name=signing_key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -90,7 +97,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -113,10 +120,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1/keys", + path_template("/accounts/{account_id}/images/v1/keys", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -131,7 +140,7 @@ def delete( self, signing_key_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -155,12 +164,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not signing_key_name: raise ValueError(f"Expected a non-empty value for `signing_key_name` but received {signing_key_name!r}") return self._delete( - f"/accounts/{account_id}/images/v1/keys/{signing_key_name}", + path_template( + "/accounts/{account_id}/images/v1/keys/{signing_key_name}", + account_id=account_id, + signing_key_name=signing_key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -196,7 +211,7 @@ async def update( self, signing_key_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -219,12 +234,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not signing_key_name: raise ValueError(f"Expected a non-empty value for `signing_key_name` but received {signing_key_name!r}") return await self._put( - f"/accounts/{account_id}/images/v1/keys/{signing_key_name}", + path_template( + "/accounts/{account_id}/images/v1/keys/{signing_key_name}", + account_id=account_id, + signing_key_name=signing_key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -238,7 +259,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -261,10 +282,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1/keys", + path_template("/accounts/{account_id}/images/v1/keys", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -279,7 +302,7 @@ async def delete( self, signing_key_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -303,12 +326,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not signing_key_name: raise ValueError(f"Expected a non-empty value for `signing_key_name` but received {signing_key_name!r}") return await self._delete( - f"/accounts/{account_id}/images/v1/keys/{signing_key_name}", + path_template( + "/accounts/{account_id}/images/v1/keys/{signing_key_name}", + account_id=account_id, + signing_key_name=signing_key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/images/v1/stats.py b/src/cloudflare/resources/images/v1/stats.py index 48a656e33fa..2786e19d981 100644 --- a/src/cloudflare/resources/images/v1/stats.py +++ b/src/cloudflare/resources/images/v1/stats.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> StatsResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -70,10 +71,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1/stats", + path_template("/accounts/{account_id}/images/v1/stats", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -108,7 +111,7 @@ def with_streaming_response(self) -> AsyncStatsResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -133,10 +136,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1/stats", + path_template("/accounts/{account_id}/images/v1/stats", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/images/v1/v1.py b/src/cloudflare/resources/images/v1/v1.py index a1f22cb3caf..f511a70f4cd 100644 --- a/src/cloudflare/resources/images/v1/v1.py +++ b/src/cloudflare/resources/images/v1/v1.py @@ -40,7 +40,7 @@ AsyncVariantsResourceWithStreamingResponse, ) 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 ...._utils import extract_files, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -99,7 +99,7 @@ def with_streaming_response(self) -> V1ResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, creator: str | Omit = omit, file: FileTypes | Omit = omit, @@ -143,6 +143,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") body = deepcopy_minimal( @@ -161,7 +163,7 @@ def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/images/v1", + path_template("/accounts/{account_id}/images/v1", account_id=account_id), body=maybe_transform(body, v1_create_params.V1CreateParams), files=files, options=make_request_options( @@ -178,7 +180,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, creator: Optional[str] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -212,10 +214,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1", + path_template("/accounts/{account_id}/images/v1", account_id=account_id), page=SyncV4PagePagination[V1ListResponse], options=make_request_options( extra_headers=extra_headers, @@ -238,7 +242,7 @@ def delete( self, image_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -264,6 +268,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not image_id: @@ -271,7 +277,7 @@ def delete( return cast( V1DeleteResponse, self._delete( - f"/accounts/{account_id}/images/v1/{image_id}", + path_template("/accounts/{account_id}/images/v1/{image_id}", account_id=account_id, image_id=image_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -289,7 +295,7 @@ def edit( self, image_id: str, *, - account_id: str, + account_id: str | None = None, creator: str | Omit = omit, metadata: object | Omit = omit, require_signed_urls: bool | Omit = omit, @@ -327,12 +333,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not image_id: raise ValueError(f"Expected a non-empty value for `image_id` but received {image_id!r}") return self._patch( - f"/accounts/{account_id}/images/v1/{image_id}", + path_template("/accounts/{account_id}/images/v1/{image_id}", account_id=account_id, image_id=image_id), body=maybe_transform( { "creator": creator, @@ -355,7 +363,7 @@ def get( self, image_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -379,12 +387,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not image_id: raise ValueError(f"Expected a non-empty value for `image_id` but received {image_id!r}") return self._get( - f"/accounts/{account_id}/images/v1/{image_id}", + path_template("/accounts/{account_id}/images/v1/{image_id}", account_id=account_id, image_id=image_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -435,7 +445,7 @@ def with_streaming_response(self) -> AsyncV1ResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, creator: str | Omit = omit, file: FileTypes | Omit = omit, @@ -479,6 +489,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") body = deepcopy_minimal( @@ -497,7 +509,7 @@ async def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/images/v1", + path_template("/accounts/{account_id}/images/v1", account_id=account_id), body=await async_maybe_transform(body, v1_create_params.V1CreateParams), files=files, options=make_request_options( @@ -514,7 +526,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, creator: Optional[str] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -548,10 +560,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1", + path_template("/accounts/{account_id}/images/v1", account_id=account_id), page=AsyncV4PagePagination[V1ListResponse], options=make_request_options( extra_headers=extra_headers, @@ -574,7 +588,7 @@ async def delete( self, image_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -600,6 +614,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not image_id: @@ -607,7 +623,7 @@ async def delete( return cast( V1DeleteResponse, await self._delete( - f"/accounts/{account_id}/images/v1/{image_id}", + path_template("/accounts/{account_id}/images/v1/{image_id}", account_id=account_id, image_id=image_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -625,7 +641,7 @@ async def edit( self, image_id: str, *, - account_id: str, + account_id: str | None = None, creator: str | Omit = omit, metadata: object | Omit = omit, require_signed_urls: bool | Omit = omit, @@ -663,12 +679,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not image_id: raise ValueError(f"Expected a non-empty value for `image_id` but received {image_id!r}") return await self._patch( - f"/accounts/{account_id}/images/v1/{image_id}", + path_template("/accounts/{account_id}/images/v1/{image_id}", account_id=account_id, image_id=image_id), body=await async_maybe_transform( { "creator": creator, @@ -691,7 +709,7 @@ async def get( self, image_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -715,12 +733,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not image_id: raise ValueError(f"Expected a non-empty value for `image_id` but received {image_id!r}") return await self._get( - f"/accounts/{account_id}/images/v1/{image_id}", + path_template("/accounts/{account_id}/images/v1/{image_id}", account_id=account_id, image_id=image_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/images/v1/variants.py b/src/cloudflare/resources/images/v1/variants.py index b681a359f93..fa4c3f5d2f8 100644 --- a/src/cloudflare/resources/images/v1/variants.py +++ b/src/cloudflare/resources/images/v1/variants.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> VariantsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, id: str, options: variant_create_params.Options, never_require_signed_urls: bool | Omit = omit, @@ -81,10 +81,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1/variants", + path_template("/accounts/{account_id}/images/v1/variants", account_id=account_id), body=maybe_transform( { "id": id, @@ -106,7 +108,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -128,10 +130,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1/variants", + path_template("/accounts/{account_id}/images/v1/variants", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -146,7 +150,7 @@ def delete( self, variant_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -168,6 +172,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not variant_id: @@ -175,7 +181,11 @@ def delete( return cast( VariantDeleteResponse, self._delete( - f"/accounts/{account_id}/images/v1/variants/{variant_id}", + path_template( + "/accounts/{account_id}/images/v1/variants/{variant_id}", + account_id=account_id, + variant_id=variant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -193,7 +203,7 @@ def edit( self, variant_id: str, *, - account_id: str, + account_id: str | None = None, options: variant_edit_params.Options, never_require_signed_urls: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -222,12 +232,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not variant_id: raise ValueError(f"Expected a non-empty value for `variant_id` but received {variant_id!r}") return self._patch( - f"/accounts/{account_id}/images/v1/variants/{variant_id}", + path_template( + "/accounts/{account_id}/images/v1/variants/{variant_id}", account_id=account_id, variant_id=variant_id + ), body=maybe_transform( { "options": options, @@ -249,7 +263,7 @@ def get( self, variant_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -271,12 +285,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not variant_id: raise ValueError(f"Expected a non-empty value for `variant_id` but received {variant_id!r}") return self._get( - f"/accounts/{account_id}/images/v1/variants/{variant_id}", + path_template( + "/accounts/{account_id}/images/v1/variants/{variant_id}", account_id=account_id, variant_id=variant_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -311,7 +329,7 @@ def with_streaming_response(self) -> AsyncVariantsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, id: str, options: variant_create_params.Options, never_require_signed_urls: bool | Omit = omit, @@ -341,10 +359,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1/variants", + path_template("/accounts/{account_id}/images/v1/variants", account_id=account_id), body=await async_maybe_transform( { "id": id, @@ -366,7 +386,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -388,10 +408,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v1/variants", + path_template("/accounts/{account_id}/images/v1/variants", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -406,7 +428,7 @@ async def delete( self, variant_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -428,6 +450,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not variant_id: @@ -435,7 +459,11 @@ async def delete( return cast( VariantDeleteResponse, await self._delete( - f"/accounts/{account_id}/images/v1/variants/{variant_id}", + path_template( + "/accounts/{account_id}/images/v1/variants/{variant_id}", + account_id=account_id, + variant_id=variant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -453,7 +481,7 @@ async def edit( self, variant_id: str, *, - account_id: str, + account_id: str | None = None, options: variant_edit_params.Options, never_require_signed_urls: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -482,12 +510,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not variant_id: raise ValueError(f"Expected a non-empty value for `variant_id` but received {variant_id!r}") return await self._patch( - f"/accounts/{account_id}/images/v1/variants/{variant_id}", + path_template( + "/accounts/{account_id}/images/v1/variants/{variant_id}", account_id=account_id, variant_id=variant_id + ), body=await async_maybe_transform( { "options": options, @@ -509,7 +541,7 @@ async def get( self, variant_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -531,12 +563,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not variant_id: raise ValueError(f"Expected a non-empty value for `variant_id` but received {variant_id!r}") return await self._get( - f"/accounts/{account_id}/images/v1/variants/{variant_id}", + path_template( + "/accounts/{account_id}/images/v1/variants/{variant_id}", account_id=account_id, variant_id=variant_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/images/v2/direct_uploads.py b/src/cloudflare/resources/images/v2/direct_uploads.py index 0ad7b440335..e53bf8095d6 100644 --- a/src/cloudflare/resources/images/v2/direct_uploads.py +++ b/src/cloudflare/resources/images/v2/direct_uploads.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> DirectUploadsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, creator: str | Omit = omit, expiry: Union[str, datetime] | Omit = omit, @@ -96,6 +96,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 @@ -103,7 +105,7 @@ def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/images/v2/direct_upload", + path_template("/accounts/{account_id}/images/v2/direct_upload", account_id=account_id), body=maybe_transform( { "id": id, @@ -148,7 +150,7 @@ def with_streaming_response(self) -> AsyncDirectUploadsResourceWithStreamingResp async def create( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, creator: str | Omit = omit, expiry: Union[str, datetime] | Omit = omit, @@ -196,6 +198,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 @@ -203,7 +207,7 @@ async def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/images/v2/direct_upload", + path_template("/accounts/{account_id}/images/v2/direct_upload", account_id=account_id), body=await async_maybe_transform( { "id": id, diff --git a/src/cloudflare/resources/images/v2/v2.py b/src/cloudflare/resources/images/v2/v2.py index b69ff0e8420..a45ae783c9b 100644 --- a/src/cloudflare/resources/images/v2/v2.py +++ b/src/cloudflare/resources/images/v2/v2.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -60,7 +60,7 @@ def with_streaming_response(self) -> V2ResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, continuation_token: Optional[str] | Omit = omit, creator: Optional[str] | Omit = omit, meta: v2_list_params.Meta | Omit = omit, @@ -142,10 +142,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v2", + path_template("/accounts/{account_id}/images/v2", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -194,7 +196,7 @@ def with_streaming_response(self) -> AsyncV2ResourceWithStreamingResponse: async def list( self, *, - account_id: str, + account_id: str | None = None, continuation_token: Optional[str] | Omit = omit, creator: Optional[str] | Omit = omit, meta: v2_list_params.Meta | Omit = omit, @@ -276,10 +278,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/images/v2", + path_template("/accounts/{account_id}/images/v2", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/intel/api.md b/src/cloudflare/resources/intel/api.md new file mode 100644 index 00000000000..2078e8284da --- /dev/null +++ b/src/cloudflare/resources/intel/api.md @@ -0,0 +1,213 @@ +# Intel + +## ASN + +Methods: + +- client.intel.asn.get(asn, \*, account_id) -> Optional[ASN] + +### Subnets + +Types: + +```python +from cloudflare.types.intel.asn import SubnetGetResponse +``` + +Methods: + +- client.intel.asn.subnets.get(asn, \*, account_id) -> SubnetGetResponse + +## DNS + +Types: + +```python +from cloudflare.types.intel import DNS +``` + +Methods: + +- client.intel.dns.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[DNS]] + +## Domains + +Types: + +```python +from cloudflare.types.intel import Domain +``` + +Methods: + +- client.intel.domains.get(\*, account_id, \*\*params) -> Optional[Domain] + +### Bulks + +Types: + +```python +from cloudflare.types.intel.domains import BulkGetResponse +``` + +Methods: + +- client.intel.domains.bulks.get(\*, account_id, \*\*params) -> Optional[BulkGetResponse] + +## DomainHistory + +Types: + +```python +from cloudflare.types.intel import DomainHistory, DomainHistoryGetResponse +``` + +Methods: + +- client.intel.domain_history.get(\*, account_id, \*\*params) -> Optional[DomainHistoryGetResponse] + +## IPs + +Types: + +```python +from cloudflare.types.intel import IP, IPGetResponse +``` + +Methods: + +- client.intel.ips.get(\*, account_id, \*\*params) -> Optional[IPGetResponse] + +## IPLists + +Types: + +```python +from cloudflare.types.intel import IPList +``` + +## Miscategorizations + +Types: + +```python +from cloudflare.types.intel import MiscategorizationCreateResponse +``` + +Methods: + +- client.intel.miscategorizations.create(\*, account_id, \*\*params) -> MiscategorizationCreateResponse + +## Whois + +Types: + +```python +from cloudflare.types.intel import Whois, WhoisGetResponse +``` + +Methods: + +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional[WhoisGetResponse] + +## IndicatorFeeds + +Types: + +```python +from cloudflare.types.intel import ( + IndicatorFeedCreateResponse, + IndicatorFeedUpdateResponse, + IndicatorFeedListResponse, + IndicatorFeedDataResponse, + IndicatorFeedGetResponse, +) +``` + +Methods: + +- 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[IndicatorFeedGetResponse] + +### Snapshots + +Types: + +```python +from cloudflare.types.intel.indicator_feeds import SnapshotUpdateResponse +``` + +Methods: + +- client.intel.indicator_feeds.snapshots.update(feed_id, \*, account_id, \*\*params) -> Optional[SnapshotUpdateResponse] + +### Permissions + +Types: + +```python +from cloudflare.types.intel.indicator_feeds import ( + PermissionCreateResponse, + PermissionListResponse, + PermissionDeleteResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.intel import Sinkhole +``` + +Methods: + +- client.intel.sinkholes.list(\*, account_id) -> SyncSinglePage[Sinkhole] + +## AttackSurfaceReport + +### IssueTypes + +Types: + +```python +from cloudflare.types.intel.attack_surface_report import IssueTypeGetResponse +``` + +Methods: + +- client.intel.attack_surface_report.issue_types.get(\*, account_id) -> SyncSinglePage[IssueTypeGetResponse] + +### Issues + +Types: + +```python +from cloudflare.types.intel.attack_surface_report import ( + IssueType, + SeverityQueryParam, + IssueListResponse, + IssueClassResponse, + IssueDismissResponse, + IssueSeverityResponse, + IssueTypeResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/intel/asn/asn.py b/src/cloudflare/resources/intel/asn/asn.py index 7cd66848da8..65b9b13227a 100644 --- a/src/cloudflare/resources/intel/asn/asn.py +++ b/src/cloudflare/resources/intel/asn/asn.py @@ -15,6 +15,7 @@ AsyncSubnetsResourceWithStreamingResponse, ) from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -58,7 +59,7 @@ def get( self, asn: ASN, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -81,10 +82,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/asn/{asn}", + path_template("/accounts/{account_id}/intel/asn/{asn}", account_id=account_id, asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -124,7 +127,7 @@ async def get( self, asn: ASN, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -147,10 +150,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/asn/{asn}", + path_template("/accounts/{account_id}/intel/asn/{asn}", account_id=account_id, asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/intel/asn/subnets.py b/src/cloudflare/resources/intel/asn/subnets.py index e1643a47223..f80802bffcb 100644 --- a/src/cloudflare/resources/intel/asn/subnets.py +++ b/src/cloudflare/resources/intel/asn/subnets.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,7 +45,7 @@ def get( self, asn: ASN, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,10 +67,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/asn/{asn}/subnets", + path_template("/accounts/{account_id}/intel/asn/{asn}/subnets", account_id=account_id, asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -101,7 +104,7 @@ async def get( self, asn: ASN, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,10 +126,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/asn/{asn}/subnets", + path_template("/accounts/{account_id}/intel/asn/{asn}/subnets", account_id=account_id, asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/intel/attack_surface_report/issue_types.py b/src/cloudflare/resources/intel/attack_surface_report/issue_types.py index 14e633df116..2006505644a 100644 --- a/src/cloudflare/resources/intel/attack_surface_report/issue_types.py +++ b/src/cloudflare/resources/intel/attack_surface_report/issue_types.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -43,7 +44,7 @@ def with_streaming_response(self) -> IssueTypesResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,10 +67,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issue-types", + path_template("/accounts/{account_id}/intel/attack-surface-report/issue-types", account_id=account_id), page=SyncSinglePage[IssueTypeGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -101,7 +104,7 @@ def with_streaming_response(self) -> AsyncIssueTypesResourceWithStreamingRespons def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -124,10 +127,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issue-types", + path_template("/accounts/{account_id}/intel/attack-surface-report/issue-types", account_id=account_id), page=AsyncSinglePage[IssueTypeGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/intel/attack_surface_report/issues.py b/src/cloudflare/resources/intel/attack_surface_report/issues.py index 8aec9bf301a..cdf65eb1c62 100644 --- a/src/cloudflare/resources/intel/attack_surface_report/issues.py +++ b/src/cloudflare/resources/intel/attack_surface_report/issues.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -62,7 +62,7 @@ def with_streaming_response(self) -> IssuesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, dismissed: bool | Omit = omit, issue_class: SequenceNotStr[str] | Omit = omit, issue_class_neq: SequenceNotStr[str] | Omit = omit, @@ -102,10 +102,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issues", + path_template("/accounts/{account_id}/intel/attack-surface-report/issues", account_id=account_id), page=SyncV4PagePagination[Optional[IssueListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -138,7 +140,7 @@ def list( def class_( self, *, - account_id: str, + account_id: str | None = None, dismissed: bool | Omit = omit, issue_class: SequenceNotStr[str] | Omit = omit, issue_class_neq: SequenceNotStr[str] | Omit = omit, @@ -171,10 +173,12 @@ def class_( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issues/class", + path_template("/accounts/{account_id}/intel/attack-surface-report/issues/class", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -206,7 +210,7 @@ def dismiss( self, issue_id: str, *, - account_id: str, + account_id: str | None = None, dismiss: 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. @@ -231,12 +235,18 @@ def dismiss( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not issue_id: raise ValueError(f"Expected a non-empty value for `issue_id` but received {issue_id!r}") return self._put( - f"/accounts/{account_id}/intel/attack-surface-report/{issue_id}/dismiss", + path_template( + "/accounts/{account_id}/intel/attack-surface-report/{issue_id}/dismiss", + account_id=account_id, + issue_id=issue_id, + ), body=maybe_transform({"dismiss": dismiss}, issue_dismiss_params.IssueDismissParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -248,7 +258,7 @@ def dismiss( def severity( self, *, - account_id: str, + account_id: str | None = None, dismissed: bool | Omit = omit, issue_class: SequenceNotStr[str] | Omit = omit, issue_class_neq: SequenceNotStr[str] | Omit = omit, @@ -281,10 +291,12 @@ def severity( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issues/severity", + path_template("/accounts/{account_id}/intel/attack-surface-report/issues/severity", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -315,7 +327,7 @@ def severity( def type( self, *, - account_id: str, + account_id: str | None = None, dismissed: bool | Omit = omit, issue_class: SequenceNotStr[str] | Omit = omit, issue_class_neq: SequenceNotStr[str] | Omit = omit, @@ -348,10 +360,12 @@ def type( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issues/type", + path_template("/accounts/{account_id}/intel/attack-surface-report/issues/type", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -403,7 +417,7 @@ def with_streaming_response(self) -> AsyncIssuesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, dismissed: bool | Omit = omit, issue_class: SequenceNotStr[str] | Omit = omit, issue_class_neq: SequenceNotStr[str] | Omit = omit, @@ -443,10 +457,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issues", + path_template("/accounts/{account_id}/intel/attack-surface-report/issues", account_id=account_id), page=AsyncV4PagePagination[Optional[IssueListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -479,7 +495,7 @@ def list( async def class_( self, *, - account_id: str, + account_id: str | None = None, dismissed: bool | Omit = omit, issue_class: SequenceNotStr[str] | Omit = omit, issue_class_neq: SequenceNotStr[str] | Omit = omit, @@ -512,10 +528,12 @@ async def class_( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issues/class", + path_template("/accounts/{account_id}/intel/attack-surface-report/issues/class", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -547,7 +565,7 @@ async def dismiss( self, issue_id: str, *, - account_id: str, + account_id: str | None = None, dismiss: 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. @@ -572,12 +590,18 @@ async def dismiss( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not issue_id: raise ValueError(f"Expected a non-empty value for `issue_id` but received {issue_id!r}") return await self._put( - f"/accounts/{account_id}/intel/attack-surface-report/{issue_id}/dismiss", + path_template( + "/accounts/{account_id}/intel/attack-surface-report/{issue_id}/dismiss", + account_id=account_id, + issue_id=issue_id, + ), body=await async_maybe_transform({"dismiss": dismiss}, issue_dismiss_params.IssueDismissParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -589,7 +613,7 @@ async def dismiss( async def severity( self, *, - account_id: str, + account_id: str | None = None, dismissed: bool | Omit = omit, issue_class: SequenceNotStr[str] | Omit = omit, issue_class_neq: SequenceNotStr[str] | Omit = omit, @@ -622,10 +646,12 @@ async def severity( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issues/severity", + path_template("/accounts/{account_id}/intel/attack-surface-report/issues/severity", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -656,7 +682,7 @@ async def severity( async def type( self, *, - account_id: str, + account_id: str | None = None, dismissed: bool | Omit = omit, issue_class: SequenceNotStr[str] | Omit = omit, issue_class_neq: SequenceNotStr[str] | Omit = omit, @@ -689,10 +715,12 @@ async def type( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/attack-surface-report/issues/type", + path_template("/accounts/{account_id}/intel/attack-surface-report/issues/type", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/intel/dns.py b/src/cloudflare/resources/intel/dns.py index 9ce121c3c4d..cb1e01c3dd3 100644 --- a/src/cloudflare/resources/intel/dns.py +++ b/src/cloudflare/resources/intel/dns.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> DNSResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, ipv4: str | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -77,10 +77,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/dns", + path_template("/accounts/{account_id}/intel/dns", account_id=account_id), page=SyncV4PagePagination[Optional[DNS]], options=make_request_options( extra_headers=extra_headers, @@ -124,7 +126,7 @@ def with_streaming_response(self) -> AsyncDNSResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, ipv4: str | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -154,10 +156,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/dns", + path_template("/accounts/{account_id}/intel/dns", account_id=account_id), page=AsyncV4PagePagination[Optional[DNS]], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/intel/domain_history.py b/src/cloudflare/resources/intel/domain_history.py index 7822bba7881..b216b6bc018 100644 --- a/src/cloudflare/resources/intel/domain_history.py +++ b/src/cloudflare/resources/intel/domain_history.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> DomainHistoryResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, domain: 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. @@ -71,10 +71,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/domain-history", + path_template("/accounts/{account_id}/intel/domain-history", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -110,7 +112,7 @@ def with_streaming_response(self) -> AsyncDomainHistoryResourceWithStreamingResp async def get( self, *, - account_id: str, + account_id: str | None = None, domain: 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. @@ -134,10 +136,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/domain-history", + path_template("/accounts/{account_id}/intel/domain-history", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/intel/domains/bulks.py b/src/cloudflare/resources/intel/domains/bulks.py index 009c7e1ee66..e0d132c502e 100644 --- a/src/cloudflare/resources/intel/domains/bulks.py +++ b/src/cloudflare/resources/intel/domains/bulks.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> BulksResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, domain: 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. @@ -72,10 +72,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/domain/bulk", + path_template("/accounts/{account_id}/intel/domain/bulk", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -111,7 +113,7 @@ def with_streaming_response(self) -> AsyncBulksResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, domain: 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. @@ -136,10 +138,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/domain/bulk", + path_template("/accounts/{account_id}/intel/domain/bulk", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/intel/domains/domains.py b/src/cloudflare/resources/intel/domains/domains.py index 9dfd4a8aef7..6c8c4ccb3a8 100644 --- a/src/cloudflare/resources/intel/domains/domains.py +++ b/src/cloudflare/resources/intel/domains/domains.py @@ -15,7 +15,7 @@ AsyncBulksResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -59,7 +59,7 @@ def with_streaming_response(self) -> DomainsResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, domain: str | Omit = omit, skip_dns: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -85,10 +85,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/domain", + path_template("/accounts/{account_id}/intel/domain", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -134,7 +136,7 @@ def with_streaming_response(self) -> AsyncDomainsResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, domain: str | Omit = omit, skip_dns: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -160,10 +162,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/domain", + path_template("/accounts/{account_id}/intel/domain", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py b/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py index bf6f0191b47..6927db62857 100644 --- a/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py +++ b/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from .snapshots import ( SnapshotsResource, AsyncSnapshotsResource, @@ -75,7 +75,7 @@ def with_streaming_response(self) -> IndicatorFeedsResourceWithStreamingResponse def create( self, *, - account_id: str, + account_id: str | None = None, description: str | 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. @@ -103,10 +103,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds", + path_template("/accounts/{account_id}/intel/indicator-feeds", account_id=account_id), body=maybe_transform( { "description": description, @@ -128,7 +130,7 @@ def update( self, feed_id: int, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, is_attributable: bool | Omit = omit, is_downloadable: bool | Omit = omit, @@ -167,10 +169,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/{feed_id}", + path_template( + "/accounts/{account_id}/intel/indicator-feeds/{feed_id}", account_id=account_id, feed_id=feed_id + ), body=maybe_transform( { "description": description, @@ -194,7 +200,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -216,10 +222,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds", + path_template("/accounts/{account_id}/intel/indicator-feeds", account_id=account_id), page=SyncSinglePage[IndicatorFeedListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -231,7 +239,7 @@ def data( self, feed_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -255,11 +263,15 @@ def data( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {"Accept": "text/csv", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/intel/indicator-feeds/{feed_id}/data", + path_template( + "/accounts/{account_id}/intel/indicator-feeds/{feed_id}/data", account_id=account_id, feed_id=feed_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -270,7 +282,7 @@ def get( self, feed_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -294,10 +306,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/{feed_id}", + path_template( + "/accounts/{account_id}/intel/indicator-feeds/{feed_id}", account_id=account_id, feed_id=feed_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -340,7 +356,7 @@ def with_streaming_response(self) -> AsyncIndicatorFeedsResourceWithStreamingRes async def create( self, *, - account_id: str, + account_id: str | None = None, description: str | 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. @@ -368,10 +384,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds", + path_template("/accounts/{account_id}/intel/indicator-feeds", account_id=account_id), body=await async_maybe_transform( { "description": description, @@ -393,7 +411,7 @@ async def update( self, feed_id: int, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, is_attributable: bool | Omit = omit, is_downloadable: bool | Omit = omit, @@ -432,10 +450,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/{feed_id}", + path_template( + "/accounts/{account_id}/intel/indicator-feeds/{feed_id}", account_id=account_id, feed_id=feed_id + ), body=await async_maybe_transform( { "description": description, @@ -459,7 +481,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -481,10 +503,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds", + path_template("/accounts/{account_id}/intel/indicator-feeds", account_id=account_id), page=AsyncSinglePage[IndicatorFeedListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -496,7 +520,7 @@ async def data( self, feed_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -520,11 +544,15 @@ async def data( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {"Accept": "text/csv", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/intel/indicator-feeds/{feed_id}/data", + path_template( + "/accounts/{account_id}/intel/indicator-feeds/{feed_id}/data", account_id=account_id, feed_id=feed_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -535,7 +563,7 @@ async def get( self, feed_id: int, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -559,10 +587,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/{feed_id}", + path_template( + "/accounts/{account_id}/intel/indicator-feeds/{feed_id}", account_id=account_id, feed_id=feed_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/intel/indicator_feeds/permissions.py b/src/cloudflare/resources/intel/indicator_feeds/permissions.py index 678794ced06..cfade74f6f3 100644 --- a/src/cloudflare/resources/intel/indicator_feeds/permissions.py +++ b/src/cloudflare/resources/intel/indicator_feeds/permissions.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> PermissionsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, account_tag: str | Omit = omit, feed_id: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,10 +77,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/permissions/add", + path_template("/accounts/{account_id}/intel/indicator-feeds/permissions/add", account_id=account_id), body=maybe_transform( { "account_tag": account_tag, @@ -101,7 +103,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,10 +125,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/permissions/view", + path_template("/accounts/{account_id}/intel/indicator-feeds/permissions/view", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -140,7 +144,7 @@ def list( def delete( self, *, - account_id: str, + account_id: str | None = None, account_tag: str | Omit = omit, feed_id: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -168,10 +172,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/permissions/remove", + path_template("/accounts/{account_id}/intel/indicator-feeds/permissions/remove", account_id=account_id), body=maybe_transform( { "account_tag": account_tag, @@ -213,7 +219,7 @@ def with_streaming_response(self) -> AsyncPermissionsResourceWithStreamingRespon async def create( self, *, - account_id: str, + account_id: str | None = None, account_tag: str | Omit = omit, feed_id: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -241,10 +247,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/permissions/add", + path_template("/accounts/{account_id}/intel/indicator-feeds/permissions/add", account_id=account_id), body=await async_maybe_transform( { "account_tag": account_tag, @@ -265,7 +273,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -287,10 +295,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/permissions/view", + path_template("/accounts/{account_id}/intel/indicator-feeds/permissions/view", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -304,7 +314,7 @@ async def list( async def delete( self, *, - account_id: str, + account_id: str | None = None, account_tag: str | Omit = omit, feed_id: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -332,10 +342,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/indicator-feeds/permissions/remove", + path_template("/accounts/{account_id}/intel/indicator-feeds/permissions/remove", account_id=account_id), body=await async_maybe_transform( { "account_tag": account_tag, diff --git a/src/cloudflare/resources/intel/indicator_feeds/snapshots.py b/src/cloudflare/resources/intel/indicator_feeds/snapshots.py index a92b19cfd1b..fba94caedb1 100644 --- a/src/cloudflare/resources/intel/indicator_feeds/snapshots.py +++ b/src/cloudflare/resources/intel/indicator_feeds/snapshots.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def update( self, feed_id: int, *, - account_id: str, + account_id: str | None = None, source: 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. @@ -75,6 +75,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 @@ -82,7 +84,11 @@ def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._put( - f"/accounts/{account_id}/intel/indicator-feeds/{feed_id}/snapshot", + path_template( + "/accounts/{account_id}/intel/indicator-feeds/{feed_id}/snapshot", + account_id=account_id, + feed_id=feed_id, + ), body=maybe_transform({"source": source}, snapshot_update_params.SnapshotUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -119,7 +125,7 @@ async def update( self, feed_id: int, *, - account_id: str, + account_id: str | None = None, source: 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. @@ -146,6 +152,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 @@ -153,7 +161,11 @@ async def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._put( - f"/accounts/{account_id}/intel/indicator-feeds/{feed_id}/snapshot", + path_template( + "/accounts/{account_id}/intel/indicator-feeds/{feed_id}/snapshot", + account_id=account_id, + feed_id=feed_id, + ), body=await async_maybe_transform({"source": source}, snapshot_update_params.SnapshotUpdateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/intel/ips.py b/src/cloudflare/resources/intel/ips.py index 4ac92b3f687..d3319403f32 100644 --- a/src/cloudflare/resources/intel/ips.py +++ b/src/cloudflare/resources/intel/ips.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> IPsResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, ipv4: str | Omit = omit, ipv6: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -73,10 +73,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/ip", + path_template("/accounts/{account_id}/intel/ip", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -118,7 +120,7 @@ def with_streaming_response(self) -> AsyncIPsResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, ipv4: str | Omit = omit, ipv6: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -144,10 +146,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/ip", + path_template("/accounts/{account_id}/intel/ip", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/intel/miscategorizations.py b/src/cloudflare/resources/intel/miscategorizations.py index c4590330302..c9013cbc0ee 100644 --- a/src/cloudflare/resources/intel/miscategorizations.py +++ b/src/cloudflare/resources/intel/miscategorizations.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> MiscategorizationsResourceWithStreamingResp def create( self, *, - account_id: str, + account_id: str | None = None, content_adds: Iterable[int] | Omit = omit, content_removes: Iterable[int] | Omit = omit, indicator_type: Literal["domain", "ipv4", "ipv6", "url"] | Omit = omit, @@ -90,10 +90,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/miscategorization", + path_template("/accounts/{account_id}/intel/miscategorization", account_id=account_id), body=maybe_transform( { "content_adds": content_adds, @@ -136,7 +138,7 @@ def with_streaming_response(self) -> AsyncMiscategorizationsResourceWithStreamin async def create( self, *, - account_id: str, + account_id: str | None = None, content_adds: Iterable[int] | Omit = omit, content_removes: Iterable[int] | Omit = omit, indicator_type: Literal["domain", "ipv4", "ipv6", "url"] | Omit = omit, @@ -179,10 +181,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/miscategorization", + path_template("/accounts/{account_id}/intel/miscategorization", account_id=account_id), body=await async_maybe_transform( { "content_adds": content_adds, diff --git a/src/cloudflare/resources/intel/sinkholes.py b/src/cloudflare/resources/intel/sinkholes.py index e9cce87bbd0..ab62f76b77c 100644 --- a/src/cloudflare/resources/intel/sinkholes.py +++ b/src/cloudflare/resources/intel/sinkholes.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -43,7 +44,7 @@ def with_streaming_response(self) -> SinkholesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -65,10 +66,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/sinkholes", + path_template("/accounts/{account_id}/intel/sinkholes", account_id=account_id), page=SyncSinglePage[Sinkhole], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -100,7 +103,7 @@ def with_streaming_response(self) -> AsyncSinkholesResourceWithStreamingResponse def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -122,10 +125,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/sinkholes", + path_template("/accounts/{account_id}/intel/sinkholes", account_id=account_id), page=AsyncSinglePage[Sinkhole], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 14de1a086e5..2260753a973 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> WhoisResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, domain: 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. @@ -71,10 +71,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/whois", + path_template("/accounts/{account_id}/intel/whois", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -110,7 +112,7 @@ def with_streaming_response(self) -> AsyncWhoisResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, domain: 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. @@ -134,10 +136,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/intel/whois", + path_template("/accounts/{account_id}/intel/whois", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ips/__init__.py b/src/cloudflare/resources/ips/__init__.py new file mode 100644 index 00000000000..33b31f63947 --- /dev/null +++ b/src/cloudflare/resources/ips/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .ips import ( + IPsResource, + AsyncIPsResource, + IPsResourceWithRawResponse, + AsyncIPsResourceWithRawResponse, + IPsResourceWithStreamingResponse, + AsyncIPsResourceWithStreamingResponse, +) + +__all__ = [ + "IPsResource", + "AsyncIPsResource", + "IPsResourceWithRawResponse", + "AsyncIPsResourceWithRawResponse", + "IPsResourceWithStreamingResponse", + "AsyncIPsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/ips/api.md b/src/cloudflare/resources/ips/api.md new file mode 100644 index 00000000000..327823981a5 --- /dev/null +++ b/src/cloudflare/resources/ips/api.md @@ -0,0 +1,11 @@ +# IPs + +Types: + +```python +from cloudflare.types.ips import IPs, IPListResponse +``` + +Methods: + +- client.ips.list(\*\*params) -> Optional[IPListResponse] diff --git a/src/cloudflare/resources/ips.py b/src/cloudflare/resources/ips/ips.py similarity index 93% rename from src/cloudflare/resources/ips.py rename to src/cloudflare/resources/ips/ips.py index 29d43e4eaa5..e18fa26a15a 100644 --- a/src/cloudflare/resources/ips.py +++ b/src/cloudflare/resources/ips/ips.py @@ -6,20 +6,20 @@ 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 ( +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 ..types.ips import ip_list_params -from .._base_client import make_request_options -from ..types.ips.ip_list_response import IPListResponse +from ..._wrappers import ResultWrapper +from ...types.ips import ip_list_params +from ..._base_client import make_request_options +from ...types.ips.ip_list_response import IPListResponse __all__ = ["IPsResource", "AsyncIPsResource"] diff --git a/src/cloudflare/resources/keyless_certificates/__init__.py b/src/cloudflare/resources/keyless_certificates/__init__.py new file mode 100644 index 00000000000..16f1473958e --- /dev/null +++ b/src/cloudflare/resources/keyless_certificates/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .keyless_certificates import ( + KeylessCertificatesResource, + AsyncKeylessCertificatesResource, + KeylessCertificatesResourceWithRawResponse, + AsyncKeylessCertificatesResourceWithRawResponse, + KeylessCertificatesResourceWithStreamingResponse, + AsyncKeylessCertificatesResourceWithStreamingResponse, +) + +__all__ = [ + "KeylessCertificatesResource", + "AsyncKeylessCertificatesResource", + "KeylessCertificatesResourceWithRawResponse", + "AsyncKeylessCertificatesResourceWithRawResponse", + "KeylessCertificatesResourceWithStreamingResponse", + "AsyncKeylessCertificatesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/keyless_certificates/api.md b/src/cloudflare/resources/keyless_certificates/api.md new file mode 100644 index 00000000000..884fc6519f6 --- /dev/null +++ b/src/cloudflare/resources/keyless_certificates/api.md @@ -0,0 +1,19 @@ +# KeylessCertificates + +Types: + +```python +from cloudflare.types.keyless_certificates import ( + KeylessCertificate, + Tunnel, + KeylessCertificateDeleteResponse, +) +``` + +Methods: + +- 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[KeylessCertificateDeleteResponse] +- client.keyless_certificates.edit(keyless_certificate_id, \*, zone_id, \*\*params) -> Optional[KeylessCertificate] +- client.keyless_certificates.get(keyless_certificate_id, \*, zone_id) -> Optional[KeylessCertificate] diff --git a/src/cloudflare/resources/keyless_certificates.py b/src/cloudflare/resources/keyless_certificates/keyless_certificates.py similarity index 87% rename from src/cloudflare/resources/keyless_certificates.py rename to src/cloudflare/resources/keyless_certificates/keyless_certificates.py index 8b0180c31d5..242999090e8 100644 --- a/src/cloudflare/resources/keyless_certificates.py +++ b/src/cloudflare/resources/keyless_certificates/keyless_certificates.py @@ -6,25 +6,25 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, 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.custom_hostnames import BundleMethod -from ..types.keyless_certificates import keyless_certificate_edit_params, keyless_certificate_create_params -from ..types.custom_hostnames.bundle_method import BundleMethod -from ..types.keyless_certificates.tunnel_param import TunnelParam -from ..types.keyless_certificates.keyless_certificate import KeylessCertificate -from ..types.keyless_certificates.keyless_certificate_delete_response import KeylessCertificateDeleteResponse +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import AsyncPaginator, make_request_options +from ...types.custom_hostnames import BundleMethod +from ...types.keyless_certificates import keyless_certificate_edit_params, keyless_certificate_create_params +from ...types.custom_hostnames.bundle_method import BundleMethod +from ...types.keyless_certificates.tunnel_param import TunnelParam +from ...types.keyless_certificates.keyless_certificate import KeylessCertificate +from ...types.keyless_certificates.keyless_certificate_delete_response import KeylessCertificateDeleteResponse __all__ = ["KeylessCertificatesResource", "AsyncKeylessCertificatesResource"] @@ -52,7 +52,7 @@ def with_streaming_response(self) -> KeylessCertificatesResourceWithStreamingRes def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, host: str, port: float, @@ -97,10 +97,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/keyless_certificates", + path_template("/zones/{zone_id}/keyless_certificates", zone_id=zone_id), body=maybe_transform( { "certificate": certificate, @@ -125,7 +127,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -147,10 +149,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/keyless_certificates", + path_template("/zones/{zone_id}/keyless_certificates", zone_id=zone_id), page=SyncSinglePage[KeylessCertificate], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -162,7 +166,7 @@ def delete( self, keyless_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -188,6 +192,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not keyless_certificate_id: @@ -195,7 +201,11 @@ def delete( f"Expected a non-empty value for `keyless_certificate_id` but received {keyless_certificate_id!r}" ) return self._delete( - f"/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + path_template( + "/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + zone_id=zone_id, + keyless_certificate_id=keyless_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -212,7 +222,7 @@ def edit( self, keyless_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, enabled: bool | Omit = omit, host: str | Omit = omit, name: str | Omit = omit, @@ -254,6 +264,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not keyless_certificate_id: @@ -261,7 +273,11 @@ def edit( f"Expected a non-empty value for `keyless_certificate_id` but received {keyless_certificate_id!r}" ) return self._patch( - f"/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + path_template( + "/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + zone_id=zone_id, + keyless_certificate_id=keyless_certificate_id, + ), body=maybe_transform( { "enabled": enabled, @@ -286,7 +302,7 @@ def get( self, keyless_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -310,6 +326,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not keyless_certificate_id: @@ -317,7 +335,11 @@ def get( f"Expected a non-empty value for `keyless_certificate_id` but received {keyless_certificate_id!r}" ) return self._get( - f"/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + path_template( + "/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + zone_id=zone_id, + keyless_certificate_id=keyless_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -352,7 +374,7 @@ def with_streaming_response(self) -> AsyncKeylessCertificatesResourceWithStreami async def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, host: str, port: float, @@ -397,10 +419,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/keyless_certificates", + path_template("/zones/{zone_id}/keyless_certificates", zone_id=zone_id), body=await async_maybe_transform( { "certificate": certificate, @@ -425,7 +449,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -447,10 +471,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/keyless_certificates", + path_template("/zones/{zone_id}/keyless_certificates", zone_id=zone_id), page=AsyncSinglePage[KeylessCertificate], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -462,7 +488,7 @@ async def delete( self, keyless_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -488,6 +514,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not keyless_certificate_id: @@ -495,7 +523,11 @@ async def delete( f"Expected a non-empty value for `keyless_certificate_id` but received {keyless_certificate_id!r}" ) return await self._delete( - f"/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + path_template( + "/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + zone_id=zone_id, + keyless_certificate_id=keyless_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -512,7 +544,7 @@ async def edit( self, keyless_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, enabled: bool | Omit = omit, host: str | Omit = omit, name: str | Omit = omit, @@ -554,6 +586,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not keyless_certificate_id: @@ -561,7 +595,11 @@ async def edit( f"Expected a non-empty value for `keyless_certificate_id` but received {keyless_certificate_id!r}" ) return await self._patch( - f"/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + path_template( + "/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + zone_id=zone_id, + keyless_certificate_id=keyless_certificate_id, + ), body=await async_maybe_transform( { "enabled": enabled, @@ -586,7 +624,7 @@ async def get( self, keyless_certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -610,6 +648,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not keyless_certificate_id: @@ -617,7 +657,11 @@ async def get( f"Expected a non-empty value for `keyless_certificate_id` but received {keyless_certificate_id!r}" ) return await self._get( - f"/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + path_template( + "/zones/{zone_id}/keyless_certificates/{keyless_certificate_id}", + zone_id=zone_id, + keyless_certificate_id=keyless_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/kv/api.md b/src/cloudflare/resources/kv/api.md new file mode 100644 index 00000000000..f5e1093604d --- /dev/null +++ b/src/cloudflare/resources/kv/api.md @@ -0,0 +1,66 @@ +# KV + +## Namespaces + +Types: + +```python +from cloudflare.types.kv import ( + Namespace, + NamespaceDeleteResponse, + NamespaceBulkDeleteResponse, + NamespaceBulkGetResponse, + NamespaceBulkUpdateResponse, +) +``` + +Methods: + +- 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, + 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 + +Methods: + +- client.kv.namespaces.metadata.get(key_name, \*, account_id, namespace_id) -> object + +### Values + +Types: + +```python +from cloudflare.types.kv.namespaces import ValueUpdateResponse, ValueDeleteResponse +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/kv/namespaces/keys.py b/src/cloudflare/resources/kv/namespaces/keys.py index 15f21598540..f4f7d9d96ba 100644 --- a/src/cloudflare/resources/kv/namespaces/keys.py +++ b/src/cloudflare/resources/kv/namespaces/keys.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -54,7 +54,7 @@ def list( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, limit: float | Omit = omit, prefix: str | Omit = omit, @@ -92,12 +92,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return self._get_api_list( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys", + account_id=account_id, + namespace_id=namespace_id, + ), page=SyncCursorLimitPagination[Key], options=make_request_options( extra_headers=extra_headers, @@ -121,7 +127,7 @@ def bulk_delete( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -148,12 +154,18 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return self._post( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete", + account_id=account_id, + namespace_id=namespace_id, + ), body=maybe_transform(body, SequenceNotStr[str]), options=make_request_options( extra_headers=extra_headers, @@ -170,7 +182,7 @@ def bulk_get( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, keys: SequenceNotStr[str], type: Literal["text", "json"] | Omit = omit, with_metadata: bool | Omit = omit, @@ -206,6 +218,8 @@ def bulk_get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -213,7 +227,11 @@ def bulk_get( return cast( Optional[KeyBulkGetResponse], self._post( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get", + account_id=account_id, + namespace_id=namespace_id, + ), body=maybe_transform( { "keys": keys, @@ -240,7 +258,7 @@ def bulk_update( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[key_bulk_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. @@ -271,12 +289,18 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + account_id=account_id, + namespace_id=namespace_id, + ), body=maybe_transform(body, Iterable[key_bulk_update_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -313,7 +337,7 @@ def list( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, limit: float | Omit = omit, prefix: str | Omit = omit, @@ -351,12 +375,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return self._get_api_list( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys", + account_id=account_id, + namespace_id=namespace_id, + ), page=AsyncCursorLimitPagination[Key], options=make_request_options( extra_headers=extra_headers, @@ -380,7 +410,7 @@ async def bulk_delete( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -407,12 +437,18 @@ async def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return await self._post( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete", + account_id=account_id, + namespace_id=namespace_id, + ), body=await async_maybe_transform(body, SequenceNotStr[str]), options=make_request_options( extra_headers=extra_headers, @@ -429,7 +465,7 @@ async def bulk_get( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, keys: SequenceNotStr[str], type: Literal["text", "json"] | Omit = omit, with_metadata: bool | Omit = omit, @@ -465,6 +501,8 @@ async def bulk_get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -472,7 +510,11 @@ async def bulk_get( return cast( Optional[KeyBulkGetResponse], await self._post( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get", + account_id=account_id, + namespace_id=namespace_id, + ), body=await async_maybe_transform( { "keys": keys, @@ -499,7 +541,7 @@ async def bulk_update( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[key_bulk_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. @@ -530,12 +572,18 @@ async def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + account_id=account_id, + namespace_id=namespace_id, + ), body=await async_maybe_transform(body, Iterable[key_bulk_update_params.Body]), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/kv/namespaces/metadata.py b/src/cloudflare/resources/kv/namespaces/metadata.py index 9310c0f11d0..67d06c1c2f2 100644 --- a/src/cloudflare/resources/kv/namespaces/metadata.py +++ b/src/cloudflare/resources/kv/namespaces/metadata.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def get( self, key_name: str, *, - account_id: str, + account_id: str | None = None, namespace_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. @@ -76,6 +77,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -83,7 +86,12 @@ def get( if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") return self._get( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/metadata/{key_name}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/metadata/{key_name}", + account_id=account_id, + namespace_id=namespace_id, + key_name=key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -119,7 +127,7 @@ async def get( self, key_name: str, *, - account_id: str, + account_id: str | None = None, namespace_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. @@ -150,6 +158,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -157,7 +167,12 @@ async def get( if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") return await self._get( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/metadata/{key_name}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/metadata/{key_name}", + account_id=account_id, + namespace_id=namespace_id, + key_name=key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/kv/namespaces/namespaces.py b/src/cloudflare/resources/kv/namespaces/namespaces.py index 211ee6fcb6f..0b08cd9aebb 100644 --- a/src/cloudflare/resources/kv/namespaces/namespaces.py +++ b/src/cloudflare/resources/kv/namespaces/namespaces.py @@ -32,7 +32,7 @@ AsyncMetadataResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ....types.kv import ( namespace_list_params, @@ -95,7 +95,7 @@ def with_streaming_response(self) -> NamespacesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, title: 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. @@ -123,10 +123,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/storage/kv/namespaces", + path_template("/accounts/{account_id}/storage/kv/namespaces", account_id=account_id), body=maybe_transform({"title": title}, namespace_create_params.NamespaceCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -142,7 +144,7 @@ def update( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, title: 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. @@ -169,12 +171,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + account_id=account_id, + namespace_id=namespace_id, + ), body=maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -189,7 +197,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["id", "title"] | Omit = omit, page: float | Omit = omit, @@ -223,10 +231,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/storage/kv/namespaces", + path_template("/accounts/{account_id}/storage/kv/namespaces", account_id=account_id), page=SyncV4PagePaginationArray[Namespace], options=make_request_options( extra_headers=extra_headers, @@ -250,7 +260,7 @@ def delete( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -274,12 +284,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + account_id=account_id, + namespace_id=namespace_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -294,7 +310,7 @@ def bulk_delete( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -321,12 +337,18 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return self._post( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete", + account_id=account_id, + namespace_id=namespace_id, + ), body=maybe_transform(body, SequenceNotStr[str]), options=make_request_options( extra_headers=extra_headers, @@ -342,7 +364,7 @@ def bulk_get( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, keys: SequenceNotStr[str], type: Literal["text", "json"] | Omit = omit, with_metadata: bool | Omit = omit, @@ -378,6 +400,8 @@ def bulk_get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -385,7 +409,11 @@ def bulk_get( return cast( Optional[NamespaceBulkGetResponse], self._post( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get", + account_id=account_id, + namespace_id=namespace_id, + ), body=maybe_transform( { "keys": keys, @@ -411,7 +439,7 @@ def bulk_update( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[namespace_bulk_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. @@ -442,12 +470,18 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + account_id=account_id, + namespace_id=namespace_id, + ), body=maybe_transform(body, Iterable[namespace_bulk_update_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -463,7 +497,7 @@ def get( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -487,12 +521,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return self._get( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + account_id=account_id, + namespace_id=namespace_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -539,7 +579,7 @@ def with_streaming_response(self) -> AsyncNamespacesResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, title: 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. @@ -567,10 +607,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/storage/kv/namespaces", + path_template("/accounts/{account_id}/storage/kv/namespaces", account_id=account_id), body=await async_maybe_transform({"title": title}, namespace_create_params.NamespaceCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -586,7 +628,7 @@ async def update( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, title: 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. @@ -613,12 +655,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + account_id=account_id, + namespace_id=namespace_id, + ), body=await async_maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -633,7 +681,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["id", "title"] | Omit = omit, page: float | Omit = omit, @@ -667,10 +715,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/storage/kv/namespaces", + path_template("/accounts/{account_id}/storage/kv/namespaces", account_id=account_id), page=AsyncV4PagePaginationArray[Namespace], options=make_request_options( extra_headers=extra_headers, @@ -694,7 +744,7 @@ async def delete( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -718,12 +768,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return await self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + account_id=account_id, + namespace_id=namespace_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -738,7 +794,7 @@ async def bulk_delete( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -765,12 +821,18 @@ async def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return await self._post( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete", + account_id=account_id, + namespace_id=namespace_id, + ), body=await async_maybe_transform(body, SequenceNotStr[str]), options=make_request_options( extra_headers=extra_headers, @@ -786,7 +848,7 @@ async def bulk_get( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, keys: SequenceNotStr[str], type: Literal["text", "json"] | Omit = omit, with_metadata: bool | Omit = omit, @@ -822,6 +884,8 @@ async def bulk_get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -829,7 +893,11 @@ async def bulk_get( return cast( Optional[NamespaceBulkGetResponse], await self._post( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get", + account_id=account_id, + namespace_id=namespace_id, + ), body=await async_maybe_transform( { "keys": keys, @@ -855,7 +923,7 @@ async def bulk_update( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[namespace_bulk_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. @@ -886,12 +954,18 @@ async def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + account_id=account_id, + namespace_id=namespace_id, + ), body=await async_maybe_transform(body, Iterable[namespace_bulk_update_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -907,7 +981,7 @@ async def get( self, namespace_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -931,12 +1005,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") return await self._get( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + account_id=account_id, + namespace_id=namespace_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/kv/namespaces/values.py b/src/cloudflare/resources/kv/namespaces/values.py index cfabd2a52d1..fc7f52c7501 100644 --- a/src/cloudflare/resources/kv/namespaces/values.py +++ b/src/cloudflare/resources/kv/namespaces/values.py @@ -7,7 +7,7 @@ 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 ...._utils import extract_files, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -57,7 +57,7 @@ def update( self, key_name: str, *, - account_id: str, + account_id: str | None = None, namespace_id: str, value: Union[str, FileTypes], expiration: float | Omit = omit, @@ -106,6 +106,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -124,7 +126,12 @@ def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + account_id=account_id, + namespace_id=namespace_id, + key_name=key_name, + ), body=maybe_transform(body, value_update_params.ValueUpdateParams), files=files, options=make_request_options( @@ -149,7 +156,7 @@ def delete( self, key_name: str, *, - account_id: str, + account_id: str | None = None, namespace_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. @@ -179,6 +186,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -186,7 +195,12 @@ def delete( if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") return self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + account_id=account_id, + namespace_id=namespace_id, + key_name=key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -201,7 +215,7 @@ def get( self, key_name: str, *, - account_id: str, + account_id: str | None = None, namespace_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. @@ -234,6 +248,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -242,7 +258,12 @@ def get( raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + account_id=account_id, + namespace_id=namespace_id, + key_name=key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -274,7 +295,7 @@ async def update( self, key_name: str, *, - account_id: str, + account_id: str | None = None, namespace_id: str, value: Union[str, FileTypes], expiration: float | Omit = omit, @@ -323,6 +344,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -341,7 +364,12 @@ async def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + account_id=account_id, + namespace_id=namespace_id, + key_name=key_name, + ), body=await async_maybe_transform(body, value_update_params.ValueUpdateParams), files=files, options=make_request_options( @@ -366,7 +394,7 @@ async def delete( self, key_name: str, *, - account_id: str, + account_id: str | None = None, namespace_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. @@ -396,6 +424,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -403,7 +433,12 @@ async def delete( if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") return await self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + account_id=account_id, + namespace_id=namespace_id, + key_name=key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -418,7 +453,7 @@ async def get( self, key_name: str, *, - account_id: str, + account_id: str | None = None, namespace_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. @@ -451,6 +486,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: @@ -459,7 +496,12 @@ async def get( raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + path_template( + "/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + account_id=account_id, + namespace_id=namespace_id, + key_name=key_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/leaked_credential_checks/api.md b/src/cloudflare/resources/leaked_credential_checks/api.md new file mode 100644 index 00000000000..52e76586205 --- /dev/null +++ b/src/cloudflare/resources/leaked_credential_checks/api.md @@ -0,0 +1,36 @@ +# LeakedCredentialChecks + +Types: + +```python +from cloudflare.types.leaked_credential_checks import ( + LeakedCredentialCheckCreateResponse, + LeakedCredentialCheckGetResponse, +) +``` + +Methods: + +- client.leaked_credential_checks.create(\*, zone_id, \*\*params) -> LeakedCredentialCheckCreateResponse +- client.leaked_credential_checks.get(\*, zone_id) -> LeakedCredentialCheckGetResponse + +## Detections + +Types: + +```python +from cloudflare.types.leaked_credential_checks import ( + DetectionCreateResponse, + DetectionUpdateResponse, + DetectionListResponse, + DetectionGetResponse, +) +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/leaked_credential_checks/detections.py b/src/cloudflare/resources/leaked_credential_checks/detections.py index 811169a7a8c..b79cddb1ba1 100644 --- a/src/cloudflare/resources/leaked_credential_checks/detections.py +++ b/src/cloudflare/resources/leaked_credential_checks/detections.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> DetectionsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, password: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -79,10 +79,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/leaked-credential-checks/detections", + path_template("/zones/{zone_id}/leaked-credential-checks/detections", zone_id=zone_id), body=maybe_transform( { "password": password, @@ -104,7 +106,7 @@ def update( self, detection_id: str, *, - zone_id: str, + zone_id: str | None = None, password: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -134,12 +136,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not detection_id: raise ValueError(f"Expected a non-empty value for `detection_id` but received {detection_id!r}") return self._put( - f"/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + path_template( + "/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + zone_id=zone_id, + detection_id=detection_id, + ), body=maybe_transform( { "password": password, @@ -160,7 +168,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -182,10 +190,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/leaked-credential-checks/detections", + path_template("/zones/{zone_id}/leaked-credential-checks/detections", zone_id=zone_id), page=SyncSinglePage[DetectionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -197,7 +207,7 @@ def delete( self, detection_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -221,12 +231,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not detection_id: raise ValueError(f"Expected a non-empty value for `detection_id` but received {detection_id!r}") return self._delete( - f"/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + path_template( + "/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + zone_id=zone_id, + detection_id=detection_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -241,7 +257,7 @@ def get( self, detection_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -265,12 +281,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not detection_id: raise ValueError(f"Expected a non-empty value for `detection_id` but received {detection_id!r}") return self._get( - f"/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + path_template( + "/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + zone_id=zone_id, + detection_id=detection_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -305,7 +327,7 @@ def with_streaming_response(self) -> AsyncDetectionsResourceWithStreamingRespons async def create( self, *, - zone_id: str, + zone_id: str | None = None, password: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -333,10 +355,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/leaked-credential-checks/detections", + path_template("/zones/{zone_id}/leaked-credential-checks/detections", zone_id=zone_id), body=await async_maybe_transform( { "password": password, @@ -358,7 +382,7 @@ async def update( self, detection_id: str, *, - zone_id: str, + zone_id: str | None = None, password: str | Omit = omit, username: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -388,12 +412,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not detection_id: raise ValueError(f"Expected a non-empty value for `detection_id` but received {detection_id!r}") return await self._put( - f"/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + path_template( + "/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + zone_id=zone_id, + detection_id=detection_id, + ), body=await async_maybe_transform( { "password": password, @@ -414,7 +444,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -436,10 +466,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/leaked-credential-checks/detections", + path_template("/zones/{zone_id}/leaked-credential-checks/detections", zone_id=zone_id), page=AsyncSinglePage[DetectionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -451,7 +483,7 @@ async def delete( self, detection_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -475,12 +507,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not detection_id: raise ValueError(f"Expected a non-empty value for `detection_id` but received {detection_id!r}") return await self._delete( - f"/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + path_template( + "/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + zone_id=zone_id, + detection_id=detection_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -495,7 +533,7 @@ async def get( self, detection_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -519,12 +557,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not detection_id: raise ValueError(f"Expected a non-empty value for `detection_id` but received {detection_id!r}") return await self._get( - f"/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + path_template( + "/zones/{zone_id}/leaked-credential-checks/detections/{detection_id}", + zone_id=zone_id, + detection_id=detection_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/leaked_credential_checks/leaked_credential_checks.py b/src/cloudflare/resources/leaked_credential_checks/leaked_credential_checks.py index 00e8ed4590d..f2cf987967d 100644 --- a/src/cloudflare/resources/leaked_credential_checks/leaked_credential_checks.py +++ b/src/cloudflare/resources/leaked_credential_checks/leaked_credential_checks.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from .detections import ( DetectionsResource, @@ -62,7 +62,7 @@ def with_streaming_response(self) -> LeakedCredentialChecksResourceWithStreaming def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -87,10 +87,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/leaked-credential-checks", + path_template("/zones/{zone_id}/leaked-credential-checks", zone_id=zone_id), body=maybe_transform( {"enabled": enabled}, leaked_credential_check_create_params.LeakedCredentialCheckCreateParams ), @@ -107,7 +109,7 @@ def create( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -129,10 +131,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/leaked-credential-checks", + path_template("/zones/{zone_id}/leaked-credential-checks", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -171,7 +175,7 @@ def with_streaming_response(self) -> AsyncLeakedCredentialChecksResourceWithStre async def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -196,10 +200,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/leaked-credential-checks", + path_template("/zones/{zone_id}/leaked-credential-checks", zone_id=zone_id), body=await async_maybe_transform( {"enabled": enabled}, leaked_credential_check_create_params.LeakedCredentialCheckCreateParams ), @@ -216,7 +222,7 @@ async def create( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -238,10 +244,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/leaked-credential-checks", + path_template("/zones/{zone_id}/leaked-credential-checks", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/load_balancers/api.md b/src/cloudflare/resources/load_balancers/api.md new file mode 100644 index 00000000000..947746e3fe6 --- /dev/null +++ b/src/cloudflare/resources/load_balancers/api.md @@ -0,0 +1,173 @@ +# LoadBalancers + +Types: + +```python +from cloudflare.types.load_balancers import ( + AdaptiveRouting, + CheckRegion, + DefaultPools, + FilterOptions, + Header, + Host, + LoadBalancer, + LoadShedding, + LocationStrategy, + NotificationFilter, + Origin, + OriginSteering, + RandomSteering, + Rules, + SessionAffinity, + SessionAffinityAttributes, + SteeringPolicy, + LoadBalancerDeleteResponse, +) +``` + +Methods: + +- client.load_balancers.create(\*, zone_id, \*\*params) -> LoadBalancer +- client.load_balancers.update(load_balancer_id, \*, zone_id, \*\*params) -> LoadBalancer +- client.load_balancers.list(\*, zone_id) -> SyncSinglePage[LoadBalancer] +- client.load_balancers.delete(load_balancer_id, \*, zone_id) -> LoadBalancerDeleteResponse +- client.load_balancers.edit(load_balancer_id, \*, zone_id, \*\*params) -> LoadBalancer +- client.load_balancers.get(load_balancer_id, \*, zone_id) -> LoadBalancer + +## Monitors + +Types: + +```python +from cloudflare.types.load_balancers import Monitor, MonitorDeleteResponse +``` + +Methods: + +- client.load_balancers.monitors.create(\*, account_id, \*\*params) -> Monitor +- client.load_balancers.monitors.update(monitor_id, \*, account_id, \*\*params) -> Monitor +- client.load_balancers.monitors.list(\*, account_id) -> SyncSinglePage[Monitor] +- client.load_balancers.monitors.delete(monitor_id, \*, account_id) -> MonitorDeleteResponse +- client.load_balancers.monitors.edit(monitor_id, \*, account_id, \*\*params) -> Monitor +- client.load_balancers.monitors.get(monitor_id, \*, account_id) -> Monitor + +### Previews + +Types: + +```python +from cloudflare.types.load_balancers.monitors import PreviewCreateResponse +``` + +Methods: + +- client.load_balancers.monitors.previews.create(monitor_id, \*, account_id, \*\*params) -> PreviewCreateResponse + +### References + +Types: + +```python +from cloudflare.types.load_balancers.monitors import ReferenceGetResponse +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.load_balancers import Pool, PoolDeleteResponse +``` + +Methods: + +- client.load_balancers.pools.create(\*, account_id, \*\*params) -> Pool +- 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 + +### Health + +Types: + +```python +from cloudflare.types.load_balancers.pools import HealthCreateResponse, HealthGetResponse +``` + +Methods: + +- client.load_balancers.pools.health.create(pool_id, \*, account_id, \*\*params) -> HealthCreateResponse +- client.load_balancers.pools.health.get(pool_id, \*, account_id) -> HealthGetResponse + +### References + +Types: + +```python +from cloudflare.types.load_balancers.pools import ReferenceGetResponse +``` + +Methods: + +- client.load_balancers.pools.references.get(pool_id, \*, account_id) -> SyncSinglePage[ReferenceGetResponse] + +## Previews + +Types: + +```python +from cloudflare.types.load_balancers import PreviewGetResponse +``` + +Methods: + +- client.load_balancers.previews.get(preview_id, \*, account_id) -> PreviewGetResponse + +## Regions + +Types: + +```python +from cloudflare.types.load_balancers import RegionListResponse, RegionGetResponse +``` + +Methods: + +- client.load_balancers.regions.list(\*, account_id, \*\*params) -> RegionListResponse +- client.load_balancers.regions.get(region_id, \*, account_id) -> RegionGetResponse + +## Searches + +Types: + +```python +from cloudflare.types.load_balancers import SearchListResponse +``` + +Methods: + +- client.load_balancers.searches.list(\*, account_id, \*\*params) -> SyncV4PagePagination[SearchListResponse] diff --git a/src/cloudflare/resources/load_balancers/load_balancers.py b/src/cloudflare/resources/load_balancers/load_balancers.py index 228f48335be..d9319e6b9be 100644 --- a/src/cloudflare/resources/load_balancers/load_balancers.py +++ b/src/cloudflare/resources/load_balancers/load_balancers.py @@ -15,7 +15,7 @@ AsyncRegionsResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .previews import ( PreviewsResource, AsyncPreviewsResource, @@ -135,7 +135,7 @@ def with_streaming_response(self) -> LoadBalancersResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, default_pools: SequenceNotStr[DefaultPools], fallback_pool: str, name: str, @@ -283,10 +283,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/load_balancers", + path_template("/zones/{zone_id}/load_balancers", zone_id=zone_id), body=maybe_transform( { "default_pools": default_pools, @@ -324,7 +326,7 @@ def update( self, load_balancer_id: str, *, - zone_id: str, + zone_id: str | None = None, default_pools: SequenceNotStr[DefaultPools], fallback_pool: str, name: str, @@ -475,12 +477,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not load_balancer_id: raise ValueError(f"Expected a non-empty value for `load_balancer_id` but received {load_balancer_id!r}") return self._put( - f"/zones/{zone_id}/load_balancers/{load_balancer_id}", + path_template( + "/zones/{zone_id}/load_balancers/{load_balancer_id}", zone_id=zone_id, load_balancer_id=load_balancer_id + ), body=maybe_transform( { "default_pools": default_pools, @@ -518,7 +524,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -538,10 +544,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/load_balancers", + path_template("/zones/{zone_id}/load_balancers", zone_id=zone_id), page=SyncSinglePage[LoadBalancer], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -553,7 +561,7 @@ def delete( self, load_balancer_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -573,12 +581,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not load_balancer_id: raise ValueError(f"Expected a non-empty value for `load_balancer_id` but received {load_balancer_id!r}") return self._delete( - f"/zones/{zone_id}/load_balancers/{load_balancer_id}", + path_template( + "/zones/{zone_id}/load_balancers/{load_balancer_id}", zone_id=zone_id, load_balancer_id=load_balancer_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -593,7 +605,7 @@ def edit( self, load_balancer_id: str, *, - zone_id: str, + zone_id: str | None = None, adaptive_routing: AdaptiveRoutingParam | Omit = omit, country_pools: Dict[str, SequenceNotStr[str]] | Omit = omit, default_pools: SequenceNotStr[DefaultPools] | Omit = omit, @@ -741,12 +753,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not load_balancer_id: raise ValueError(f"Expected a non-empty value for `load_balancer_id` but received {load_balancer_id!r}") return self._patch( - f"/zones/{zone_id}/load_balancers/{load_balancer_id}", + path_template( + "/zones/{zone_id}/load_balancers/{load_balancer_id}", zone_id=zone_id, load_balancer_id=load_balancer_id + ), body=maybe_transform( { "adaptive_routing": adaptive_routing, @@ -784,7 +800,7 @@ def get( self, load_balancer_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -804,12 +820,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not load_balancer_id: raise ValueError(f"Expected a non-empty value for `load_balancer_id` but received {load_balancer_id!r}") return self._get( - f"/zones/{zone_id}/load_balancers/{load_balancer_id}", + path_template( + "/zones/{zone_id}/load_balancers/{load_balancer_id}", zone_id=zone_id, load_balancer_id=load_balancer_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -868,7 +888,7 @@ def with_streaming_response(self) -> AsyncLoadBalancersResourceWithStreamingResp async def create( self, *, - zone_id: str, + zone_id: str | None = None, default_pools: SequenceNotStr[DefaultPools], fallback_pool: str, name: str, @@ -1016,10 +1036,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/load_balancers", + path_template("/zones/{zone_id}/load_balancers", zone_id=zone_id), body=await async_maybe_transform( { "default_pools": default_pools, @@ -1057,7 +1079,7 @@ async def update( self, load_balancer_id: str, *, - zone_id: str, + zone_id: str | None = None, default_pools: SequenceNotStr[DefaultPools], fallback_pool: str, name: str, @@ -1208,12 +1230,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not load_balancer_id: raise ValueError(f"Expected a non-empty value for `load_balancer_id` but received {load_balancer_id!r}") return await self._put( - f"/zones/{zone_id}/load_balancers/{load_balancer_id}", + path_template( + "/zones/{zone_id}/load_balancers/{load_balancer_id}", zone_id=zone_id, load_balancer_id=load_balancer_id + ), body=await async_maybe_transform( { "default_pools": default_pools, @@ -1251,7 +1277,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1271,10 +1297,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/load_balancers", + path_template("/zones/{zone_id}/load_balancers", zone_id=zone_id), page=AsyncSinglePage[LoadBalancer], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -1286,7 +1314,7 @@ async def delete( self, load_balancer_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1306,12 +1334,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not load_balancer_id: raise ValueError(f"Expected a non-empty value for `load_balancer_id` but received {load_balancer_id!r}") return await self._delete( - f"/zones/{zone_id}/load_balancers/{load_balancer_id}", + path_template( + "/zones/{zone_id}/load_balancers/{load_balancer_id}", zone_id=zone_id, load_balancer_id=load_balancer_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1326,7 +1358,7 @@ async def edit( self, load_balancer_id: str, *, - zone_id: str, + zone_id: str | None = None, adaptive_routing: AdaptiveRoutingParam | Omit = omit, country_pools: Dict[str, SequenceNotStr[str]] | Omit = omit, default_pools: SequenceNotStr[DefaultPools] | Omit = omit, @@ -1474,12 +1506,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not load_balancer_id: raise ValueError(f"Expected a non-empty value for `load_balancer_id` but received {load_balancer_id!r}") return await self._patch( - f"/zones/{zone_id}/load_balancers/{load_balancer_id}", + path_template( + "/zones/{zone_id}/load_balancers/{load_balancer_id}", zone_id=zone_id, load_balancer_id=load_balancer_id + ), body=await async_maybe_transform( { "adaptive_routing": adaptive_routing, @@ -1517,7 +1553,7 @@ async def get( self, load_balancer_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1537,12 +1573,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not load_balancer_id: raise ValueError(f"Expected a non-empty value for `load_balancer_id` but received {load_balancer_id!r}") return await self._get( - f"/zones/{zone_id}/load_balancers/{load_balancer_id}", + path_template( + "/zones/{zone_id}/load_balancers/{load_balancer_id}", zone_id=zone_id, load_balancer_id=load_balancer_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/load_balancers/monitor_groups.py b/src/cloudflare/resources/load_balancers/monitor_groups.py index b07f8c4f7c7..d6cf21a3630 100644 --- a/src/cloudflare/resources/load_balancers/monitor_groups.py +++ b/src/cloudflare/resources/load_balancers/monitor_groups.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> MonitorGroupsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, id: str, description: str, members: Iterable[monitor_group_create_params.Member], @@ -80,10 +80,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/monitor_groups", + path_template("/accounts/{account_id}/load_balancers/monitor_groups", account_id=account_id), body=maybe_transform( { "id": id, @@ -106,7 +108,7 @@ def update( self, monitor_group_id: str, *, - account_id: str, + account_id: str | None = None, id: str, description: str, members: Iterable[monitor_group_update_params.Member], @@ -138,12 +140,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_group_id: raise ValueError(f"Expected a non-empty value for `monitor_group_id` but received {monitor_group_id!r}") return self._put( - f"/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + account_id=account_id, + monitor_group_id=monitor_group_id, + ), body=maybe_transform( { "id": id, @@ -165,7 +173,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -187,10 +195,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/monitor_groups", + path_template("/accounts/{account_id}/load_balancers/monitor_groups", account_id=account_id), page=SyncSinglePage[MonitorGroup], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -202,7 +212,7 @@ def delete( self, monitor_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -224,12 +234,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_group_id: raise ValueError(f"Expected a non-empty value for `monitor_group_id` but received {monitor_group_id!r}") return self._delete( - f"/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + account_id=account_id, + monitor_group_id=monitor_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -244,7 +260,7 @@ def edit( self, monitor_group_id: str, *, - account_id: str, + account_id: str | None = None, id: str, description: str, members: Iterable[monitor_group_edit_params.Member], @@ -276,12 +292,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_group_id: raise ValueError(f"Expected a non-empty value for `monitor_group_id` but received {monitor_group_id!r}") return self._patch( - f"/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + account_id=account_id, + monitor_group_id=monitor_group_id, + ), body=maybe_transform( { "id": id, @@ -304,7 +326,7 @@ def get( self, monitor_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -326,12 +348,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_group_id: raise ValueError(f"Expected a non-empty value for `monitor_group_id` but received {monitor_group_id!r}") return self._get( - f"/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + account_id=account_id, + monitor_group_id=monitor_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -366,7 +394,7 @@ def with_streaming_response(self) -> AsyncMonitorGroupsResourceWithStreamingResp async def create( self, *, - account_id: str, + account_id: str | None = None, id: str, description: str, members: Iterable[monitor_group_create_params.Member], @@ -398,10 +426,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/monitor_groups", + path_template("/accounts/{account_id}/load_balancers/monitor_groups", account_id=account_id), body=await async_maybe_transform( { "id": id, @@ -424,7 +454,7 @@ async def update( self, monitor_group_id: str, *, - account_id: str, + account_id: str | None = None, id: str, description: str, members: Iterable[monitor_group_update_params.Member], @@ -456,12 +486,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_group_id: raise ValueError(f"Expected a non-empty value for `monitor_group_id` but received {monitor_group_id!r}") return await self._put( - f"/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + account_id=account_id, + monitor_group_id=monitor_group_id, + ), body=await async_maybe_transform( { "id": id, @@ -483,7 +519,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -505,10 +541,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/monitor_groups", + path_template("/accounts/{account_id}/load_balancers/monitor_groups", account_id=account_id), page=AsyncSinglePage[MonitorGroup], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -520,7 +558,7 @@ async def delete( self, monitor_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -542,12 +580,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_group_id: raise ValueError(f"Expected a non-empty value for `monitor_group_id` but received {monitor_group_id!r}") return await self._delete( - f"/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + account_id=account_id, + monitor_group_id=monitor_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -562,7 +606,7 @@ async def edit( self, monitor_group_id: str, *, - account_id: str, + account_id: str | None = None, id: str, description: str, members: Iterable[monitor_group_edit_params.Member], @@ -594,12 +638,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_group_id: raise ValueError(f"Expected a non-empty value for `monitor_group_id` but received {monitor_group_id!r}") return await self._patch( - f"/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + account_id=account_id, + monitor_group_id=monitor_group_id, + ), body=await async_maybe_transform( { "id": id, @@ -622,7 +672,7 @@ async def get( self, monitor_group_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -644,12 +694,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_group_id: raise ValueError(f"Expected a non-empty value for `monitor_group_id` but received {monitor_group_id!r}") return await self._get( - f"/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitor_groups/{monitor_group_id}", + account_id=account_id, + monitor_group_id=monitor_group_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/load_balancers/monitors/monitors.py b/src/cloudflare/resources/load_balancers/monitors/monitors.py index 4137d8448f6..db84661e49b 100644 --- a/src/cloudflare/resources/load_balancers/monitors/monitors.py +++ b/src/cloudflare/resources/load_balancers/monitors/monitors.py @@ -16,7 +16,7 @@ AsyncPreviewsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from .references import ( ReferencesResource, @@ -74,7 +74,7 @@ def with_streaming_response(self) -> MonitorsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -161,10 +161,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/monitors", + path_template("/accounts/{account_id}/load_balancers/monitors", account_id=account_id), body=maybe_transform( { "allow_insecure": allow_insecure, @@ -200,7 +202,7 @@ def update( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -287,12 +289,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return self._put( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + account_id=account_id, + monitor_id=monitor_id, + ), body=maybe_transform( { "allow_insecure": allow_insecure, @@ -327,7 +335,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -349,10 +357,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/monitors", + path_template("/accounts/{account_id}/load_balancers/monitors", account_id=account_id), page=SyncSinglePage[Monitor], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -364,7 +374,7 @@ def delete( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -386,12 +396,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return self._delete( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + account_id=account_id, + monitor_id=monitor_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -406,7 +422,7 @@ def edit( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -493,12 +509,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return self._patch( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + account_id=account_id, + monitor_id=monitor_id, + ), body=maybe_transform( { "allow_insecure": allow_insecure, @@ -534,7 +556,7 @@ def get( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -556,12 +578,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return self._get( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + account_id=account_id, + monitor_id=monitor_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -604,7 +632,7 @@ def with_streaming_response(self) -> AsyncMonitorsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -691,10 +719,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/monitors", + path_template("/accounts/{account_id}/load_balancers/monitors", account_id=account_id), body=await async_maybe_transform( { "allow_insecure": allow_insecure, @@ -730,7 +760,7 @@ async def update( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -817,12 +847,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return await self._put( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + account_id=account_id, + monitor_id=monitor_id, + ), body=await async_maybe_transform( { "allow_insecure": allow_insecure, @@ -857,7 +893,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -879,10 +915,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/monitors", + path_template("/accounts/{account_id}/load_balancers/monitors", account_id=account_id), page=AsyncSinglePage[Monitor], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -894,7 +932,7 @@ async def delete( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -916,12 +954,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return await self._delete( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + account_id=account_id, + monitor_id=monitor_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -936,7 +980,7 @@ async def edit( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -1023,12 +1067,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return await self._patch( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + account_id=account_id, + monitor_id=monitor_id, + ), body=await async_maybe_transform( { "allow_insecure": allow_insecure, @@ -1064,7 +1114,7 @@ async def get( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1086,12 +1136,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return await self._get( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}", + account_id=account_id, + monitor_id=monitor_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/load_balancers/monitors/previews.py b/src/cloudflare/resources/load_balancers/monitors/previews.py index 93dc55e8c55..ca932df4519 100644 --- a/src/cloudflare/resources/load_balancers/monitors/previews.py +++ b/src/cloudflare/resources/load_balancers/monitors/previews.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def create( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -138,12 +138,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return self._post( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}/preview", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}/preview", + account_id=account_id, + monitor_id=monitor_id, + ), body=maybe_transform( { "allow_insecure": allow_insecure, @@ -200,7 +206,7 @@ async def create( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -289,12 +295,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return await self._post( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}/preview", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}/preview", + account_id=account_id, + monitor_id=monitor_id, + ), body=await async_maybe_transform( { "allow_insecure": allow_insecure, diff --git a/src/cloudflare/resources/load_balancers/monitors/references.py b/src/cloudflare/resources/load_balancers/monitors/references.py index 0730278f0df..dd0b765215f 100644 --- a/src/cloudflare/resources/load_balancers/monitors/references.py +++ b/src/cloudflare/resources/load_balancers/monitors/references.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,7 +45,7 @@ def get( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,12 +67,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return self._get_api_list( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}/references", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}/references", + account_id=account_id, + monitor_id=monitor_id, + ), page=SyncSinglePage[ReferenceGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -104,7 +111,7 @@ def get( self, monitor_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -126,12 +133,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not monitor_id: raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}") return self._get_api_list( - f"/accounts/{account_id}/load_balancers/monitors/{monitor_id}/references", + path_template( + "/accounts/{account_id}/load_balancers/monitors/{monitor_id}/references", + account_id=account_id, + monitor_id=monitor_id, + ), page=AsyncSinglePage[ReferenceGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/load_balancers/pools/health.py b/src/cloudflare/resources/load_balancers/pools/health.py index 1cd0e96d1de..474673a360e 100644 --- a/src/cloudflare/resources/load_balancers/pools/health.py +++ b/src/cloudflare/resources/load_balancers/pools/health.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def create( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -139,12 +139,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return self._post( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}/preview", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}/preview", account_id=account_id, pool_id=pool_id + ), body=maybe_transform( { "allow_insecure": allow_insecure, @@ -180,7 +184,7 @@ def get( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -202,12 +206,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return self._get( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}/health", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}/health", account_id=account_id, pool_id=pool_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -243,7 +251,7 @@ async def create( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, allow_insecure: bool | Omit = omit, consecutive_down: int | Omit = omit, consecutive_up: int | Omit = omit, @@ -332,12 +340,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return await self._post( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}/preview", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}/preview", account_id=account_id, pool_id=pool_id + ), body=await async_maybe_transform( { "allow_insecure": allow_insecure, @@ -373,7 +385,7 @@ async def get( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -395,12 +407,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return await self._get( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}/health", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}/health", account_id=account_id, pool_id=pool_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/load_balancers/pools/pools.py b/src/cloudflare/resources/load_balancers/pools/pools.py index 7d3c3876c67..9762e7550e4 100644 --- a/src/cloudflare/resources/load_balancers/pools/pools.py +++ b/src/cloudflare/resources/load_balancers/pools/pools.py @@ -16,7 +16,7 @@ AsyncHealthResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from .references import ( ReferencesResource, @@ -85,7 +85,7 @@ def with_streaming_response(self) -> PoolsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, origins: Iterable[OriginParam], description: str | Omit = omit, @@ -162,10 +162,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/pools", + path_template("/accounts/{account_id}/load_balancers/pools", account_id=account_id), body=maybe_transform( { "name": name, @@ -198,7 +200,7 @@ def update( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, name: str, origins: Iterable[OriginParam], check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -279,12 +281,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return self._put( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}", account_id=account_id, pool_id=pool_id + ), body=maybe_transform( { "name": name, @@ -317,7 +323,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, monitor: 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. @@ -343,10 +349,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/pools", + path_template("/accounts/{account_id}/load_balancers/pools", account_id=account_id), page=SyncSinglePage[Pool], options=make_request_options( extra_headers=extra_headers, @@ -362,7 +370,7 @@ def delete( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -384,12 +392,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return self._delete( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}", account_id=account_id, pool_id=pool_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -403,7 +415,7 @@ def delete( def bulk_edit( self, *, - account_id: str, + account_id: str | None = None, notification_email: Literal[""] | 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. @@ -434,10 +446,12 @@ def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/pools", + path_template("/accounts/{account_id}/load_balancers/pools", account_id=account_id), page=SyncSinglePage[Pool], body=maybe_transform({"notification_email": notification_email}, pool_bulk_edit_params.PoolBulkEditParams), options=make_request_options( @@ -451,7 +465,7 @@ def edit( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, check_regions: Optional[List[CheckRegion]] | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, @@ -532,12 +546,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return self._patch( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}", account_id=account_id, pool_id=pool_id + ), body=maybe_transform( { "check_regions": check_regions, @@ -571,7 +589,7 @@ def get( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -593,12 +611,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return self._get( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}", account_id=account_id, pool_id=pool_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -641,7 +663,7 @@ def with_streaming_response(self) -> AsyncPoolsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, origins: Iterable[OriginParam], description: str | Omit = omit, @@ -718,10 +740,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/pools", + path_template("/accounts/{account_id}/load_balancers/pools", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -754,7 +778,7 @@ async def update( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, name: str, origins: Iterable[OriginParam], check_regions: Optional[List[CheckRegion]] | Omit = omit, @@ -835,12 +859,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return await self._put( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}", account_id=account_id, pool_id=pool_id + ), body=await async_maybe_transform( { "name": name, @@ -873,7 +901,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, monitor: 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. @@ -899,10 +927,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/pools", + path_template("/accounts/{account_id}/load_balancers/pools", account_id=account_id), page=AsyncSinglePage[Pool], options=make_request_options( extra_headers=extra_headers, @@ -918,7 +948,7 @@ async def delete( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -940,12 +970,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return await self._delete( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}", account_id=account_id, pool_id=pool_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -959,7 +993,7 @@ async def delete( def bulk_edit( self, *, - account_id: str, + account_id: str | None = None, notification_email: Literal[""] | 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. @@ -990,10 +1024,12 @@ def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/pools", + path_template("/accounts/{account_id}/load_balancers/pools", account_id=account_id), page=AsyncSinglePage[Pool], body=maybe_transform({"notification_email": notification_email}, pool_bulk_edit_params.PoolBulkEditParams), options=make_request_options( @@ -1007,7 +1043,7 @@ async def edit( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, check_regions: Optional[List[CheckRegion]] | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, @@ -1088,12 +1124,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return await self._patch( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}", account_id=account_id, pool_id=pool_id + ), body=await async_maybe_transform( { "check_regions": check_regions, @@ -1127,7 +1167,7 @@ async def get( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1149,12 +1189,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return await self._get( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}", account_id=account_id, pool_id=pool_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/load_balancers/pools/references.py b/src/cloudflare/resources/load_balancers/pools/references.py index 2bdf9464def..4932ea6649a 100644 --- a/src/cloudflare/resources/load_balancers/pools/references.py +++ b/src/cloudflare/resources/load_balancers/pools/references.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,7 +45,7 @@ def get( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,12 +67,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return self._get_api_list( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}/references", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}/references", + account_id=account_id, + pool_id=pool_id, + ), page=SyncSinglePage[ReferenceGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -104,7 +111,7 @@ def get( self, pool_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -126,12 +133,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pool_id: raise ValueError(f"Expected a non-empty value for `pool_id` but received {pool_id!r}") return self._get_api_list( - f"/accounts/{account_id}/load_balancers/pools/{pool_id}/references", + path_template( + "/accounts/{account_id}/load_balancers/pools/{pool_id}/references", + account_id=account_id, + pool_id=pool_id, + ), page=AsyncSinglePage[ReferenceGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/load_balancers/previews.py b/src/cloudflare/resources/load_balancers/previews.py index 9aa003c8728..2c37559665a 100644 --- a/src/cloudflare/resources/load_balancers/previews.py +++ b/src/cloudflare/resources/load_balancers/previews.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +47,7 @@ def get( self, preview_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,12 +69,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not preview_id: raise ValueError(f"Expected a non-empty value for `preview_id` but received {preview_id!r}") return self._get( - f"/accounts/{account_id}/load_balancers/preview/{preview_id}", + path_template( + "/accounts/{account_id}/load_balancers/preview/{preview_id}", + account_id=account_id, + preview_id=preview_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -109,7 +116,7 @@ async def get( self, preview_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -131,12 +138,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not preview_id: raise ValueError(f"Expected a non-empty value for `preview_id` but received {preview_id!r}") return await self._get( - f"/accounts/{account_id}/load_balancers/preview/{preview_id}", + path_template( + "/accounts/{account_id}/load_balancers/preview/{preview_id}", + account_id=account_id, + preview_id=preview_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/load_balancers/regions.py b/src/cloudflare/resources/load_balancers/regions.py index d885fe0838d..72b6891971e 100644 --- a/src/cloudflare/resources/load_balancers/regions.py +++ b/src/cloudflare/resources/load_balancers/regions.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> RegionsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, country_code_a2: str | Omit = omit, subdivision_code: str | Omit = omit, subdivision_code_a2: str | Omit = omit, @@ -80,12 +80,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( RegionListResponse, self._get( - f"/accounts/{account_id}/load_balancers/regions", + path_template("/accounts/{account_id}/load_balancers/regions", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -113,7 +115,7 @@ def get( "WNAM", "ENAM", "WEU", "EEU", "NSAM", "SSAM", "OC", "ME", "NAF", "SAF", "SAS", "SEAS", "NEAS" ], *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -141,6 +143,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not region_id: @@ -148,7 +152,11 @@ def get( return cast( RegionGetResponse, self._get( - f"/accounts/{account_id}/load_balancers/regions/{region_id}", + path_template( + "/accounts/{account_id}/load_balancers/regions/{region_id}", + account_id=account_id, + region_id=region_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -186,7 +194,7 @@ def with_streaming_response(self) -> AsyncRegionsResourceWithStreamingResponse: async def list( self, *, - account_id: str, + account_id: str | None = None, country_code_a2: str | Omit = omit, subdivision_code: str | Omit = omit, subdivision_code_a2: str | Omit = omit, @@ -217,12 +225,14 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( RegionListResponse, await self._get( - f"/accounts/{account_id}/load_balancers/regions", + path_template("/accounts/{account_id}/load_balancers/regions", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -250,7 +260,7 @@ async def get( "WNAM", "ENAM", "WEU", "EEU", "NSAM", "SSAM", "OC", "ME", "NAF", "SAF", "SAS", "SEAS", "NEAS" ], *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -278,6 +288,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not region_id: @@ -285,7 +297,11 @@ async def get( return cast( RegionGetResponse, await self._get( - f"/accounts/{account_id}/load_balancers/regions/{region_id}", + path_template( + "/accounts/{account_id}/load_balancers/regions/{region_id}", + account_id=account_id, + region_id=region_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/load_balancers/searches.py b/src/cloudflare/resources/load_balancers/searches.py index 0bf1c0e6e04..9b254b09b36 100644 --- a/src/cloudflare/resources/load_balancers/searches.py +++ b/src/cloudflare/resources/load_balancers/searches.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> SearchesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, page: float | Omit = omit, per_page: float | Omit = omit, query: str | Omit = omit, @@ -78,10 +78,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/search", + path_template("/accounts/{account_id}/load_balancers/search", account_id=account_id), page=SyncV4PagePagination[SearchListResponse], options=make_request_options( extra_headers=extra_headers, @@ -125,7 +127,7 @@ def with_streaming_response(self) -> AsyncSearchesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, page: float | Omit = omit, per_page: float | Omit = omit, query: str | Omit = omit, @@ -156,10 +158,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/load_balancers/search", + path_template("/accounts/{account_id}/load_balancers/search", account_id=account_id), page=AsyncV4PagePagination[SearchListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/logpush/api.md b/src/cloudflare/resources/logpush/api.md new file mode 100644 index 00000000000..30f7d7254f2 --- /dev/null +++ b/src/cloudflare/resources/logpush/api.md @@ -0,0 +1,75 @@ +# Logpush + +## Datasets + +### Fields + +Methods: + +- client.logpush.datasets.fields.get(dataset_id, \*, account_id, zone_id) -> object + +### Jobs + +Methods: + +- client.logpush.datasets.jobs.get(dataset_id, \*, account_id, zone_id) -> SyncSinglePage[Optional[LogpushJob]] + +## Edge + +Types: + +```python +from cloudflare.types.logpush import InstantLogpushJob +``` + +Methods: + +- client.logpush.edge.create(\*, zone_id, \*\*params) -> Optional[InstantLogpushJob] +- client.logpush.edge.get(\*, zone_id) -> SyncSinglePage[Optional[InstantLogpushJob]] + +## Jobs + +Types: + +```python +from cloudflare.types.logpush import LogpushJob, OutputOptions, JobDeleteResponse +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.logpush import OwnershipValidation, OwnershipCreateResponse +``` + +Methods: + +- 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, + ValidateDestinationExistsResponse, + ValidateOriginResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/logpush/datasets/fields.py b/src/cloudflare/resources/logpush/datasets/fields.py index 75640d3e262..9e49fbc0cad 100644 --- a/src/cloudflare/resources/logpush/datasets/fields.py +++ b/src/cloudflare/resources/logpush/datasets/fields.py @@ -7,7 +7,8 @@ import httpx -from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -44,44 +45,42 @@ def with_streaming_response(self) -> FieldsResourceWithStreamingResponse: def get( self, - dataset_id: Optional[ - Literal[ - "access_requests", - "audit_logs", - "audit_logs_v2", - "biso_user_actions", - "casb_findings", - "device_posture_results", - "dex_application_tests", - "dex_device_state_events", - "dlp_forensic_copies", - "dns_firewall_logs", - "dns_logs", - "email_security_alerts", - "firewall_events", - "gateway_dns", - "gateway_http", - "gateway_network", - "http_requests", - "ipsec_logs", - "magic_ids_detections", - "mcp_portal_logs", - "nel_reports", - "network_analytics_logs", - "page_shield_events", - "sinkhole_http_logs", - "spectrum_events", - "ssh_logs", - "warp_config_changes", - "warp_toggle_changes", - "workers_trace_events", - "zaraz_events", - "zero_trust_network_sessions", - ] + dataset_id: Literal[ + "access_requests", + "audit_logs", + "audit_logs_v2", + "biso_user_actions", + "casb_findings", + "device_posture_results", + "dex_application_tests", + "dex_device_state_events", + "dlp_forensic_copies", + "dns_firewall_logs", + "dns_logs", + "email_security_alerts", + "firewall_events", + "gateway_dns", + "gateway_http", + "gateway_network", + "http_requests", + "ipsec_logs", + "magic_ids_detections", + "mcp_portal_logs", + "nel_reports", + "network_analytics_logs", + "page_shield_events", + "sinkhole_http_logs", + "spectrum_events", + "ssh_logs", + "warp_config_changes", + "warp_toggle_changes", + "workers_trace_events", + "zaraz_events", + "zero_trust_network_sessions", ], *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -112,6 +111,10 @@ def get( """ if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -125,7 +128,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/fields", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/fields", + dataset_id=dataset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -159,44 +167,42 @@ def with_streaming_response(self) -> AsyncFieldsResourceWithStreamingResponse: async def get( self, - dataset_id: Optional[ - Literal[ - "access_requests", - "audit_logs", - "audit_logs_v2", - "biso_user_actions", - "casb_findings", - "device_posture_results", - "dex_application_tests", - "dex_device_state_events", - "dlp_forensic_copies", - "dns_firewall_logs", - "dns_logs", - "email_security_alerts", - "firewall_events", - "gateway_dns", - "gateway_http", - "gateway_network", - "http_requests", - "ipsec_logs", - "magic_ids_detections", - "mcp_portal_logs", - "nel_reports", - "network_analytics_logs", - "page_shield_events", - "sinkhole_http_logs", - "spectrum_events", - "ssh_logs", - "warp_config_changes", - "warp_toggle_changes", - "workers_trace_events", - "zaraz_events", - "zero_trust_network_sessions", - ] + dataset_id: Literal[ + "access_requests", + "audit_logs", + "audit_logs_v2", + "biso_user_actions", + "casb_findings", + "device_posture_results", + "dex_application_tests", + "dex_device_state_events", + "dlp_forensic_copies", + "dns_firewall_logs", + "dns_logs", + "email_security_alerts", + "firewall_events", + "gateway_dns", + "gateway_http", + "gateway_network", + "http_requests", + "ipsec_logs", + "magic_ids_detections", + "mcp_portal_logs", + "nel_reports", + "network_analytics_logs", + "page_shield_events", + "sinkhole_http_logs", + "spectrum_events", + "ssh_logs", + "warp_config_changes", + "warp_toggle_changes", + "workers_trace_events", + "zaraz_events", + "zero_trust_network_sessions", ], *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -227,6 +233,10 @@ async def get( """ if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -240,7 +250,12 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/fields", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/fields", + dataset_id=dataset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/logpush/datasets/jobs.py b/src/cloudflare/resources/logpush/datasets/jobs.py index d6714544ff9..5cbac38c0aa 100644 --- a/src/cloudflare/resources/logpush/datasets/jobs.py +++ b/src/cloudflare/resources/logpush/datasets/jobs.py @@ -7,7 +7,8 @@ import httpx -from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,44 +46,42 @@ def with_streaming_response(self) -> JobsResourceWithStreamingResponse: def get( self, - dataset_id: Optional[ - Literal[ - "access_requests", - "audit_logs", - "audit_logs_v2", - "biso_user_actions", - "casb_findings", - "device_posture_results", - "dex_application_tests", - "dex_device_state_events", - "dlp_forensic_copies", - "dns_firewall_logs", - "dns_logs", - "email_security_alerts", - "firewall_events", - "gateway_dns", - "gateway_http", - "gateway_network", - "http_requests", - "ipsec_logs", - "magic_ids_detections", - "mcp_portal_logs", - "nel_reports", - "network_analytics_logs", - "page_shield_events", - "sinkhole_http_logs", - "spectrum_events", - "ssh_logs", - "warp_config_changes", - "warp_toggle_changes", - "workers_trace_events", - "zaraz_events", - "zero_trust_network_sessions", - ] + dataset_id: Literal[ + "access_requests", + "audit_logs", + "audit_logs_v2", + "biso_user_actions", + "casb_findings", + "device_posture_results", + "dex_application_tests", + "dex_device_state_events", + "dlp_forensic_copies", + "dns_firewall_logs", + "dns_logs", + "email_security_alerts", + "firewall_events", + "gateway_dns", + "gateway_http", + "gateway_network", + "http_requests", + "ipsec_logs", + "magic_ids_detections", + "mcp_portal_logs", + "nel_reports", + "network_analytics_logs", + "page_shield_events", + "sinkhole_http_logs", + "spectrum_events", + "ssh_logs", + "warp_config_changes", + "warp_toggle_changes", + "workers_trace_events", + "zaraz_events", + "zero_trust_network_sessions", ], *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -111,6 +110,10 @@ def get( """ if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -124,7 +127,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/jobs", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/jobs", + dataset_id=dataset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncSinglePage[Optional[LogpushJob]], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -155,44 +163,42 @@ def with_streaming_response(self) -> AsyncJobsResourceWithStreamingResponse: def get( self, - dataset_id: Optional[ - Literal[ - "access_requests", - "audit_logs", - "audit_logs_v2", - "biso_user_actions", - "casb_findings", - "device_posture_results", - "dex_application_tests", - "dex_device_state_events", - "dlp_forensic_copies", - "dns_firewall_logs", - "dns_logs", - "email_security_alerts", - "firewall_events", - "gateway_dns", - "gateway_http", - "gateway_network", - "http_requests", - "ipsec_logs", - "magic_ids_detections", - "mcp_portal_logs", - "nel_reports", - "network_analytics_logs", - "page_shield_events", - "sinkhole_http_logs", - "spectrum_events", - "ssh_logs", - "warp_config_changes", - "warp_toggle_changes", - "workers_trace_events", - "zaraz_events", - "zero_trust_network_sessions", - ] + dataset_id: Literal[ + "access_requests", + "audit_logs", + "audit_logs_v2", + "biso_user_actions", + "casb_findings", + "device_posture_results", + "dex_application_tests", + "dex_device_state_events", + "dlp_forensic_copies", + "dns_firewall_logs", + "dns_logs", + "email_security_alerts", + "firewall_events", + "gateway_dns", + "gateway_http", + "gateway_network", + "http_requests", + "ipsec_logs", + "magic_ids_detections", + "mcp_portal_logs", + "nel_reports", + "network_analytics_logs", + "page_shield_events", + "sinkhole_http_logs", + "spectrum_events", + "ssh_logs", + "warp_config_changes", + "warp_toggle_changes", + "workers_trace_events", + "zaraz_events", + "zero_trust_network_sessions", ], *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -221,6 +227,10 @@ def get( """ if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -234,7 +244,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/jobs", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/jobs", + dataset_id=dataset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncSinglePage[Optional[LogpushJob]], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/logpush/edge.py b/src/cloudflare/resources/logpush/edge.py index 5404dffd698..5192b93cf87 100644 --- a/src/cloudflare/resources/logpush/edge.py +++ b/src/cloudflare/resources/logpush/edge.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> EdgeResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, fields: str | Omit = omit, filter: str | Omit = omit, sample: int | Omit = omit, @@ -81,10 +81,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/logpush/edge/jobs", + path_template("/zones/{zone_id}/logpush/edge/jobs", zone_id=zone_id), body=maybe_transform( { "fields": fields, @@ -106,7 +108,7 @@ def create( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -128,10 +130,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/logpush/edge/jobs", + path_template("/zones/{zone_id}/logpush/edge/jobs", zone_id=zone_id), page=SyncSinglePage[Optional[InstantLogpushJob]], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -163,7 +167,7 @@ def with_streaming_response(self) -> AsyncEdgeResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, fields: str | Omit = omit, filter: str | Omit = omit, sample: int | Omit = omit, @@ -196,10 +200,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/logpush/edge/jobs", + path_template("/zones/{zone_id}/logpush/edge/jobs", zone_id=zone_id), body=await async_maybe_transform( { "fields": fields, @@ -221,7 +227,7 @@ async def create( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -243,10 +249,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/logpush/edge/jobs", + path_template("/zones/{zone_id}/logpush/edge/jobs", zone_id=zone_id), page=AsyncSinglePage[Optional[InstantLogpushJob]], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/logpush/jobs.py b/src/cloudflare/resources/logpush/jobs.py index 46b1c9bdddd..923de998f9c 100644 --- a/src/cloudflare/resources/logpush/jobs.py +++ b/src/cloudflare/resources/logpush/jobs.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,8 +52,8 @@ def create( self, *, destination_conf: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, dataset: Optional[ Literal[ "access_requests", @@ -175,6 +175,10 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -188,7 +192,11 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "destination_conf": destination_conf, @@ -221,8 +229,8 @@ def update( self, job_id: int, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, destination_conf: str | Omit = omit, enabled: bool | Omit = omit, filter: Optional[str] | Omit = omit, @@ -308,6 +316,10 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -321,7 +333,12 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._put( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + job_id=job_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "destination_conf": destination_conf, @@ -352,8 +369,8 @@ def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -377,6 +394,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -390,7 +411,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncSinglePage[Optional[LogpushJob]], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -402,8 +427,8 @@ def delete( self, job_id: int, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -429,6 +454,10 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -442,7 +471,12 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + job_id=job_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -457,8 +491,8 @@ def get( self, job_id: int, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -484,6 +518,10 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -497,7 +535,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + job_id=job_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -533,8 +576,8 @@ async def create( self, *, destination_conf: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, dataset: Optional[ Literal[ "access_requests", @@ -656,6 +699,10 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -669,7 +716,11 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "destination_conf": destination_conf, @@ -702,8 +753,8 @@ async def update( self, job_id: int, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, destination_conf: str | Omit = omit, enabled: bool | Omit = omit, filter: Optional[str] | Omit = omit, @@ -789,6 +840,10 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -802,7 +857,12 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + job_id=job_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "destination_conf": destination_conf, @@ -833,8 +893,8 @@ async def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -858,6 +918,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -871,7 +935,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncSinglePage[Optional[LogpushJob]], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -883,8 +951,8 @@ async def delete( self, job_id: int, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -910,6 +978,10 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -923,7 +995,12 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + job_id=job_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -938,8 +1015,8 @@ async def get( self, job_id: int, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -965,6 +1042,10 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -978,7 +1059,12 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + job_id=job_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/logpush/ownership.py b/src/cloudflare/resources/logpush/ownership.py index c10b76d96c2..885a81f6f34 100644 --- a/src/cloudflare/resources/logpush/ownership.py +++ b/src/cloudflare/resources/logpush/ownership.py @@ -6,8 +6,8 @@ import httpx -from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,8 +49,8 @@ def create( self, *, destination_conf: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -78,6 +78,10 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -91,7 +95,11 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/ownership", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/ownership", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform({"destination_conf": destination_conf}, ownership_create_params.OwnershipCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -108,8 +116,8 @@ def validate( *, destination_conf: str, ownership_challenge: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -139,6 +147,10 @@ def validate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -152,7 +164,11 @@ def validate( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/ownership/validate", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/ownership/validate", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "destination_conf": destination_conf, @@ -195,8 +211,8 @@ async def create( self, *, destination_conf: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -224,6 +240,10 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -237,7 +257,11 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/ownership", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/ownership", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( {"destination_conf": destination_conf}, ownership_create_params.OwnershipCreateParams ), @@ -256,8 +280,8 @@ async def validate( *, destination_conf: str, ownership_challenge: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -287,6 +311,10 @@ async def validate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -300,7 +328,11 @@ async def validate( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/ownership/validate", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/ownership/validate", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "destination_conf": destination_conf, diff --git a/src/cloudflare/resources/logpush/validate.py b/src/cloudflare/resources/logpush/validate.py index cfeeb0f3af0..cc6981edc98 100644 --- a/src/cloudflare/resources/logpush/validate.py +++ b/src/cloudflare/resources/logpush/validate.py @@ -6,8 +6,8 @@ import httpx -from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,8 +50,8 @@ def destination( self, *, destination_conf: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -79,6 +79,10 @@ def destination( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -92,7 +96,11 @@ def destination( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/validate/destination", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/validate/destination", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( {"destination_conf": destination_conf}, validate_destination_params.ValidateDestinationParams ), @@ -110,8 +118,8 @@ def destination_exists( self, *, destination_conf: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -139,6 +147,10 @@ def destination_exists( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -152,7 +164,11 @@ def destination_exists( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/validate/destination/exists", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/validate/destination/exists", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( {"destination_conf": destination_conf}, validate_destination_exists_params.ValidateDestinationExistsParams, @@ -173,8 +189,8 @@ def origin( self, *, logpull_options: Optional[str], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -204,6 +220,10 @@ def origin( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -217,7 +237,11 @@ def origin( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/validate/origin", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/validate/origin", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform({"logpull_options": logpull_options}, validate_origin_params.ValidateOriginParams), options=make_request_options( extra_headers=extra_headers, @@ -254,8 +278,8 @@ async def destination( self, *, destination_conf: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -283,6 +307,10 @@ async def destination( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -296,7 +324,11 @@ async def destination( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/validate/destination", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/validate/destination", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( {"destination_conf": destination_conf}, validate_destination_params.ValidateDestinationParams ), @@ -314,8 +346,8 @@ async def destination_exists( self, *, destination_conf: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -343,6 +375,10 @@ async def destination_exists( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -356,7 +392,11 @@ async def destination_exists( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/validate/destination/exists", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/validate/destination/exists", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( {"destination_conf": destination_conf}, validate_destination_exists_params.ValidateDestinationExistsParams, @@ -377,8 +417,8 @@ async def origin( self, *, logpull_options: Optional[str], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -408,6 +448,10 @@ async def origin( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -421,7 +465,11 @@ async def origin( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/logpush/validate/origin", + path_template( + "/{account_or_zone}/{account_or_zone_id}/logpush/validate/origin", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( {"logpull_options": logpull_options}, validate_origin_params.ValidateOriginParams ), diff --git a/src/cloudflare/resources/logs/api.md b/src/cloudflare/resources/logs/api.md new file mode 100644 index 00000000000..b38a955fdfb --- /dev/null +++ b/src/cloudflare/resources/logs/api.md @@ -0,0 +1,68 @@ +# Logs + +## Control + +### Retention + +Types: + +```python +from cloudflare.types.logs.control import RetentionCreateResponse, RetentionGetResponse +``` + +Methods: + +- client.logs.control.retention.create(\*, zone_id, \*\*params) -> Optional[RetentionCreateResponse] +- client.logs.control.retention.get(\*, zone_id) -> Optional[RetentionGetResponse] + +### Cmb + +#### Config + +Types: + +```python +from cloudflare.types.logs.control.cmb import CmbConfig +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.logs import RayIDGetResponse +``` + +Methods: + +- client.logs.rayid.get(rayid, \*, zone_id, \*\*params) -> RayIDGetResponse + +## Received + +Types: + +```python +from cloudflare.types.logs import ReceivedGetResponse +``` + +Methods: + +- client.logs.received.get(\*, zone_id, \*\*params) -> ReceivedGetResponse + +### Fields + +Types: + +```python +from cloudflare.types.logs.received import FieldGetResponse +``` + +Methods: + +- client.logs.received.fields.get(\*, zone_id) -> FieldGetResponse diff --git a/src/cloudflare/resources/logs/control/cmb/config.py b/src/cloudflare/resources/logs/control/cmb/config.py index bf0fe2e3c0c..d53e71c87a8 100644 --- a/src/cloudflare/resources/logs/control/cmb/config.py +++ b/src/cloudflare/resources/logs/control/cmb/config.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> ConfigResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, allow_out_of_region_access: bool | Omit = omit, regions: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -75,10 +75,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/logs/control/cmb/config", + path_template("/accounts/{account_id}/logs/control/cmb/config", account_id=account_id), body=maybe_transform( { "allow_out_of_region_access": allow_out_of_region_access, @@ -99,7 +101,7 @@ def create( def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -121,10 +123,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/logs/control/cmb/config", + path_template("/accounts/{account_id}/logs/control/cmb/config", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -138,7 +142,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -160,10 +164,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/logs/control/cmb/config", + path_template("/accounts/{account_id}/logs/control/cmb/config", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -198,7 +204,7 @@ def with_streaming_response(self) -> AsyncConfigResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, allow_out_of_region_access: bool | Omit = omit, regions: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -226,10 +232,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/logs/control/cmb/config", + path_template("/accounts/{account_id}/logs/control/cmb/config", account_id=account_id), body=await async_maybe_transform( { "allow_out_of_region_access": allow_out_of_region_access, @@ -250,7 +258,7 @@ async def create( async def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -272,10 +280,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/logs/control/cmb/config", + path_template("/accounts/{account_id}/logs/control/cmb/config", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -289,7 +299,7 @@ async def delete( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -311,10 +321,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/logs/control/cmb/config", + path_template("/accounts/{account_id}/logs/control/cmb/config", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/logs/control/retention.py b/src/cloudflare/resources/logs/control/retention.py index 3485d0a5d1f..01b35db235a 100644 --- a/src/cloudflare/resources/logs/control/retention.py +++ b/src/cloudflare/resources/logs/control/retention.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> RetentionResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, flag: 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. @@ -73,10 +73,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/logs/control/retention/flag", + path_template("/zones/{zone_id}/logs/control/retention/flag", zone_id=zone_id), body=maybe_transform({"flag": flag}, retention_create_params.RetentionCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -91,7 +93,7 @@ def create( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -113,10 +115,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/logs/control/retention/flag", + path_template("/zones/{zone_id}/logs/control/retention/flag", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -151,7 +155,7 @@ def with_streaming_response(self) -> AsyncRetentionResourceWithStreamingResponse async def create( self, *, - zone_id: str, + zone_id: str | None = None, flag: 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. @@ -176,10 +180,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/logs/control/retention/flag", + path_template("/zones/{zone_id}/logs/control/retention/flag", zone_id=zone_id), body=await async_maybe_transform({"flag": flag}, retention_create_params.RetentionCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -194,7 +200,7 @@ async def create( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -216,10 +222,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/logs/control/retention/flag", + path_template("/zones/{zone_id}/logs/control/retention/flag", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/logs/rayid.py b/src/cloudflare/resources/logs/rayid.py index 1f38aa3d088..04c04f19bc6 100644 --- a/src/cloudflare/resources/logs/rayid.py +++ b/src/cloudflare/resources/logs/rayid.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def get( self, rayid: str, *, - zone_id: str, + zone_id: str | None = None, fields: str | Omit = omit, timestamps: Literal["unix", "unixnano", "rfc3339"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -94,6 +94,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rayid: @@ -101,7 +103,7 @@ def get( return cast( RayIDGetResponse, self._get( - f"/zones/{zone_id}/logs/rayids/{rayid}", + path_template("/zones/{zone_id}/logs/rayids/{rayid}", zone_id=zone_id, rayid=rayid), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -144,7 +146,7 @@ async def get( self, rayid: str, *, - zone_id: str, + zone_id: str | None = None, fields: str | Omit = omit, timestamps: Literal["unix", "unixnano", "rfc3339"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -190,6 +192,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rayid: @@ -197,7 +201,7 @@ async def get( return cast( RayIDGetResponse, await self._get( - f"/zones/{zone_id}/logs/rayids/{rayid}", + path_template("/zones/{zone_id}/logs/rayids/{rayid}", zone_id=zone_id, rayid=rayid), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/logs/received/fields.py b/src/cloudflare/resources/logs/received/fields.py index 4527eff4bcd..f7534c173e7 100644 --- a/src/cloudflare/resources/logs/received/fields.py +++ b/src/cloudflare/resources/logs/received/fields.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -42,7 +43,7 @@ def with_streaming_response(self) -> FieldsResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,10 +67,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/logs/received/fields", + path_template("/zones/{zone_id}/logs/received/fields", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -100,7 +103,7 @@ def with_streaming_response(self) -> AsyncFieldsResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -124,10 +127,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/logs/received/fields", + path_template("/zones/{zone_id}/logs/received/fields", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/logs/received/received.py b/src/cloudflare/resources/logs/received/received.py index bbb7f57a210..f2ed529b10f 100644 --- a/src/cloudflare/resources/logs/received/received.py +++ b/src/cloudflare/resources/logs/received/received.py @@ -16,7 +16,7 @@ AsyncFieldsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -59,7 +59,7 @@ def with_streaming_response(self) -> ReceivedResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, end: Union[str, int], count: int | Omit = omit, fields: str | Omit = omit, @@ -137,12 +137,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( ReceivedGetResponse, self._get( - f"/zones/{zone_id}/logs/received", + path_template("/zones/{zone_id}/logs/received", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -194,7 +196,7 @@ def with_streaming_response(self) -> AsyncReceivedResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, end: Union[str, int], count: int | Omit = omit, fields: str | Omit = omit, @@ -272,12 +274,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( ReceivedGetResponse, await self._get( - f"/zones/{zone_id}/logs/received", + path_template("/zones/{zone_id}/logs/received", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_cloud_networking/api.md b/src/cloudflare/resources/magic_cloud_networking/api.md new file mode 100644 index 00000000000..77aecf0410b --- /dev/null +++ b/src/cloudflare/resources/magic_cloud_networking/api.md @@ -0,0 +1,135 @@ +# MagicCloudNetworking + +## CatalogSyncs + +Types: + +```python +from cloudflare.types.magic_cloud_networking import ( + CatalogSyncCreateResponse, + CatalogSyncUpdateResponse, + CatalogSyncListResponse, + CatalogSyncDeleteResponse, + CatalogSyncEditResponse, + CatalogSyncGetResponse, + CatalogSyncRefreshResponse, +) +``` + +Methods: + +- 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 + +### PrebuiltPolicies + +Types: + +```python +from cloudflare.types.magic_cloud_networking.catalog_syncs import PrebuiltPolicyListResponse +``` + +Methods: + +- client.magic_cloud_networking.catalog_syncs.prebuilt_policies.list(\*, account_id, \*\*params) -> SyncSinglePage[PrebuiltPolicyListResponse] + +## OnRamps + +Types: + +```python +from cloudflare.types.magic_cloud_networking import ( + OnRampCreateResponse, + OnRampUpdateResponse, + OnRampListResponse, + OnRampDeleteResponse, + OnRampApplyResponse, + OnRampEditResponse, + OnRampGetResponse, + OnRampPlanResponse, +) +``` + +Methods: + +- 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 + +### AddressSpaces + +Types: + +```python +from cloudflare.types.magic_cloud_networking.on_ramps import ( + AddressSpaceUpdateResponse, + AddressSpaceListResponse, + AddressSpaceEditResponse, +) +``` + +Methods: + +- 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 + +## CloudIntegrations + +Types: + +```python +from cloudflare.types.magic_cloud_networking import ( + CloudIntegrationCreateResponse, + CloudIntegrationUpdateResponse, + CloudIntegrationListResponse, + CloudIntegrationDeleteResponse, + CloudIntegrationDiscoverResponse, + CloudIntegrationDiscoverAllResponse, + CloudIntegrationEditResponse, + CloudIntegrationGetResponse, + CloudIntegrationInitialSetupResponse, +) +``` + +Methods: + +- 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 + +## Resources + +Types: + +```python +from cloudflare.types.magic_cloud_networking import ( + ResourceListResponse, + ResourceGetResponse, + ResourcePolicyPreviewResponse, +) +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/magic_cloud_networking/catalog_syncs/catalog_syncs.py b/src/cloudflare/resources/magic_cloud_networking/catalog_syncs/catalog_syncs.py index 98112dbdf70..678a34d42a6 100644 --- a/src/cloudflare/resources/magic_cloud_networking/catalog_syncs/catalog_syncs.py +++ b/src/cloudflare/resources/magic_cloud_networking/catalog_syncs/catalog_syncs.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, strip_not_given, async_maybe_transform +from ...._utils import path_template, maybe_transform, strip_not_given, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -72,7 +72,7 @@ def with_streaming_response(self) -> CatalogSyncsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, destination_type: Literal["NONE", "ZERO_TRUST_LIST"], name: str, update_mode: Literal["AUTO", "MANUAL"], @@ -98,11 +98,13 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"forwarded": forwarded}), **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/magic/cloud/catalog-syncs", + path_template("/accounts/{account_id}/magic/cloud/catalog-syncs", account_id=account_id), body=maybe_transform( { "destination_type": destination_type, @@ -127,7 +129,7 @@ def update( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, name: str | Omit = omit, policy: str | Omit = omit, @@ -151,12 +153,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return self._put( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", account_id=account_id, sync_id=sync_id + ), body=maybe_transform( { "description": description, @@ -179,7 +185,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -199,10 +205,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/catalog-syncs", + path_template("/accounts/{account_id}/magic/cloud/catalog-syncs", account_id=account_id), page=SyncSinglePage[CatalogSyncListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -214,7 +222,7 @@ def delete( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, delete_destination: 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. @@ -235,12 +243,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return self._delete( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", account_id=account_id, sync_id=sync_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -258,7 +270,7 @@ def edit( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, name: str | Omit = omit, policy: str | Omit = omit, @@ -282,12 +294,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return self._patch( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", account_id=account_id, sync_id=sync_id + ), body=maybe_transform( { "description": description, @@ -311,7 +327,7 @@ def get( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -331,12 +347,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return self._get( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", account_id=account_id, sync_id=sync_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -351,7 +371,7 @@ def refresh( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -372,12 +392,18 @@ def refresh( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return self._post( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}/refresh", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}/refresh", + account_id=account_id, + sync_id=sync_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -416,7 +442,7 @@ def with_streaming_response(self) -> AsyncCatalogSyncsResourceWithStreamingRespo async def create( self, *, - account_id: str, + account_id: str | None = None, destination_type: Literal["NONE", "ZERO_TRUST_LIST"], name: str, update_mode: Literal["AUTO", "MANUAL"], @@ -442,11 +468,13 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"forwarded": forwarded}), **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/magic/cloud/catalog-syncs", + path_template("/accounts/{account_id}/magic/cloud/catalog-syncs", account_id=account_id), body=await async_maybe_transform( { "destination_type": destination_type, @@ -471,7 +499,7 @@ async def update( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, name: str | Omit = omit, policy: str | Omit = omit, @@ -495,12 +523,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return await self._put( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", account_id=account_id, sync_id=sync_id + ), body=await async_maybe_transform( { "description": description, @@ -523,7 +555,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -543,10 +575,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/catalog-syncs", + path_template("/accounts/{account_id}/magic/cloud/catalog-syncs", account_id=account_id), page=AsyncSinglePage[CatalogSyncListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -558,7 +592,7 @@ async def delete( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, delete_destination: 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. @@ -579,12 +613,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", account_id=account_id, sync_id=sync_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -602,7 +640,7 @@ async def edit( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, name: str | Omit = omit, policy: str | Omit = omit, @@ -626,12 +664,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", account_id=account_id, sync_id=sync_id + ), body=await async_maybe_transform( { "description": description, @@ -655,7 +697,7 @@ async def get( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -675,12 +717,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return await self._get( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}", account_id=account_id, sync_id=sync_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -695,7 +741,7 @@ async def refresh( self, sync_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -716,12 +762,18 @@ async def refresh( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sync_id: raise ValueError(f"Expected a non-empty value for `sync_id` but received {sync_id!r}") return await self._post( - f"/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}/refresh", + path_template( + "/accounts/{account_id}/magic/cloud/catalog-syncs/{sync_id}/refresh", + account_id=account_id, + sync_id=sync_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_cloud_networking/catalog_syncs/prebuilt_policies.py b/src/cloudflare/resources/magic_cloud_networking/catalog_syncs/prebuilt_policies.py index 360302ee218..84fe5ec8847 100644 --- a/src/cloudflare/resources/magic_cloud_networking/catalog_syncs/prebuilt_policies.py +++ b/src/cloudflare/resources/magic_cloud_networking/catalog_syncs/prebuilt_policies.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> PrebuiltPoliciesResourceWithStreamingRespon def list( self, *, - account_id: str, + account_id: str | None = None, destination_type: Literal["NONE", "ZERO_TRUST_LIST"] | 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. @@ -70,10 +70,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/catalog-syncs/prebuilt-policies", + path_template("/accounts/{account_id}/magic/cloud/catalog-syncs/prebuilt-policies", account_id=account_id), page=SyncSinglePage[PrebuiltPolicyListResponse], options=make_request_options( extra_headers=extra_headers, @@ -111,7 +113,7 @@ def with_streaming_response(self) -> AsyncPrebuiltPoliciesResourceWithStreamingR def list( self, *, - account_id: str, + account_id: str | None = None, destination_type: Literal["NONE", "ZERO_TRUST_LIST"] | 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. @@ -134,10 +136,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/catalog-syncs/prebuilt-policies", + path_template("/accounts/{account_id}/magic/cloud/catalog-syncs/prebuilt-policies", account_id=account_id), page=AsyncSinglePage[PrebuiltPolicyListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/magic_cloud_networking/cloud_integrations.py b/src/cloudflare/resources/magic_cloud_networking/cloud_integrations.py index 8953e359d8d..1fa5f85013d 100644 --- a/src/cloudflare/resources/magic_cloud_networking/cloud_integrations.py +++ b/src/cloudflare/resources/magic_cloud_networking/cloud_integrations.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import path_template, maybe_transform, strip_not_given, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -66,7 +66,7 @@ def with_streaming_response(self) -> CloudIntegrationsResourceWithStreamingRespo def create( self, *, - account_id: str, + account_id: str | None = None, cloud_type: Literal["AWS", "AZURE", "GOOGLE", "CLOUDFLARE"], friendly_name: str, description: str | Omit = omit, @@ -90,11 +90,13 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"forwarded": forwarded}), **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/magic/cloud/providers", + path_template("/accounts/{account_id}/magic/cloud/providers", account_id=account_id), body=maybe_transform( { "cloud_type": cloud_type, @@ -117,7 +119,7 @@ def update( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, aws_arn: str | Omit = omit, azure_subscription_id: str | Omit = omit, azure_tenant_id: str | Omit = omit, @@ -144,12 +146,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return self._put( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}", + account_id=account_id, + provider_id=provider_id, + ), body=maybe_transform( { "aws_arn": aws_arn, @@ -175,7 +183,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, cloudflare: bool | Omit = omit, desc: bool | Omit = omit, order_by: str | Omit = omit, @@ -201,10 +209,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/providers", + path_template("/accounts/{account_id}/magic/cloud/providers", account_id=account_id), page=SyncSinglePage[CloudIntegrationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -228,7 +238,7 @@ def delete( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -248,12 +258,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return self._delete( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}", + account_id=account_id, + provider_id=provider_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -268,7 +284,7 @@ def discover( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, v2: 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. @@ -289,12 +305,18 @@ def discover( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return self._post( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}/discover", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}/discover", + account_id=account_id, + provider_id=provider_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -308,7 +330,7 @@ def discover( def discover_all( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -328,10 +350,12 @@ def discover_all( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/providers/discover", + path_template("/accounts/{account_id}/magic/cloud/providers/discover", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -342,7 +366,7 @@ def edit( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, aws_arn: str | Omit = omit, azure_subscription_id: str | Omit = omit, azure_tenant_id: str | Omit = omit, @@ -369,12 +393,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return self._patch( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}", + account_id=account_id, + provider_id=provider_id, + ), body=maybe_transform( { "aws_arn": aws_arn, @@ -401,7 +431,7 @@ def get( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, status: 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. @@ -422,12 +452,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return self._get( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}", + account_id=account_id, + provider_id=provider_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -443,7 +479,7 @@ def initial_setup( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -463,6 +499,8 @@ def initial_setup( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: @@ -470,7 +508,11 @@ def initial_setup( return cast( CloudIntegrationInitialSetupResponse, self._get( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}/initial_setup", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}/initial_setup", + account_id=account_id, + provider_id=provider_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -508,7 +550,7 @@ def with_streaming_response(self) -> AsyncCloudIntegrationsResourceWithStreaming async def create( self, *, - account_id: str, + account_id: str | None = None, cloud_type: Literal["AWS", "AZURE", "GOOGLE", "CLOUDFLARE"], friendly_name: str, description: str | Omit = omit, @@ -532,11 +574,13 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"forwarded": forwarded}), **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/magic/cloud/providers", + path_template("/accounts/{account_id}/magic/cloud/providers", account_id=account_id), body=await async_maybe_transform( { "cloud_type": cloud_type, @@ -559,7 +603,7 @@ async def update( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, aws_arn: str | Omit = omit, azure_subscription_id: str | Omit = omit, azure_tenant_id: str | Omit = omit, @@ -586,12 +630,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return await self._put( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}", + account_id=account_id, + provider_id=provider_id, + ), body=await async_maybe_transform( { "aws_arn": aws_arn, @@ -617,7 +667,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, cloudflare: bool | Omit = omit, desc: bool | Omit = omit, order_by: str | Omit = omit, @@ -643,10 +693,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/providers", + path_template("/accounts/{account_id}/magic/cloud/providers", account_id=account_id), page=AsyncSinglePage[CloudIntegrationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -670,7 +722,7 @@ async def delete( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -690,12 +742,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}", + account_id=account_id, + provider_id=provider_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -710,7 +768,7 @@ async def discover( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, v2: 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. @@ -731,12 +789,18 @@ async def discover( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return await self._post( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}/discover", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}/discover", + account_id=account_id, + provider_id=provider_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -752,7 +816,7 @@ async def discover( async def discover_all( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -772,10 +836,12 @@ async def discover_all( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/providers/discover", + path_template("/accounts/{account_id}/magic/cloud/providers/discover", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -786,7 +852,7 @@ async def edit( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, aws_arn: str | Omit = omit, azure_subscription_id: str | Omit = omit, azure_tenant_id: str | Omit = omit, @@ -813,12 +879,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}", + account_id=account_id, + provider_id=provider_id, + ), body=await async_maybe_transform( { "aws_arn": aws_arn, @@ -845,7 +917,7 @@ async def get( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, status: 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. @@ -866,12 +938,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: raise ValueError(f"Expected a non-empty value for `provider_id` but received {provider_id!r}") return await self._get( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}", + account_id=account_id, + provider_id=provider_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -889,7 +967,7 @@ async def initial_setup( self, provider_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -909,6 +987,8 @@ async def initial_setup( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not provider_id: @@ -916,7 +996,11 @@ async def initial_setup( return cast( CloudIntegrationInitialSetupResponse, await self._get( - f"/accounts/{account_id}/magic/cloud/providers/{provider_id}/initial_setup", + path_template( + "/accounts/{account_id}/magic/cloud/providers/{provider_id}/initial_setup", + account_id=account_id, + provider_id=provider_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_cloud_networking/on_ramps/address_spaces.py b/src/cloudflare/resources/magic_cloud_networking/on_ramps/address_spaces.py index ea74a5cb0e0..846e7dd8cd7 100644 --- a/src/cloudflare/resources/magic_cloud_networking/on_ramps/address_spaces.py +++ b/src/cloudflare/resources/magic_cloud_networking/on_ramps/address_spaces.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> AddressSpacesResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, prefixes: 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. @@ -70,10 +70,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/onramps/magic_wan_address_space", + path_template("/accounts/{account_id}/magic/cloud/onramps/magic_wan_address_space", account_id=account_id), body=maybe_transform({"prefixes": prefixes}, address_space_update_params.AddressSpaceUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -88,7 +90,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -108,10 +110,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/onramps/magic_wan_address_space", + path_template("/accounts/{account_id}/magic/cloud/onramps/magic_wan_address_space", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -125,7 +129,7 @@ def list( def edit( self, *, - account_id: str, + account_id: str | None = None, prefixes: 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. @@ -146,10 +150,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/magic/cloud/onramps/magic_wan_address_space", + path_template("/accounts/{account_id}/magic/cloud/onramps/magic_wan_address_space", account_id=account_id), body=maybe_transform({"prefixes": prefixes}, address_space_edit_params.AddressSpaceEditParams), options=make_request_options( extra_headers=extra_headers, @@ -185,7 +191,7 @@ def with_streaming_response(self) -> AsyncAddressSpacesResourceWithStreamingResp async def update( self, *, - account_id: str, + account_id: str | None = None, prefixes: 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. @@ -206,10 +212,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/onramps/magic_wan_address_space", + path_template("/accounts/{account_id}/magic/cloud/onramps/magic_wan_address_space", account_id=account_id), body=await async_maybe_transform( {"prefixes": prefixes}, address_space_update_params.AddressSpaceUpdateParams ), @@ -226,7 +234,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -246,10 +254,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/onramps/magic_wan_address_space", + path_template("/accounts/{account_id}/magic/cloud/onramps/magic_wan_address_space", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -263,7 +273,7 @@ async def list( async def edit( self, *, - account_id: str, + account_id: str | None = None, prefixes: 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. @@ -284,10 +294,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/cloud/onramps/magic_wan_address_space", + path_template("/accounts/{account_id}/magic/cloud/onramps/magic_wan_address_space", account_id=account_id), body=await async_maybe_transform({"prefixes": prefixes}, address_space_edit_params.AddressSpaceEditParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/magic_cloud_networking/on_ramps/on_ramps.py b/src/cloudflare/resources/magic_cloud_networking/on_ramps/on_ramps.py index 3e602ee1b06..be648372058 100644 --- a/src/cloudflare/resources/magic_cloud_networking/on_ramps/on_ramps.py +++ b/src/cloudflare/resources/magic_cloud_networking/on_ramps/on_ramps.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, strip_not_given, async_maybe_transform +from ...._utils import path_template, maybe_transform, strip_not_given, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -83,7 +83,7 @@ def with_streaming_response(self) -> OnRampsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, cloud_type: Literal["AWS", "AZURE", "GOOGLE"], dynamic_routing: bool, install_routes_in_cloud: bool, @@ -125,11 +125,13 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"forwarded": forwarded}), **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/magic/cloud/onramps", + path_template("/accounts/{account_id}/magic/cloud/onramps", account_id=account_id), body=maybe_transform( { "cloud_type": cloud_type, @@ -165,7 +167,7 @@ def update( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, attached_hubs: SequenceNotStr[str] | Omit = omit, attached_vpcs: SequenceNotStr[str] | Omit = omit, description: str | Omit = omit, @@ -194,12 +196,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return self._put( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", account_id=account_id, onramp_id=onramp_id + ), body=maybe_transform( { "attached_hubs": attached_hubs, @@ -227,7 +233,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, desc: bool | Omit = omit, order_by: str | Omit = omit, status: bool | Omit = omit, @@ -253,10 +259,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/onramps", + path_template("/accounts/{account_id}/magic/cloud/onramps", account_id=account_id), page=SyncSinglePage[OnRampListResponse], options=make_request_options( extra_headers=extra_headers, @@ -280,7 +288,7 @@ def delete( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, destroy: bool | Omit = omit, force: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -302,12 +310,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return self._delete( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", account_id=account_id, onramp_id=onramp_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -329,7 +341,7 @@ def apply( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -349,12 +361,18 @@ def apply( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return self._post( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/apply", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/apply", + account_id=account_id, + onramp_id=onramp_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -365,7 +383,7 @@ def edit( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, attached_hubs: SequenceNotStr[str] | Omit = omit, attached_vpcs: SequenceNotStr[str] | Omit = omit, description: str | Omit = omit, @@ -394,12 +412,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return self._patch( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", account_id=account_id, onramp_id=onramp_id + ), body=maybe_transform( { "attached_hubs": attached_hubs, @@ -428,7 +450,7 @@ def export( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -448,13 +470,19 @@ def export( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") extra_headers = {"Accept": "application/zip", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/export", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/export", + account_id=account_id, + onramp_id=onramp_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -465,7 +493,7 @@ def get( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, planned_resources: bool | Omit = omit, post_apply_resources: bool | Omit = omit, status: bool | Omit = omit, @@ -489,12 +517,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return self._get( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", account_id=account_id, onramp_id=onramp_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -518,7 +550,7 @@ def plan( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -538,12 +570,18 @@ def plan( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return self._post( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/plan", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/plan", + account_id=account_id, + onramp_id=onramp_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -578,7 +616,7 @@ def with_streaming_response(self) -> AsyncOnRampsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, cloud_type: Literal["AWS", "AZURE", "GOOGLE"], dynamic_routing: bool, install_routes_in_cloud: bool, @@ -620,11 +658,13 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"forwarded": forwarded}), **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/magic/cloud/onramps", + path_template("/accounts/{account_id}/magic/cloud/onramps", account_id=account_id), body=await async_maybe_transform( { "cloud_type": cloud_type, @@ -660,7 +700,7 @@ async def update( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, attached_hubs: SequenceNotStr[str] | Omit = omit, attached_vpcs: SequenceNotStr[str] | Omit = omit, description: str | Omit = omit, @@ -689,12 +729,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return await self._put( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", account_id=account_id, onramp_id=onramp_id + ), body=await async_maybe_transform( { "attached_hubs": attached_hubs, @@ -722,7 +766,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, desc: bool | Omit = omit, order_by: str | Omit = omit, status: bool | Omit = omit, @@ -748,10 +792,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/onramps", + path_template("/accounts/{account_id}/magic/cloud/onramps", account_id=account_id), page=AsyncSinglePage[OnRampListResponse], options=make_request_options( extra_headers=extra_headers, @@ -775,7 +821,7 @@ async def delete( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, destroy: bool | Omit = omit, force: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -797,12 +843,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", account_id=account_id, onramp_id=onramp_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -824,7 +874,7 @@ async def apply( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -844,12 +894,18 @@ async def apply( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return await self._post( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/apply", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/apply", + account_id=account_id, + onramp_id=onramp_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -860,7 +916,7 @@ async def edit( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, attached_hubs: SequenceNotStr[str] | Omit = omit, attached_vpcs: SequenceNotStr[str] | Omit = omit, description: str | Omit = omit, @@ -889,12 +945,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", account_id=account_id, onramp_id=onramp_id + ), body=await async_maybe_transform( { "attached_hubs": attached_hubs, @@ -923,7 +983,7 @@ async def export( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -943,13 +1003,19 @@ async def export( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") extra_headers = {"Accept": "application/zip", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/export", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/export", + account_id=account_id, + onramp_id=onramp_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -960,7 +1026,7 @@ async def get( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, planned_resources: bool | Omit = omit, post_apply_resources: bool | Omit = omit, status: bool | Omit = omit, @@ -984,12 +1050,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return await self._get( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}", account_id=account_id, onramp_id=onramp_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1013,7 +1083,7 @@ async def plan( self, onramp_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1033,12 +1103,18 @@ async def plan( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not onramp_id: raise ValueError(f"Expected a non-empty value for `onramp_id` but received {onramp_id!r}") return await self._post( - f"/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/plan", + path_template( + "/accounts/{account_id}/magic/cloud/onramps/{onramp_id}/plan", + account_id=account_id, + onramp_id=onramp_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/magic_cloud_networking/resources.py b/src/cloudflare/resources/magic_cloud_networking/resources.py index a6fa0be26aa..34bf58ff884 100644 --- a/src/cloudflare/resources/magic_cloud_networking/resources.py +++ b/src/cloudflare/resources/magic_cloud_networking/resources.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -64,7 +64,7 @@ def with_streaming_response(self) -> ResourcesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, cloudflare: bool | Omit = omit, desc: bool | Omit = omit, managed: bool | Omit = omit, @@ -160,10 +160,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/resources", + path_template("/accounts/{account_id}/magic/cloud/resources", account_id=account_id), page=SyncV4PagePaginationArray[ResourceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -195,7 +197,7 @@ def list( def export( self, *, - account_id: str, + account_id: str | None = None, desc: bool | Omit = omit, order_by: str | Omit = omit, provider_id: str | Omit = omit, @@ -287,11 +289,13 @@ def export( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/magic/cloud/resources/export", + path_template("/accounts/{account_id}/magic/cloud/resources/export", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -319,7 +323,7 @@ def get( self, resource_id: str, *, - account_id: str, + account_id: str | None = None, v2: 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. @@ -340,12 +344,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not resource_id: raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") return self._get( - f"/accounts/{account_id}/magic/cloud/resources/{resource_id}", + path_template( + "/accounts/{account_id}/magic/cloud/resources/{resource_id}", + account_id=account_id, + resource_id=resource_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -360,7 +370,7 @@ def get( def policy_preview( self, *, - account_id: str, + account_id: str | None = None, policy: 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. @@ -381,10 +391,12 @@ def policy_preview( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/resources/policy-preview", + path_template("/accounts/{account_id}/magic/cloud/resources/policy-preview", account_id=account_id), body=maybe_transform({"policy": policy}, resource_policy_preview_params.ResourcePolicyPreviewParams), options=make_request_options( extra_headers=extra_headers, @@ -420,7 +432,7 @@ def with_streaming_response(self) -> AsyncResourcesResourceWithStreamingResponse def list( self, *, - account_id: str, + account_id: str | None = None, cloudflare: bool | Omit = omit, desc: bool | Omit = omit, managed: bool | Omit = omit, @@ -516,10 +528,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/resources", + path_template("/accounts/{account_id}/magic/cloud/resources", account_id=account_id), page=AsyncV4PagePaginationArray[ResourceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -551,7 +565,7 @@ def list( async def export( self, *, - account_id: str, + account_id: str | None = None, desc: bool | Omit = omit, order_by: str | Omit = omit, provider_id: str | Omit = omit, @@ -643,11 +657,13 @@ async def export( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/magic/cloud/resources/export", + path_template("/accounts/{account_id}/magic/cloud/resources/export", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -675,7 +691,7 @@ async def get( self, resource_id: str, *, - account_id: str, + account_id: str | None = None, v2: 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. @@ -696,12 +712,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not resource_id: raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") return await self._get( - f"/accounts/{account_id}/magic/cloud/resources/{resource_id}", + path_template( + "/accounts/{account_id}/magic/cloud/resources/{resource_id}", + account_id=account_id, + resource_id=resource_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -716,7 +738,7 @@ async def get( async def policy_preview( self, *, - account_id: str, + account_id: str | None = None, policy: 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. @@ -737,10 +759,12 @@ async def policy_preview( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/cloud/resources/policy-preview", + path_template("/accounts/{account_id}/magic/cloud/resources/policy-preview", account_id=account_id), body=await async_maybe_transform( {"policy": policy}, resource_policy_preview_params.ResourcePolicyPreviewParams ), diff --git a/src/cloudflare/resources/magic_network_monitoring/api.md b/src/cloudflare/resources/magic_network_monitoring/api.md new file mode 100644 index 00000000000..3f86cf66f2f --- /dev/null +++ b/src/cloudflare/resources/magic_network_monitoring/api.md @@ -0,0 +1,66 @@ +# MagicNetworkMonitoring + +## VPCFlows + +### Tokens + +Types: + +```python +from cloudflare.types.magic_network_monitoring.vpc_flows import TokenCreateResponse +``` + +Methods: + +- client.magic_network_monitoring.vpc_flows.tokens.create(\*, account_id) -> str + +## Configs + +Types: + +```python +from cloudflare.types.magic_network_monitoring import Configuration +``` + +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 + +### Full + +Methods: + +- client.magic_network_monitoring.configs.full.get(\*, account_id) -> Configuration + +## Rules + +Types: + +```python +from cloudflare.types.magic_network_monitoring import MagicNetworkMonitoringRule +``` + +Methods: + +- 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] + +### Advertisements + +Types: + +```python +from cloudflare.types.magic_network_monitoring.rules import Advertisement +``` + +Methods: + +- client.magic_network_monitoring.rules.advertisements.edit(rule_id, \*, account_id, \*\*params) -> Optional[Advertisement] diff --git a/src/cloudflare/resources/magic_network_monitoring/configs/configs.py b/src/cloudflare/resources/magic_network_monitoring/configs/configs.py index 217848dca6a..f54c165103d 100644 --- a/src/cloudflare/resources/magic_network_monitoring/configs/configs.py +++ b/src/cloudflare/resources/magic_network_monitoring/configs/configs.py @@ -15,7 +15,7 @@ AsyncFullResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -59,7 +59,7 @@ def with_streaming_response(self) -> ConfigsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, default_sampling: float, name: str, router_ips: SequenceNotStr[str] | Omit = omit, @@ -88,10 +88,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), body=maybe_transform( { "default_sampling": default_sampling, @@ -114,7 +116,7 @@ def create( def update( self, *, - account_id: str, + account_id: str | None = None, default_sampling: float, name: str, router_ips: SequenceNotStr[str] | Omit = omit, @@ -144,10 +146,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), body=maybe_transform( { "default_sampling": default_sampling, @@ -170,7 +174,7 @@ def update( def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -190,10 +194,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -207,7 +213,7 @@ def delete( def edit( self, *, - account_id: str, + account_id: str | None = None, default_sampling: float | Omit = omit, name: str | Omit = omit, router_ips: SequenceNotStr[str] | Omit = omit, @@ -236,10 +242,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), body=maybe_transform( { "default_sampling": default_sampling, @@ -262,7 +270,7 @@ def edit( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -282,10 +290,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -324,7 +334,7 @@ def with_streaming_response(self) -> AsyncConfigsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, default_sampling: float, name: str, router_ips: SequenceNotStr[str] | Omit = omit, @@ -353,10 +363,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), body=await async_maybe_transform( { "default_sampling": default_sampling, @@ -379,7 +391,7 @@ async def create( async def update( self, *, - account_id: str, + account_id: str | None = None, default_sampling: float, name: str, router_ips: SequenceNotStr[str] | Omit = omit, @@ -409,10 +421,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), body=await async_maybe_transform( { "default_sampling": default_sampling, @@ -435,7 +449,7 @@ async def update( async def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -455,10 +469,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -472,7 +488,7 @@ async def delete( async def edit( self, *, - account_id: str, + account_id: str | None = None, default_sampling: float | Omit = omit, name: str | Omit = omit, router_ips: SequenceNotStr[str] | Omit = omit, @@ -501,10 +517,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), body=await async_maybe_transform( { "default_sampling": default_sampling, @@ -527,7 +545,7 @@ async def edit( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -547,10 +565,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config", + path_template("/accounts/{account_id}/mnm/config", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_network_monitoring/configs/full.py b/src/cloudflare/resources/magic_network_monitoring/configs/full.py index c6ff6036bb7..197ae7ad775 100644 --- a/src/cloudflare/resources/magic_network_monitoring/configs/full.py +++ b/src/cloudflare/resources/magic_network_monitoring/configs/full.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> FullResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -65,10 +66,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config/full", + path_template("/accounts/{account_id}/mnm/config/full", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -103,7 +106,7 @@ def with_streaming_response(self) -> AsyncFullResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,10 +126,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/config/full", + path_template("/accounts/{account_id}/mnm/config/full", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_network_monitoring/rules/advertisements.py b/src/cloudflare/resources/magic_network_monitoring/rules/advertisements.py index 96590f760c5..9c0d8320f16 100644 --- a/src/cloudflare/resources/magic_network_monitoring/rules/advertisements.py +++ b/src/cloudflare/resources/magic_network_monitoring/rules/advertisements.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def edit( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -72,12 +72,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._patch( - f"/accounts/{account_id}/mnm/rules/{rule_id}/advertisement", + path_template( + "/accounts/{account_id}/mnm/rules/{rule_id}/advertisement", account_id=account_id, rule_id=rule_id + ), body=maybe_transform(body, advertisement_edit_params.AdvertisementEditParams), options=make_request_options( extra_headers=extra_headers, @@ -114,7 +118,7 @@ async def edit( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -138,12 +142,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._patch( - f"/accounts/{account_id}/mnm/rules/{rule_id}/advertisement", + path_template( + "/accounts/{account_id}/mnm/rules/{rule_id}/advertisement", account_id=account_id, rule_id=rule_id + ), body=await async_maybe_transform(body, advertisement_edit_params.AdvertisementEditParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/magic_network_monitoring/rules/rules.py b/src/cloudflare/resources/magic_network_monitoring/rules/rules.py index 6224f365a32..3a0f753b0ee 100644 --- a/src/cloudflare/resources/magic_network_monitoring/rules/rules.py +++ b/src/cloudflare/resources/magic_network_monitoring/rules/rules.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -61,7 +61,7 @@ def with_streaming_response(self) -> RulesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, automatic_advertisement: Optional[bool], name: str, prefixes: SequenceNotStr[str], @@ -120,10 +120,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/rules", + path_template("/accounts/{account_id}/mnm/rules", account_id=account_id), body=maybe_transform( { "automatic_advertisement": automatic_advertisement, @@ -152,7 +154,7 @@ def create( def update( self, *, - account_id: str, + account_id: str | None = None, automatic_advertisement: Optional[bool], name: str, prefixes: SequenceNotStr[str], @@ -209,10 +211,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/rules", + path_template("/accounts/{account_id}/mnm/rules", account_id=account_id), body=maybe_transform( { "automatic_advertisement": automatic_advertisement, @@ -241,7 +245,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -261,10 +265,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/rules", + path_template("/accounts/{account_id}/mnm/rules", account_id=account_id), page=SyncSinglePage[Optional[MagicNetworkMonitoringRule]], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -276,7 +282,7 @@ def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -298,12 +304,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._delete( - f"/accounts/{account_id}/mnm/rules/{rule_id}", + path_template("/accounts/{account_id}/mnm/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -318,7 +326,7 @@ def edit( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, automatic_advertisement: Optional[bool], name: str, prefixes: SequenceNotStr[str], @@ -377,12 +385,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._patch( - f"/accounts/{account_id}/mnm/rules/{rule_id}", + path_template("/accounts/{account_id}/mnm/rules/{rule_id}", account_id=account_id, rule_id=rule_id), body=maybe_transform( { "automatic_advertisement": automatic_advertisement, @@ -412,7 +422,7 @@ def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -434,12 +444,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get( - f"/accounts/{account_id}/mnm/rules/{rule_id}", + path_template("/accounts/{account_id}/mnm/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -478,7 +490,7 @@ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, automatic_advertisement: Optional[bool], name: str, prefixes: SequenceNotStr[str], @@ -537,10 +549,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/rules", + path_template("/accounts/{account_id}/mnm/rules", account_id=account_id), body=await async_maybe_transform( { "automatic_advertisement": automatic_advertisement, @@ -569,7 +583,7 @@ async def create( async def update( self, *, - account_id: str, + account_id: str | None = None, automatic_advertisement: Optional[bool], name: str, prefixes: SequenceNotStr[str], @@ -626,10 +640,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/rules", + path_template("/accounts/{account_id}/mnm/rules", account_id=account_id), body=await async_maybe_transform( { "automatic_advertisement": automatic_advertisement, @@ -658,7 +674,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -678,10 +694,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/rules", + path_template("/accounts/{account_id}/mnm/rules", account_id=account_id), page=AsyncSinglePage[Optional[MagicNetworkMonitoringRule]], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -693,7 +711,7 @@ async def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -715,12 +733,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._delete( - f"/accounts/{account_id}/mnm/rules/{rule_id}", + path_template("/accounts/{account_id}/mnm/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -735,7 +755,7 @@ async def edit( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, automatic_advertisement: Optional[bool], name: str, prefixes: SequenceNotStr[str], @@ -794,12 +814,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._patch( - f"/accounts/{account_id}/mnm/rules/{rule_id}", + path_template("/accounts/{account_id}/mnm/rules/{rule_id}", account_id=account_id, rule_id=rule_id), body=await async_maybe_transform( { "automatic_advertisement": automatic_advertisement, @@ -829,7 +851,7 @@ async def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -851,12 +873,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._get( - f"/accounts/{account_id}/mnm/rules/{rule_id}", + path_template("/accounts/{account_id}/mnm/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_network_monitoring/vpc_flows/tokens.py b/src/cloudflare/resources/magic_network_monitoring/vpc_flows/tokens.py index be0e187d9d1..ed5eef93cb2 100644 --- a/src/cloudflare/resources/magic_network_monitoring/vpc_flows/tokens.py +++ b/src/cloudflare/resources/magic_network_monitoring/vpc_flows/tokens.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> TokensResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -65,10 +66,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/vpc-flows/token", + path_template("/accounts/{account_id}/mnm/vpc-flows/token", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -103,7 +106,7 @@ def with_streaming_response(self) -> AsyncTokensResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,10 +126,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mnm/vpc-flows/token", + path_template("/accounts/{account_id}/mnm/vpc-flows/token", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/api.md b/src/cloudflare/resources/magic_transit/api.md new file mode 100644 index 00000000000..a7477a25fa8 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/api.md @@ -0,0 +1,318 @@ +# MagicTransit + +Types: + +```python +from cloudflare.types.magic_transit import HealthCheck, HealthCheckRate, HealthCheckType +``` + +## Apps + +Types: + +```python +from cloudflare.types.magic_transit import ( + AppCreateResponse, + AppUpdateResponse, + AppListResponse, + AppDeleteResponse, + AppEditResponse, +) +``` + +Methods: + +- 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[AppDeleteResponse] +- client.magic_transit.apps.edit(account_app_id, \*, account_id, \*\*params) -> Optional[AppEditResponse] + +## CfInterconnects + +Types: + +```python +from cloudflare.types.magic_transit import ( + CfInterconnectUpdateResponse, + CfInterconnectListResponse, + CfInterconnectBulkUpdateResponse, + CfInterconnectGetResponse, +) +``` + +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 + +Types: + +```python +from cloudflare.types.magic_transit import ( + GRETunnelCreateResponse, + GRETunnelUpdateResponse, + GRETunnelListResponse, + GRETunnelDeleteResponse, + GRETunnelBulkUpdateResponse, + GRETunnelGetResponse, +) +``` + +Methods: + +- client.magic_transit.gre_tunnels.create(\*, account_id, \*\*params) -> GRETunnelCreateResponse +- 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 + +Types: + +```python +from cloudflare.types.magic_transit import ( + PSKMetadata, + IPSECTunnelCreateResponse, + IPSECTunnelUpdateResponse, + IPSECTunnelListResponse, + IPSECTunnelDeleteResponse, + IPSECTunnelBulkUpdateResponse, + IPSECTunnelGetResponse, + IPSECTunnelPSKGenerateResponse, +) +``` + +Methods: + +- client.magic_transit.ipsec_tunnels.create(\*, account_id, \*\*params) -> IPSECTunnelCreateResponse +- 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 + +## Routes + +Types: + +```python +from cloudflare.types.magic_transit import ( + Scope, + RouteCreateResponse, + RouteUpdateResponse, + RouteListResponse, + RouteDeleteResponse, + RouteBulkUpdateResponse, + RouteEmptyResponse, + RouteGetResponse, +) +``` + +Methods: + +- client.magic_transit.routes.create(\*, account_id, \*\*params) -> RouteCreateResponse +- 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 + +## Sites + +Types: + +```python +from cloudflare.types.magic_transit import Site, SiteLocation +``` + +Methods: + +- client.magic_transit.sites.create(\*, account_id, \*\*params) -> Site +- client.magic_transit.sites.update(site_id, \*, account_id, \*\*params) -> Site +- client.magic_transit.sites.list(\*, account_id, \*\*params) -> SyncSinglePage[Site] +- client.magic_transit.sites.delete(site_id, \*, account_id) -> Site +- client.magic_transit.sites.edit(site_id, \*, account_id, \*\*params) -> Site +- client.magic_transit.sites.get(site_id, \*, account_id) -> Site + +### ACLs + +Types: + +```python +from cloudflare.types.magic_transit.sites import ACL, ACLConfiguration, AllowedProtocol, Subnet +``` + +Methods: + +- client.magic_transit.sites.acls.create(site_id, \*, account_id, \*\*params) -> ACL +- client.magic_transit.sites.acls.update(acl_id, \*, account_id, site_id, \*\*params) -> ACL +- client.magic_transit.sites.acls.list(site_id, \*, account_id) -> SyncSinglePage[ACL] +- client.magic_transit.sites.acls.delete(acl_id, \*, account_id, site_id) -> ACL +- client.magic_transit.sites.acls.edit(acl_id, \*, account_id, site_id, \*\*params) -> ACL +- client.magic_transit.sites.acls.get(acl_id, \*, account_id, site_id) -> ACL + +### LANs + +Types: + +```python +from cloudflare.types.magic_transit.sites import ( + DHCPRelay, + DHCPServer, + LAN, + LANStaticAddressing, + Nat, + RoutedSubnet, +) +``` + +Methods: + +- 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 +- client.magic_transit.sites.lans.edit(lan_id, \*, account_id, site_id, \*\*params) -> LAN +- client.magic_transit.sites.lans.get(lan_id, \*, account_id, site_id) -> LAN + +### WANs + +Types: + +```python +from cloudflare.types.magic_transit.sites import WAN, WANStaticAddressing +``` + +Methods: + +- 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 +- client.magic_transit.sites.wans.edit(wan_id, \*, account_id, site_id, \*\*params) -> WAN +- client.magic_transit.sites.wans.get(wan_id, \*, account_id, site_id) -> WAN + +## Connectors + +Types: + +```python +from cloudflare.types.magic_transit import ( + ConnectorCreateResponse, + ConnectorUpdateResponse, + ConnectorListResponse, + ConnectorDeleteResponse, + ConnectorEditResponse, + ConnectorGetResponse, +) +``` + +Methods: + +- 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 + +### Events + +Types: + +```python +from cloudflare.types.magic_transit.connectors import EventListResponse, EventGetResponse +``` + +Methods: + +- 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 + +#### Latest + +Types: + +```python +from cloudflare.types.magic_transit.connectors.events import LatestListResponse +``` + +Methods: + +- client.magic_transit.connectors.events.latest.list(connector_id, \*, account_id) -> LatestListResponse + +### Snapshots + +Types: + +```python +from cloudflare.types.magic_transit.connectors import SnapshotListResponse, SnapshotGetResponse +``` + +Methods: + +- 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 + +#### Latest + +Types: + +```python +from cloudflare.types.magic_transit.connectors.snapshots import LatestListResponse +``` + +Methods: + +- client.magic_transit.connectors.snapshots.latest.list(connector_id, \*, account_id) -> LatestListResponse + +## PCAPs + +Types: + +```python +from cloudflare.types.magic_transit import ( + PCAP, + PCAPFilter, + PCAPCreateResponse, + PCAPListResponse, + PCAPGetResponse, +) +``` + +Methods: + +- 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 + +### Ownership + +Types: + +```python +from cloudflare.types.magic_transit.pcaps import Ownership +``` + +Methods: + +- 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 + +### Download + +Methods: + +- client.magic_transit.pcaps.download.get(pcap_id, \*, account_id) -> BinaryAPIResponse diff --git a/src/cloudflare/resources/magic_transit/apps.py b/src/cloudflare/resources/magic_transit/apps.py index 9a394b05499..a3886e62e6b 100644 --- a/src/cloudflare/resources/magic_transit/apps.py +++ b/src/cloudflare/resources/magic_transit/apps.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> AppsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, type: str, hostnames: SequenceNotStr[str] | Omit = omit, @@ -91,10 +91,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/apps", + path_template("/accounts/{account_id}/magic/apps", account_id=account_id), body=maybe_transform( { "name": name, @@ -119,7 +121,7 @@ def update( self, account_app_id: str, *, - account_id: str, + account_id: str | None = None, hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, name: str | Omit = omit, @@ -160,12 +162,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not account_app_id: raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") return self._put( - f"/accounts/{account_id}/magic/apps/{account_app_id}", + path_template( + "/accounts/{account_id}/magic/apps/{account_app_id}", + account_id=account_id, + account_app_id=account_app_id, + ), body=maybe_transform( { "hostnames": hostnames, @@ -189,7 +197,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -211,10 +219,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/apps", + path_template("/accounts/{account_id}/magic/apps", account_id=account_id), page=SyncSinglePage[AppListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -226,7 +236,7 @@ def delete( self, account_app_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -250,12 +260,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not account_app_id: raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") return self._delete( - f"/accounts/{account_id}/magic/apps/{account_app_id}", + path_template( + "/accounts/{account_id}/magic/apps/{account_app_id}", + account_id=account_id, + account_app_id=account_app_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -270,7 +286,7 @@ def edit( self, account_app_id: str, *, - account_id: str, + account_id: str | None = None, hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, name: str | Omit = omit, @@ -311,12 +327,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not account_app_id: raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") return self._patch( - f"/accounts/{account_id}/magic/apps/{account_app_id}", + path_template( + "/accounts/{account_id}/magic/apps/{account_app_id}", + account_id=account_id, + account_app_id=account_app_id, + ), body=maybe_transform( { "hostnames": hostnames, @@ -361,7 +383,7 @@ def with_streaming_response(self) -> AsyncAppsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, type: str, hostnames: SequenceNotStr[str] | Omit = omit, @@ -400,10 +422,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/apps", + path_template("/accounts/{account_id}/magic/apps", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -428,7 +452,7 @@ async def update( self, account_app_id: str, *, - account_id: str, + account_id: str | None = None, hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, name: str | Omit = omit, @@ -469,12 +493,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not account_app_id: raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") return await self._put( - f"/accounts/{account_id}/magic/apps/{account_app_id}", + path_template( + "/accounts/{account_id}/magic/apps/{account_app_id}", + account_id=account_id, + account_app_id=account_app_id, + ), body=await async_maybe_transform( { "hostnames": hostnames, @@ -498,7 +528,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -520,10 +550,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/apps", + path_template("/accounts/{account_id}/magic/apps", account_id=account_id), page=AsyncSinglePage[AppListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -535,7 +567,7 @@ async def delete( self, account_app_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -559,12 +591,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not account_app_id: raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/apps/{account_app_id}", + path_template( + "/accounts/{account_id}/magic/apps/{account_app_id}", + account_id=account_id, + account_app_id=account_app_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -579,7 +617,7 @@ async def edit( self, account_app_id: str, *, - account_id: str, + account_id: str | None = None, hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, name: str | Omit = omit, @@ -620,12 +658,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not account_app_id: raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/apps/{account_app_id}", + path_template( + "/accounts/{account_id}/magic/apps/{account_app_id}", + account_id=account_id, + account_app_id=account_app_id, + ), body=await async_maybe_transform( { "hostnames": hostnames, diff --git a/src/cloudflare/resources/magic_transit/cf_interconnects.py b/src/cloudflare/resources/magic_transit/cf_interconnects.py index 11fef4bc6b7..c7d150e084c 100644 --- a/src/cloudflare/resources/magic_transit/cf_interconnects.py +++ b/src/cloudflare/resources/magic_transit/cf_interconnects.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def update( self, cf_interconnect_id: str, *, - account_id: str, + account_id: str | None = None, automatic_return_routing: bool | Omit = omit, description: str | Omit = omit, gre: cf_interconnect_update_params.GRE | Omit = omit, @@ -109,6 +109,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cf_interconnect_id: @@ -124,7 +126,11 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + path_template( + "/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + account_id=account_id, + cf_interconnect_id=cf_interconnect_id, + ), body=maybe_transform( { "automatic_return_routing": automatic_return_routing, @@ -151,7 +157,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -174,6 +180,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -187,7 +195,7 @@ def list( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/magic/cf_interconnects", + path_template("/accounts/{account_id}/magic/cf_interconnects", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -201,7 +209,7 @@ def list( def bulk_update( self, *, - account_id: str, + account_id: str | None = None, body: object, x_magic_new_hc_target: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -228,6 +236,8 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -241,7 +251,7 @@ def bulk_update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/magic/cf_interconnects", + path_template("/accounts/{account_id}/magic/cf_interconnects", account_id=account_id), body=maybe_transform(body, cf_interconnect_bulk_update_params.CfInterconnectBulkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -257,7 +267,7 @@ def get( self, cf_interconnect_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -282,6 +292,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cf_interconnect_id: @@ -297,7 +309,11 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + path_template( + "/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + account_id=account_id, + cf_interconnect_id=cf_interconnect_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -333,7 +349,7 @@ async def update( self, cf_interconnect_id: str, *, - account_id: str, + account_id: str | None = None, automatic_return_routing: bool | Omit = omit, description: str | Omit = omit, gre: cf_interconnect_update_params.GRE | Omit = omit, @@ -390,6 +406,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cf_interconnect_id: @@ -405,7 +423,11 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + path_template( + "/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + account_id=account_id, + cf_interconnect_id=cf_interconnect_id, + ), body=await async_maybe_transform( { "automatic_return_routing": automatic_return_routing, @@ -432,7 +454,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -455,6 +477,8 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -468,7 +492,7 @@ async def list( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/magic/cf_interconnects", + path_template("/accounts/{account_id}/magic/cf_interconnects", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -482,7 +506,7 @@ async def list( async def bulk_update( self, *, - account_id: str, + account_id: str | None = None, body: object, x_magic_new_hc_target: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -509,6 +533,8 @@ async def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -522,7 +548,7 @@ async def bulk_update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/magic/cf_interconnects", + path_template("/accounts/{account_id}/magic/cf_interconnects", account_id=account_id), body=await async_maybe_transform(body, cf_interconnect_bulk_update_params.CfInterconnectBulkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -538,7 +564,7 @@ async def get( self, cf_interconnect_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -563,6 +589,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cf_interconnect_id: @@ -578,7 +606,11 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + path_template( + "/accounts/{account_id}/magic/cf_interconnects/{cf_interconnect_id}", + account_id=account_id, + cf_interconnect_id=cf_interconnect_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/connectors/connectors.py b/src/cloudflare/resources/magic_transit/connectors/connectors.py index f757d6a4b8d..86b9c801045 100644 --- a/src/cloudflare/resources/magic_transit/connectors/connectors.py +++ b/src/cloudflare/resources/magic_transit/connectors/connectors.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -78,7 +78,7 @@ def with_streaming_response(self) -> ConnectorsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, device: connector_create_params.Device, activated: bool | Omit = omit, interrupt_window_days_of_week: List[ @@ -117,10 +117,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/connectors", + path_template("/accounts/{account_id}/magic/connectors", account_id=account_id), body=maybe_transform( { "device": device, @@ -148,7 +150,7 @@ def update( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, activated: bool | Omit = omit, interrupt_window_days_of_week: List[ Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] @@ -187,12 +189,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._put( - f"/accounts/{account_id}/magic/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}", + account_id=account_id, + connector_id=connector_id, + ), body=maybe_transform( { "activated": activated, @@ -219,7 +227,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -241,10 +249,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/connectors", + path_template("/accounts/{account_id}/magic/connectors", account_id=account_id), page=SyncSinglePage[ConnectorListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -256,7 +266,7 @@ def delete( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -278,12 +288,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._delete( - f"/accounts/{account_id}/magic/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -298,7 +314,7 @@ def edit( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, activated: bool | Omit = omit, interrupt_window_days_of_week: List[ Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] @@ -337,12 +353,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._patch( - f"/accounts/{account_id}/magic/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}", + account_id=account_id, + connector_id=connector_id, + ), body=maybe_transform( { "activated": activated, @@ -370,7 +392,7 @@ def get( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -392,12 +414,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -440,7 +468,7 @@ def with_streaming_response(self) -> AsyncConnectorsResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, device: connector_create_params.Device, activated: bool | Omit = omit, interrupt_window_days_of_week: List[ @@ -479,10 +507,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/connectors", + path_template("/accounts/{account_id}/magic/connectors", account_id=account_id), body=await async_maybe_transform( { "device": device, @@ -510,7 +540,7 @@ async def update( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, activated: bool | Omit = omit, interrupt_window_days_of_week: List[ Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] @@ -549,12 +579,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._put( - f"/accounts/{account_id}/magic/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}", + account_id=account_id, + connector_id=connector_id, + ), body=await async_maybe_transform( { "activated": activated, @@ -581,7 +617,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -603,10 +639,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/connectors", + path_template("/accounts/{account_id}/magic/connectors", account_id=account_id), page=AsyncSinglePage[ConnectorListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -618,7 +656,7 @@ async def delete( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -640,12 +678,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -660,7 +704,7 @@ async def edit( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, activated: bool | Omit = omit, interrupt_window_days_of_week: List[ Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] @@ -699,12 +743,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}", + account_id=account_id, + connector_id=connector_id, + ), body=await async_maybe_transform( { "activated": activated, @@ -732,7 +782,7 @@ async def get( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -754,12 +804,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/connectors/events/events.py b/src/cloudflare/resources/magic_transit/connectors/events/events.py index d02f170e0f5..c177e559aec 100644 --- a/src/cloudflare/resources/magic_transit/connectors/events/events.py +++ b/src/cloudflare/resources/magic_transit/connectors/events/events.py @@ -15,7 +15,7 @@ AsyncLatestResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -61,7 +61,7 @@ def list( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, from_: float, to: float, cursor: str | Omit = omit, @@ -90,12 +90,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -120,7 +126,7 @@ def get( self, event_n: float, *, - account_id: str, + account_id: str | None = None, connector_id: str, event_t: float, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -144,12 +150,20 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events/{event_t}.{event_n}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events/{event_t}.{event_n}", + account_id=account_id, + connector_id=connector_id, + event_t=event_t, + event_n=event_n, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -189,7 +203,7 @@ async def list( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, from_: float, to: float, cursor: str | Omit = omit, @@ -218,12 +232,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -248,7 +268,7 @@ async def get( self, event_n: float, *, - account_id: str, + account_id: str | None = None, connector_id: str, event_t: float, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -272,12 +292,20 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events/{event_t}.{event_n}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events/{event_t}.{event_n}", + account_id=account_id, + connector_id=connector_id, + event_t=event_t, + event_n=event_n, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/connectors/events/latest.py b/src/cloudflare/resources/magic_transit/connectors/events/latest.py index a3bec2ee768..2fa9e2caff1 100644 --- a/src/cloudflare/resources/magic_transit/connectors/events/latest.py +++ b/src/cloudflare/resources/magic_transit/connectors/events/latest.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def list( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,12 +69,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events/latest", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events/latest", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -109,7 +116,7 @@ async def list( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -131,12 +138,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events/latest", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/events/latest", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/connectors/snapshots/latest.py b/src/cloudflare/resources/magic_transit/connectors/snapshots/latest.py index 6f682411445..0bf0132b619 100644 --- a/src/cloudflare/resources/magic_transit/connectors/snapshots/latest.py +++ b/src/cloudflare/resources/magic_transit/connectors/snapshots/latest.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def list( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,12 +69,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots/latest", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots/latest", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -109,7 +116,7 @@ async def list( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -131,12 +138,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots/latest", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots/latest", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/connectors/snapshots/snapshots.py b/src/cloudflare/resources/magic_transit/connectors/snapshots/snapshots.py index 6a2d8029801..f54e7f372df 100644 --- a/src/cloudflare/resources/magic_transit/connectors/snapshots/snapshots.py +++ b/src/cloudflare/resources/magic_transit/connectors/snapshots/snapshots.py @@ -15,7 +15,7 @@ AsyncLatestResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -61,7 +61,7 @@ def list( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, from_: float, to: float, cursor: str | Omit = omit, @@ -87,12 +87,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -116,7 +122,7 @@ def get( self, snapshot_t: float, *, - account_id: str, + account_id: str | None = None, connector_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. @@ -139,12 +145,19 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots/{snapshot_t}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots/{snapshot_t}", + account_id=account_id, + connector_id=connector_id, + snapshot_t=snapshot_t, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -184,7 +197,7 @@ async def list( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, from_: float, to: float, cursor: str | Omit = omit, @@ -210,12 +223,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots", + account_id=account_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -239,7 +258,7 @@ async def get( self, snapshot_t: float, *, - account_id: str, + account_id: str | None = None, connector_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. @@ -262,12 +281,19 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( - f"/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots/{snapshot_t}", + path_template( + "/accounts/{account_id}/magic/connectors/{connector_id}/telemetry/snapshots/{snapshot_t}", + account_id=account_id, + connector_id=connector_id, + snapshot_t=snapshot_t, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/gre_tunnels.py b/src/cloudflare/resources/magic_transit/gre_tunnels.py index ffd5ac90504..5fca90a33d7 100644 --- a/src/cloudflare/resources/magic_transit/gre_tunnels.py +++ b/src/cloudflare/resources/magic_transit/gre_tunnels.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> GRETunnelsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, cloudflare_gre_endpoint: str, customer_gre_endpoint: str, interface_address: str, @@ -114,6 +114,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -127,7 +129,7 @@ def create( **(extra_headers or {}), } return self._post( - f"/accounts/{account_id}/magic/gre_tunnels", + path_template("/accounts/{account_id}/magic/gre_tunnels", account_id=account_id), body=maybe_transform( { "cloudflare_gre_endpoint": cloudflare_gre_endpoint, @@ -158,7 +160,7 @@ def update( self, gre_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, cloudflare_gre_endpoint: str, customer_gre_endpoint: str, interface_address: str, @@ -221,6 +223,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gre_tunnel_id: @@ -236,7 +240,11 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + account_id=account_id, + gre_tunnel_id=gre_tunnel_id, + ), body=maybe_transform( { "cloudflare_gre_endpoint": cloudflare_gre_endpoint, @@ -265,7 +273,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -288,6 +296,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -301,7 +311,7 @@ def list( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/magic/gre_tunnels", + path_template("/accounts/{account_id}/magic/gre_tunnels", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -316,7 +326,7 @@ def delete( self, gre_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -343,6 +353,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gre_tunnel_id: @@ -358,7 +370,11 @@ def delete( **(extra_headers or {}), } return self._delete( - f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + account_id=account_id, + gre_tunnel_id=gre_tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -372,7 +388,7 @@ def delete( def bulk_update( self, *, - account_id: str, + account_id: str | None = None, body: object, x_magic_new_hc_target: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -398,6 +414,8 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -411,7 +429,7 @@ def bulk_update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/magic/gre_tunnels", + path_template("/accounts/{account_id}/magic/gre_tunnels", account_id=account_id), body=maybe_transform(body, gre_tunnel_bulk_update_params.GRETunnelBulkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -427,7 +445,7 @@ def get( self, gre_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -452,6 +470,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gre_tunnel_id: @@ -467,7 +487,11 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + account_id=account_id, + gre_tunnel_id=gre_tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -502,7 +526,7 @@ def with_streaming_response(self) -> AsyncGRETunnelsResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, cloudflare_gre_endpoint: str, customer_gre_endpoint: str, interface_address: str, @@ -564,6 +588,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -577,7 +603,7 @@ async def create( **(extra_headers or {}), } return await self._post( - f"/accounts/{account_id}/magic/gre_tunnels", + path_template("/accounts/{account_id}/magic/gre_tunnels", account_id=account_id), body=await async_maybe_transform( { "cloudflare_gre_endpoint": cloudflare_gre_endpoint, @@ -608,7 +634,7 @@ async def update( self, gre_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, cloudflare_gre_endpoint: str, customer_gre_endpoint: str, interface_address: str, @@ -671,6 +697,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gre_tunnel_id: @@ -686,7 +714,11 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + account_id=account_id, + gre_tunnel_id=gre_tunnel_id, + ), body=await async_maybe_transform( { "cloudflare_gre_endpoint": cloudflare_gre_endpoint, @@ -715,7 +747,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -738,6 +770,8 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -751,7 +785,7 @@ async def list( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/magic/gre_tunnels", + path_template("/accounts/{account_id}/magic/gre_tunnels", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -766,7 +800,7 @@ async def delete( self, gre_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -793,6 +827,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gre_tunnel_id: @@ -808,7 +844,11 @@ async def delete( **(extra_headers or {}), } return await self._delete( - f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + account_id=account_id, + gre_tunnel_id=gre_tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -822,7 +862,7 @@ async def delete( async def bulk_update( self, *, - account_id: str, + account_id: str | None = None, body: object, x_magic_new_hc_target: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -848,6 +888,8 @@ async def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -861,7 +903,7 @@ async def bulk_update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/magic/gre_tunnels", + path_template("/accounts/{account_id}/magic/gre_tunnels", account_id=account_id), body=await async_maybe_transform(body, gre_tunnel_bulk_update_params.GRETunnelBulkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -877,7 +919,7 @@ async def get( self, gre_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -902,6 +944,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not gre_tunnel_id: @@ -917,7 +961,11 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}", + account_id=account_id, + gre_tunnel_id=gre_tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/ipsec_tunnels.py b/src/cloudflare/resources/magic_transit/ipsec_tunnels.py index e12f29bb249..69b3a382f8c 100644 --- a/src/cloudflare/resources/magic_transit/ipsec_tunnels.py +++ b/src/cloudflare/resources/magic_transit/ipsec_tunnels.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -58,7 +58,7 @@ def with_streaming_response(self) -> IPSECTunnelsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, cloudflare_endpoint: str, interface_address: str, name: str, @@ -122,6 +122,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -135,7 +137,7 @@ def create( **(extra_headers or {}), } return self._post( - f"/accounts/{account_id}/magic/ipsec_tunnels", + path_template("/accounts/{account_id}/magic/ipsec_tunnels", account_id=account_id), body=maybe_transform( { "cloudflare_endpoint": cloudflare_endpoint, @@ -167,7 +169,7 @@ def update( self, ipsec_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, cloudflare_endpoint: str, interface_address: str, name: str, @@ -233,6 +235,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ipsec_tunnel_id: @@ -248,7 +252,11 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + account_id=account_id, + ipsec_tunnel_id=ipsec_tunnel_id, + ), body=maybe_transform( { "cloudflare_endpoint": cloudflare_endpoint, @@ -279,7 +287,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -302,6 +310,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -315,7 +325,7 @@ def list( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/magic/ipsec_tunnels", + path_template("/accounts/{account_id}/magic/ipsec_tunnels", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -330,7 +340,7 @@ def delete( self, ipsec_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -357,6 +367,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ipsec_tunnel_id: @@ -372,7 +384,11 @@ def delete( **(extra_headers or {}), } return self._delete( - f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + account_id=account_id, + ipsec_tunnel_id=ipsec_tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -386,7 +402,7 @@ def delete( def bulk_update( self, *, - account_id: str, + account_id: str | None = None, body: object, x_magic_new_hc_target: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -413,6 +429,8 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -426,7 +444,7 @@ def bulk_update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/magic/ipsec_tunnels", + path_template("/accounts/{account_id}/magic/ipsec_tunnels", account_id=account_id), body=maybe_transform(body, ipsec_tunnel_bulk_update_params.IPSECTunnelBulkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -442,7 +460,7 @@ def get( self, ipsec_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -467,6 +485,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ipsec_tunnel_id: @@ -482,7 +502,11 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + account_id=account_id, + ipsec_tunnel_id=ipsec_tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -497,7 +521,7 @@ def psk_generate( self, ipsec_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -526,12 +550,18 @@ def psk_generate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ipsec_tunnel_id: raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") return self._post( - f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}/psk_generate", + path_template( + "/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}/psk_generate", + account_id=account_id, + ipsec_tunnel_id=ipsec_tunnel_id, + ), body=maybe_transform(body, ipsec_tunnel_psk_generate_params.IPSECTunnelPSKGenerateParams), options=make_request_options( extra_headers=extra_headers, @@ -567,7 +597,7 @@ def with_streaming_response(self) -> AsyncIPSECTunnelsResourceWithStreamingRespo async def create( self, *, - account_id: str, + account_id: str | None = None, cloudflare_endpoint: str, interface_address: str, name: str, @@ -631,6 +661,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -644,7 +676,7 @@ async def create( **(extra_headers or {}), } return await self._post( - f"/accounts/{account_id}/magic/ipsec_tunnels", + path_template("/accounts/{account_id}/magic/ipsec_tunnels", account_id=account_id), body=await async_maybe_transform( { "cloudflare_endpoint": cloudflare_endpoint, @@ -676,7 +708,7 @@ async def update( self, ipsec_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, cloudflare_endpoint: str, interface_address: str, name: str, @@ -742,6 +774,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ipsec_tunnel_id: @@ -757,7 +791,11 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + account_id=account_id, + ipsec_tunnel_id=ipsec_tunnel_id, + ), body=await async_maybe_transform( { "cloudflare_endpoint": cloudflare_endpoint, @@ -788,7 +826,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -811,6 +849,8 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -824,7 +864,7 @@ async def list( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/magic/ipsec_tunnels", + path_template("/accounts/{account_id}/magic/ipsec_tunnels", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -839,7 +879,7 @@ async def delete( self, ipsec_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -866,6 +906,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ipsec_tunnel_id: @@ -881,7 +923,11 @@ async def delete( **(extra_headers or {}), } return await self._delete( - f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + account_id=account_id, + ipsec_tunnel_id=ipsec_tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -895,7 +941,7 @@ async def delete( async def bulk_update( self, *, - account_id: str, + account_id: str | None = None, body: object, x_magic_new_hc_target: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -922,6 +968,8 @@ async def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -935,7 +983,7 @@ async def bulk_update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/magic/ipsec_tunnels", + path_template("/accounts/{account_id}/magic/ipsec_tunnels", account_id=account_id), body=await async_maybe_transform(body, ipsec_tunnel_bulk_update_params.IPSECTunnelBulkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -951,7 +999,7 @@ async def get( self, ipsec_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -976,6 +1024,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ipsec_tunnel_id: @@ -991,7 +1041,11 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + path_template( + "/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}", + account_id=account_id, + ipsec_tunnel_id=ipsec_tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1006,7 +1060,7 @@ async def psk_generate( self, ipsec_tunnel_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -1035,12 +1089,18 @@ async def psk_generate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ipsec_tunnel_id: raise ValueError(f"Expected a non-empty value for `ipsec_tunnel_id` but received {ipsec_tunnel_id!r}") return await self._post( - f"/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}/psk_generate", + path_template( + "/accounts/{account_id}/magic/ipsec_tunnels/{ipsec_tunnel_id}/psk_generate", + account_id=account_id, + ipsec_tunnel_id=ipsec_tunnel_id, + ), body=await async_maybe_transform(body, ipsec_tunnel_psk_generate_params.IPSECTunnelPSKGenerateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/magic_transit/pcaps/download.py b/src/cloudflare/resources/magic_transit/pcaps/download.py index 780af5ba4ce..5fe1df8c155 100644 --- a/src/cloudflare/resources/magic_transit/pcaps/download.py +++ b/src/cloudflare/resources/magic_transit/pcaps/download.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +47,7 @@ def get( self, pcap_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -71,13 +72,15 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pcap_id: raise ValueError(f"Expected a non-empty value for `pcap_id` but received {pcap_id!r}") extra_headers = {"Accept": "application/vnd.tcpdump.pcap", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/pcaps/{pcap_id}/download", + path_template("/accounts/{account_id}/pcaps/{pcap_id}/download", account_id=account_id, pcap_id=pcap_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -109,7 +112,7 @@ async def get( self, pcap_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -134,13 +137,15 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pcap_id: raise ValueError(f"Expected a non-empty value for `pcap_id` but received {pcap_id!r}") extra_headers = {"Accept": "application/vnd.tcpdump.pcap", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/pcaps/{pcap_id}/download", + path_template("/accounts/{account_id}/pcaps/{pcap_id}/download", account_id=account_id, pcap_id=pcap_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/magic_transit/pcaps/ownership.py b/src/cloudflare/resources/magic_transit/pcaps/ownership.py index 76e096bbcfd..7c705d53b6a 100644 --- a/src/cloudflare/resources/magic_transit/pcaps/ownership.py +++ b/src/cloudflare/resources/magic_transit/pcaps/ownership.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NoneType, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> OwnershipResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, destination_conf: 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. @@ -73,10 +73,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pcaps/ownership", + path_template("/accounts/{account_id}/pcaps/ownership", account_id=account_id), body=maybe_transform({"destination_conf": destination_conf}, ownership_create_params.OwnershipCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -92,7 +94,7 @@ def delete( self, ownership_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -116,13 +118,19 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ownership_id: raise ValueError(f"Expected a non-empty value for `ownership_id` but received {ownership_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/pcaps/ownership/{ownership_id}", + path_template( + "/accounts/{account_id}/pcaps/ownership/{ownership_id}", + account_id=account_id, + ownership_id=ownership_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -132,7 +140,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -154,10 +162,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pcaps/ownership", + path_template("/accounts/{account_id}/pcaps/ownership", account_id=account_id), page=SyncSinglePage[Ownership], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -168,7 +178,7 @@ def get( def validate( self, *, - account_id: str, + account_id: str | None = None, destination_conf: str, ownership_challenge: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -196,10 +206,12 @@ def validate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pcaps/ownership/validate", + path_template("/accounts/{account_id}/pcaps/ownership/validate", account_id=account_id), body=maybe_transform( { "destination_conf": destination_conf, @@ -241,7 +253,7 @@ def with_streaming_response(self) -> AsyncOwnershipResourceWithStreamingResponse async def create( self, *, - account_id: str, + account_id: str | None = None, destination_conf: 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. @@ -266,10 +278,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pcaps/ownership", + path_template("/accounts/{account_id}/pcaps/ownership", account_id=account_id), body=await async_maybe_transform( {"destination_conf": destination_conf}, ownership_create_params.OwnershipCreateParams ), @@ -287,7 +301,7 @@ async def delete( self, ownership_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -311,13 +325,19 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ownership_id: raise ValueError(f"Expected a non-empty value for `ownership_id` but received {ownership_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/pcaps/ownership/{ownership_id}", + path_template( + "/accounts/{account_id}/pcaps/ownership/{ownership_id}", + account_id=account_id, + ownership_id=ownership_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -327,7 +347,7 @@ async def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -349,10 +369,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pcaps/ownership", + path_template("/accounts/{account_id}/pcaps/ownership", account_id=account_id), page=AsyncSinglePage[Ownership], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -363,7 +385,7 @@ def get( async def validate( self, *, - account_id: str, + account_id: str | None = None, destination_conf: str, ownership_challenge: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -391,10 +413,12 @@ async def validate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pcaps/ownership/validate", + path_template("/accounts/{account_id}/pcaps/ownership/validate", account_id=account_id), body=await async_maybe_transform( { "destination_conf": destination_conf, diff --git a/src/cloudflare/resources/magic_transit/pcaps/pcaps.py b/src/cloudflare/resources/magic_transit/pcaps/pcaps.py index 27d7c351c5f..2399e9b383b 100644 --- a/src/cloudflare/resources/magic_transit/pcaps/pcaps.py +++ b/src/cloudflare/resources/magic_transit/pcaps/pcaps.py @@ -17,7 +17,7 @@ AsyncDownloadResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ...._utils import required_args, maybe_transform, async_maybe_transform +from ...._utils import path_template, required_args, maybe_transform, async_maybe_transform from .ownership import ( OwnershipResource, AsyncOwnershipResource, @@ -78,7 +78,7 @@ def with_streaming_response(self) -> PCAPsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, packet_limit: float, system: Literal["magic-transit"], time_limit: float, @@ -126,7 +126,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, colo_name: str, destination_conf: str, system: Literal["magic-transit"], @@ -179,13 +179,13 @@ def create( ... @required_args( - ["account_id", "packet_limit", "system", "time_limit", "type"], - ["account_id", "colo_name", "destination_conf", "system", "time_limit", "type"], + ["packet_limit", "system", "time_limit", "type"], + ["colo_name", "destination_conf", "system", "time_limit", "type"], ) def create( self, *, - account_id: str, + account_id: str | None = None, packet_limit: float | Omit = omit, system: Literal["magic-transit"], time_limit: float, @@ -202,12 +202,14 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PCAPCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( PCAPCreateResponse, self._post( - f"/accounts/{account_id}/pcaps", + path_template("/accounts/{account_id}/pcaps", account_id=account_id), body=maybe_transform( { "packet_limit": packet_limit, @@ -238,7 +240,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -260,10 +262,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pcaps", + path_template("/accounts/{account_id}/pcaps", account_id=account_id), page=SyncSinglePage[PCAPListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -275,7 +279,7 @@ def get( self, pcap_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -299,6 +303,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pcap_id: @@ -306,7 +312,7 @@ def get( return cast( PCAPGetResponse, self._get( - f"/accounts/{account_id}/pcaps/{pcap_id}", + path_template("/accounts/{account_id}/pcaps/{pcap_id}", account_id=account_id, pcap_id=pcap_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -324,7 +330,7 @@ def stop( self, pcap_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -348,13 +354,15 @@ def stop( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pcap_id: raise ValueError(f"Expected a non-empty value for `pcap_id` but received {pcap_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._put( - f"/accounts/{account_id}/pcaps/{pcap_id}/stop", + path_template("/accounts/{account_id}/pcaps/{pcap_id}/stop", account_id=account_id, pcap_id=pcap_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -394,7 +402,7 @@ def with_streaming_response(self) -> AsyncPCAPsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, packet_limit: float, system: Literal["magic-transit"], time_limit: float, @@ -442,7 +450,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, colo_name: str, destination_conf: str, system: Literal["magic-transit"], @@ -495,13 +503,13 @@ async def create( ... @required_args( - ["account_id", "packet_limit", "system", "time_limit", "type"], - ["account_id", "colo_name", "destination_conf", "system", "time_limit", "type"], + ["packet_limit", "system", "time_limit", "type"], + ["colo_name", "destination_conf", "system", "time_limit", "type"], ) async def create( self, *, - account_id: str, + account_id: str | None = None, packet_limit: float | Omit = omit, system: Literal["magic-transit"], time_limit: float, @@ -518,12 +526,14 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PCAPCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( PCAPCreateResponse, await self._post( - f"/accounts/{account_id}/pcaps", + path_template("/accounts/{account_id}/pcaps", account_id=account_id), body=await async_maybe_transform( { "packet_limit": packet_limit, @@ -554,7 +564,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -576,10 +586,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pcaps", + path_template("/accounts/{account_id}/pcaps", account_id=account_id), page=AsyncSinglePage[PCAPListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -591,7 +603,7 @@ async def get( self, pcap_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -615,6 +627,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pcap_id: @@ -622,7 +636,7 @@ async def get( return cast( PCAPGetResponse, await self._get( - f"/accounts/{account_id}/pcaps/{pcap_id}", + path_template("/accounts/{account_id}/pcaps/{pcap_id}", account_id=account_id, pcap_id=pcap_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -640,7 +654,7 @@ async def stop( self, pcap_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -664,13 +678,15 @@ async def stop( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pcap_id: raise ValueError(f"Expected a non-empty value for `pcap_id` but received {pcap_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._put( - f"/accounts/{account_id}/pcaps/{pcap_id}/stop", + path_template("/accounts/{account_id}/pcaps/{pcap_id}/stop", account_id=account_id, pcap_id=pcap_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/magic_transit/routes.py b/src/cloudflare/resources/magic_transit/routes.py index b38cd58d58e..c084ca2372a 100644 --- a/src/cloudflare/resources/magic_transit/routes.py +++ b/src/cloudflare/resources/magic_transit/routes.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -54,7 +54,7 @@ def with_streaming_response(self) -> RoutesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, nexthop: str, prefix: str, priority: int, @@ -96,10 +96,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/routes", + path_template("/accounts/{account_id}/magic/routes", account_id=account_id), body=maybe_transform( { "nexthop": nexthop, @@ -125,7 +127,7 @@ def update( self, route_id: str, *, - account_id: str, + account_id: str | None = None, nexthop: str, prefix: str, priority: int, @@ -169,12 +171,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._put( - f"/accounts/{account_id}/magic/routes/{route_id}", + path_template("/accounts/{account_id}/magic/routes/{route_id}", account_id=account_id, route_id=route_id), body=maybe_transform( { "nexthop": nexthop, @@ -199,7 +203,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -221,10 +225,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/routes", + path_template("/accounts/{account_id}/magic/routes", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -239,7 +245,7 @@ def delete( self, route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -263,12 +269,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._delete( - f"/accounts/{account_id}/magic/routes/{route_id}", + path_template("/accounts/{account_id}/magic/routes/{route_id}", account_id=account_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -282,7 +290,7 @@ def delete( def bulk_update( self, *, - account_id: str, + account_id: str | None = None, routes: Iterable[route_bulk_update_params.Route], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -308,10 +316,12 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/routes", + path_template("/accounts/{account_id}/magic/routes", account_id=account_id), body=maybe_transform({"routes": routes}, route_bulk_update_params.RouteBulkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -326,7 +336,7 @@ def bulk_update( def empty( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -348,10 +358,12 @@ def empty( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/routes", + path_template("/accounts/{account_id}/magic/routes", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -366,7 +378,7 @@ def get( self, route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -390,12 +402,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._get( - f"/accounts/{account_id}/magic/routes/{route_id}", + path_template("/accounts/{account_id}/magic/routes/{route_id}", account_id=account_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -430,7 +444,7 @@ def with_streaming_response(self) -> AsyncRoutesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, nexthop: str, prefix: str, priority: int, @@ -472,10 +486,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/routes", + path_template("/accounts/{account_id}/magic/routes", account_id=account_id), body=await async_maybe_transform( { "nexthop": nexthop, @@ -501,7 +517,7 @@ async def update( self, route_id: str, *, - account_id: str, + account_id: str | None = None, nexthop: str, prefix: str, priority: int, @@ -545,12 +561,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._put( - f"/accounts/{account_id}/magic/routes/{route_id}", + path_template("/accounts/{account_id}/magic/routes/{route_id}", account_id=account_id, route_id=route_id), body=await async_maybe_transform( { "nexthop": nexthop, @@ -575,7 +593,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -597,10 +615,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/routes", + path_template("/accounts/{account_id}/magic/routes", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -615,7 +635,7 @@ async def delete( self, route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -639,12 +659,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/routes/{route_id}", + path_template("/accounts/{account_id}/magic/routes/{route_id}", account_id=account_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -658,7 +680,7 @@ async def delete( async def bulk_update( self, *, - account_id: str, + account_id: str | None = None, routes: Iterable[route_bulk_update_params.Route], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -684,10 +706,12 @@ async def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/routes", + path_template("/accounts/{account_id}/magic/routes", account_id=account_id), body=await async_maybe_transform({"routes": routes}, route_bulk_update_params.RouteBulkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -702,7 +726,7 @@ async def bulk_update( async def empty( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -724,10 +748,12 @@ async def empty( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/routes", + path_template("/accounts/{account_id}/magic/routes", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -742,7 +768,7 @@ async def get( self, route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -766,12 +792,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._get( - f"/accounts/{account_id}/magic/routes/{route_id}", + path_template("/accounts/{account_id}/magic/routes/{route_id}", account_id=account_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/sites/acls.py b/src/cloudflare/resources/magic_transit/sites/acls.py index 309e9a5c9ac..65c5b44d1ac 100644 --- a/src/cloudflare/resources/magic_transit/sites/acls.py +++ b/src/cloudflare/resources/magic_transit/sites/acls.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def create( self, site_id: str, *, - account_id: str, + account_id: str | None = None, lan_1: ACLConfigurationParam, lan_2: ACLConfigurationParam, name: str, @@ -95,12 +95,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._post( - f"/accounts/{account_id}/magic/sites/{site_id}/acls", + path_template("/accounts/{account_id}/magic/sites/{site_id}/acls", account_id=account_id, site_id=site_id), body=maybe_transform( { "lan_1": lan_1, @@ -127,7 +129,7 @@ def update( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, description: str | Omit = omit, forward_locally: bool | Omit = omit, @@ -174,6 +176,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -181,7 +185,12 @@ def update( if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return self._put( - f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + account_id=account_id, + site_id=site_id, + acl_id=acl_id, + ), body=maybe_transform( { "description": description, @@ -208,7 +217,7 @@ def list( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -232,12 +241,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/acls", + path_template("/accounts/{account_id}/magic/sites/{site_id}/acls", account_id=account_id, site_id=site_id), page=SyncSinglePage[ACL], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -249,7 +260,7 @@ def delete( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -276,6 +287,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -283,7 +296,12 @@ def delete( if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + account_id=account_id, + site_id=site_id, + acl_id=acl_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -298,7 +316,7 @@ def edit( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, description: str | Omit = omit, forward_locally: bool | Omit = omit, @@ -345,6 +363,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -352,7 +372,12 @@ def edit( if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return self._patch( - f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + account_id=account_id, + site_id=site_id, + acl_id=acl_id, + ), body=maybe_transform( { "description": description, @@ -379,7 +404,7 @@ def get( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -406,6 +431,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -413,7 +440,12 @@ def get( if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return self._get( - f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + account_id=account_id, + site_id=site_id, + acl_id=acl_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -449,7 +481,7 @@ async def create( self, site_id: str, *, - account_id: str, + account_id: str | None = None, lan_1: ACLConfigurationParam, lan_2: ACLConfigurationParam, name: str, @@ -493,12 +525,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return await self._post( - f"/accounts/{account_id}/magic/sites/{site_id}/acls", + path_template("/accounts/{account_id}/magic/sites/{site_id}/acls", account_id=account_id, site_id=site_id), body=await async_maybe_transform( { "lan_1": lan_1, @@ -525,7 +559,7 @@ async def update( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, description: str | Omit = omit, forward_locally: bool | Omit = omit, @@ -572,6 +606,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -579,7 +615,12 @@ async def update( if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return await self._put( - f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + account_id=account_id, + site_id=site_id, + acl_id=acl_id, + ), body=await async_maybe_transform( { "description": description, @@ -606,7 +647,7 @@ def list( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -630,12 +671,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/acls", + path_template("/accounts/{account_id}/magic/sites/{site_id}/acls", account_id=account_id, site_id=site_id), page=AsyncSinglePage[ACL], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -647,7 +690,7 @@ async def delete( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -674,6 +717,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -681,7 +726,12 @@ async def delete( if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + account_id=account_id, + site_id=site_id, + acl_id=acl_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -696,7 +746,7 @@ async def edit( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, description: str | Omit = omit, forward_locally: bool | Omit = omit, @@ -743,6 +793,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -750,7 +802,12 @@ async def edit( if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + account_id=account_id, + site_id=site_id, + acl_id=acl_id, + ), body=await async_maybe_transform( { "description": description, @@ -777,7 +834,7 @@ async def get( self, acl_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -804,6 +861,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -811,7 +870,12 @@ async def get( if not acl_id: raise ValueError(f"Expected a non-empty value for `acl_id` but received {acl_id!r}") return await self._get( - f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}", + account_id=account_id, + site_id=site_id, + acl_id=acl_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/sites/lans.py b/src/cloudflare/resources/magic_transit/sites/lans.py index baab5990753..abdf0f6d2b2 100644 --- a/src/cloudflare/resources/magic_transit/sites/lans.py +++ b/src/cloudflare/resources/magic_transit/sites/lans.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -56,7 +56,7 @@ def create( self, site_id: str, *, - account_id: str, + account_id: str | None = None, bond_id: int | Omit = omit, ha_link: bool | Omit = omit, is_breakout: bool | Omit = omit, @@ -105,12 +105,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/lans", + path_template("/accounts/{account_id}/magic/sites/{site_id}/lans", account_id=account_id, site_id=site_id), page=SyncSinglePage[LAN], body=maybe_transform( { @@ -138,7 +140,7 @@ def update( self, lan_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, bond_id: int | Omit = omit, is_breakout: bool | Omit = omit, @@ -184,6 +186,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -191,7 +195,12 @@ def update( if not lan_id: raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") return self._put( - f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + account_id=account_id, + site_id=site_id, + lan_id=lan_id, + ), body=maybe_transform( { "bond_id": bond_id, @@ -220,7 +229,7 @@ def list( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -244,12 +253,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/lans", + path_template("/accounts/{account_id}/magic/sites/{site_id}/lans", account_id=account_id, site_id=site_id), page=SyncSinglePage[LAN], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -261,7 +272,7 @@ def delete( self, lan_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -288,6 +299,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -295,7 +308,12 @@ def delete( if not lan_id: raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") return self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + account_id=account_id, + site_id=site_id, + lan_id=lan_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -310,7 +328,7 @@ def edit( self, lan_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, bond_id: int | Omit = omit, is_breakout: bool | Omit = omit, @@ -356,6 +374,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -363,7 +383,12 @@ def edit( if not lan_id: raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") return self._patch( - f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + account_id=account_id, + site_id=site_id, + lan_id=lan_id, + ), body=maybe_transform( { "bond_id": bond_id, @@ -392,7 +417,7 @@ def get( self, lan_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -419,6 +444,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -426,7 +453,12 @@ def get( if not lan_id: raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") return self._get( - f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + account_id=account_id, + site_id=site_id, + lan_id=lan_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -462,7 +494,7 @@ def create( self, site_id: str, *, - account_id: str, + account_id: str | None = None, bond_id: int | Omit = omit, ha_link: bool | Omit = omit, is_breakout: bool | Omit = omit, @@ -511,12 +543,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/lans", + path_template("/accounts/{account_id}/magic/sites/{site_id}/lans", account_id=account_id, site_id=site_id), page=AsyncSinglePage[LAN], body=maybe_transform( { @@ -544,7 +578,7 @@ async def update( self, lan_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, bond_id: int | Omit = omit, is_breakout: bool | Omit = omit, @@ -590,6 +624,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -597,7 +633,12 @@ async def update( if not lan_id: raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") return await self._put( - f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + account_id=account_id, + site_id=site_id, + lan_id=lan_id, + ), body=await async_maybe_transform( { "bond_id": bond_id, @@ -626,7 +667,7 @@ def list( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -650,12 +691,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/lans", + path_template("/accounts/{account_id}/magic/sites/{site_id}/lans", account_id=account_id, site_id=site_id), page=AsyncSinglePage[LAN], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -667,7 +710,7 @@ async def delete( self, lan_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -694,6 +737,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -701,7 +746,12 @@ async def delete( if not lan_id: raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + account_id=account_id, + site_id=site_id, + lan_id=lan_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -716,7 +766,7 @@ async def edit( self, lan_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, bond_id: int | Omit = omit, is_breakout: bool | Omit = omit, @@ -762,6 +812,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -769,7 +821,12 @@ async def edit( if not lan_id: raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + account_id=account_id, + site_id=site_id, + lan_id=lan_id, + ), body=await async_maybe_transform( { "bond_id": bond_id, @@ -798,7 +855,7 @@ async def get( self, lan_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -825,6 +882,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -832,7 +891,12 @@ async def get( if not lan_id: raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") return await self._get( - f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + account_id=account_id, + site_id=site_id, + lan_id=lan_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites.py index cc3cb96bf58..6c1ddf1ce31 100644 --- a/src/cloudflare/resources/magic_transit/sites/sites.py +++ b/src/cloudflare/resources/magic_transit/sites/sites.py @@ -31,7 +31,7 @@ AsyncWANsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ...._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -90,7 +90,7 @@ def with_streaming_response(self) -> SitesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, connector_id: str | Omit = omit, description: str | Omit = omit, @@ -129,10 +129,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/sites", + path_template("/accounts/{account_id}/magic/sites", account_id=account_id), body=maybe_transform( { "name": name, @@ -158,7 +160,7 @@ def update( self, site_id: str, *, - account_id: str, + account_id: str | None = None, connector_id: str | Omit = omit, description: str | Omit = omit, location: SiteLocationParam | Omit = omit, @@ -195,12 +197,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._put( - f"/accounts/{account_id}/magic/sites/{site_id}", + path_template("/accounts/{account_id}/magic/sites/{site_id}", account_id=account_id, site_id=site_id), body=maybe_transform( { "connector_id": connector_id, @@ -224,7 +228,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, connectorid: 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. @@ -252,10 +256,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/sites", + path_template("/accounts/{account_id}/magic/sites", account_id=account_id), page=SyncSinglePage[Site], options=make_request_options( extra_headers=extra_headers, @@ -271,7 +277,7 @@ def delete( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -295,12 +301,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}", + path_template("/accounts/{account_id}/magic/sites/{site_id}", account_id=account_id, site_id=site_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -315,7 +323,7 @@ def edit( self, site_id: str, *, - account_id: str, + account_id: str | None = None, connector_id: str | Omit = omit, description: str | Omit = omit, location: SiteLocationParam | Omit = omit, @@ -352,12 +360,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._patch( - f"/accounts/{account_id}/magic/sites/{site_id}", + path_template("/accounts/{account_id}/magic/sites/{site_id}", account_id=account_id, site_id=site_id), body=maybe_transform( { "connector_id": connector_id, @@ -382,7 +392,7 @@ def get( self, site_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -407,6 +417,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -422,7 +434,7 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/magic/sites/{site_id}", + path_template("/accounts/{account_id}/magic/sites/{site_id}", account_id=account_id, site_id=site_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -469,7 +481,7 @@ def with_streaming_response(self) -> AsyncSitesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, connector_id: str | Omit = omit, description: str | Omit = omit, @@ -508,10 +520,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/sites", + path_template("/accounts/{account_id}/magic/sites", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -537,7 +551,7 @@ async def update( self, site_id: str, *, - account_id: str, + account_id: str | None = None, connector_id: str | Omit = omit, description: str | Omit = omit, location: SiteLocationParam | Omit = omit, @@ -574,12 +588,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return await self._put( - f"/accounts/{account_id}/magic/sites/{site_id}", + path_template("/accounts/{account_id}/magic/sites/{site_id}", account_id=account_id, site_id=site_id), body=await async_maybe_transform( { "connector_id": connector_id, @@ -603,7 +619,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, connectorid: 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. @@ -631,10 +647,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/magic/sites", + path_template("/accounts/{account_id}/magic/sites", account_id=account_id), page=AsyncSinglePage[Site], options=make_request_options( extra_headers=extra_headers, @@ -650,7 +668,7 @@ async def delete( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -674,12 +692,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}", + path_template("/accounts/{account_id}/magic/sites/{site_id}", account_id=account_id, site_id=site_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -694,7 +714,7 @@ async def edit( self, site_id: str, *, - account_id: str, + account_id: str | None = None, connector_id: str | Omit = omit, description: str | Omit = omit, location: SiteLocationParam | Omit = omit, @@ -731,12 +751,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/sites/{site_id}", + path_template("/accounts/{account_id}/magic/sites/{site_id}", account_id=account_id, site_id=site_id), body=await async_maybe_transform( { "connector_id": connector_id, @@ -761,7 +783,7 @@ async def get( self, site_id: str, *, - account_id: str, + account_id: str | None = None, x_magic_new_hc_target: 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. @@ -786,6 +808,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -801,7 +825,7 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/magic/sites/{site_id}", + path_template("/accounts/{account_id}/magic/sites/{site_id}", account_id=account_id, site_id=site_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/magic_transit/sites/wans.py b/src/cloudflare/resources/magic_transit/sites/wans.py index b6e574898d4..44b24fb6c9c 100644 --- a/src/cloudflare/resources/magic_transit/sites/wans.py +++ b/src/cloudflare/resources/magic_transit/sites/wans.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def create( self, site_id: str, *, - account_id: str, + account_id: str | None = None, physport: int, name: str | Omit = omit, priority: int | Omit = omit, @@ -84,12 +84,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/wans", + path_template("/accounts/{account_id}/magic/sites/{site_id}/wans", account_id=account_id, site_id=site_id), page=SyncSinglePage[WAN], body=maybe_transform( { @@ -112,7 +114,7 @@ def update( self, wan_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, name: str | Omit = omit, physport: int | Omit = omit, @@ -149,6 +151,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -156,7 +160,12 @@ def update( if not wan_id: raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") return self._put( - f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + account_id=account_id, + site_id=site_id, + wan_id=wan_id, + ), body=maybe_transform( { "name": name, @@ -181,7 +190,7 @@ def list( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -205,12 +214,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/wans", + path_template("/accounts/{account_id}/magic/sites/{site_id}/wans", account_id=account_id, site_id=site_id), page=SyncSinglePage[WAN], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -222,7 +233,7 @@ def delete( self, wan_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -249,6 +260,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -256,7 +269,12 @@ def delete( if not wan_id: raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") return self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + account_id=account_id, + site_id=site_id, + wan_id=wan_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -271,7 +289,7 @@ def edit( self, wan_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, name: str | Omit = omit, physport: int | Omit = omit, @@ -308,6 +326,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -315,7 +335,12 @@ def edit( if not wan_id: raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") return self._patch( - f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + account_id=account_id, + site_id=site_id, + wan_id=wan_id, + ), body=maybe_transform( { "name": name, @@ -340,7 +365,7 @@ def get( self, wan_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -367,6 +392,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -374,7 +401,12 @@ def get( if not wan_id: raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") return self._get( - f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + account_id=account_id, + site_id=site_id, + wan_id=wan_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -410,7 +442,7 @@ def create( self, site_id: str, *, - account_id: str, + account_id: str | None = None, physport: int, name: str | Omit = omit, priority: int | Omit = omit, @@ -444,12 +476,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/wans", + path_template("/accounts/{account_id}/magic/sites/{site_id}/wans", account_id=account_id, site_id=site_id), page=AsyncSinglePage[WAN], body=maybe_transform( { @@ -472,7 +506,7 @@ async def update( self, wan_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, name: str | Omit = omit, physport: int | Omit = omit, @@ -509,6 +543,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -516,7 +552,12 @@ async def update( if not wan_id: raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") return await self._put( - f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + account_id=account_id, + site_id=site_id, + wan_id=wan_id, + ), body=await async_maybe_transform( { "name": name, @@ -541,7 +582,7 @@ def list( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -565,12 +606,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/wans", + path_template("/accounts/{account_id}/magic/sites/{site_id}/wans", account_id=account_id, site_id=site_id), page=AsyncSinglePage[WAN], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -582,7 +625,7 @@ async def delete( self, wan_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -609,6 +652,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -616,7 +661,12 @@ async def delete( if not wan_id: raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") return await self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + account_id=account_id, + site_id=site_id, + wan_id=wan_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -631,7 +681,7 @@ async def edit( self, wan_id: str, *, - account_id: str, + account_id: str | None = None, site_id: str, name: str | Omit = omit, physport: int | Omit = omit, @@ -668,6 +718,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -675,7 +727,12 @@ async def edit( if not wan_id: raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") return await self._patch( - f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + account_id=account_id, + site_id=site_id, + wan_id=wan_id, + ), body=await async_maybe_transform( { "name": name, @@ -700,7 +757,7 @@ async def get( self, wan_id: str, *, - account_id: str, + account_id: str | None = None, site_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. @@ -727,6 +784,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: @@ -734,7 +793,12 @@ async def get( if not wan_id: raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") return await self._get( - f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + path_template( + "/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + account_id=account_id, + site_id=site_id, + wan_id=wan_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/managed_transforms/__init__.py b/src/cloudflare/resources/managed_transforms/__init__.py new file mode 100644 index 00000000000..d40e063c3c8 --- /dev/null +++ b/src/cloudflare/resources/managed_transforms/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .managed_transforms import ( + ManagedTransformsResource, + AsyncManagedTransformsResource, + ManagedTransformsResourceWithRawResponse, + AsyncManagedTransformsResourceWithRawResponse, + ManagedTransformsResourceWithStreamingResponse, + AsyncManagedTransformsResourceWithStreamingResponse, +) + +__all__ = [ + "ManagedTransformsResource", + "AsyncManagedTransformsResource", + "ManagedTransformsResourceWithRawResponse", + "AsyncManagedTransformsResourceWithRawResponse", + "ManagedTransformsResourceWithStreamingResponse", + "AsyncManagedTransformsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/managed_transforms/api.md b/src/cloudflare/resources/managed_transforms/api.md new file mode 100644 index 00000000000..264fc01c044 --- /dev/null +++ b/src/cloudflare/resources/managed_transforms/api.md @@ -0,0 +1,16 @@ +# ManagedTransforms + +Types: + +```python +from cloudflare.types.managed_transforms import ( + ManagedTransformListResponse, + ManagedTransformEditResponse, +) +``` + +Methods: + +- client.managed_transforms.list(\*, zone_id) -> ManagedTransformListResponse +- client.managed_transforms.delete(\*, zone_id) -> None +- client.managed_transforms.edit(\*, zone_id, \*\*params) -> ManagedTransformEditResponse diff --git a/src/cloudflare/resources/managed_transforms.py b/src/cloudflare/resources/managed_transforms/managed_transforms.py similarity index 88% rename from src/cloudflare/resources/managed_transforms.py rename to src/cloudflare/resources/managed_transforms/managed_transforms.py index 1b70c745c06..35e19541e0c 100644 --- a/src/cloudflare/resources/managed_transforms.py +++ b/src/cloudflare/resources/managed_transforms/managed_transforms.py @@ -6,21 +6,21 @@ import httpx -from .._types import Body, Query, Headers, NoneType, NotGiven, not_given -from .._utils import maybe_transform, async_maybe_transform -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( +from ..._types import Body, Query, Headers, NoneType, NotGiven, not_given +from ..._utils import path_template, 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.managed_transforms import managed_transform_edit_params -from ..types.managed_transforms.managed_transform_edit_response import ManagedTransformEditResponse -from ..types.managed_transforms.managed_transform_list_response import ManagedTransformListResponse +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.managed_transforms import managed_transform_edit_params +from ...types.managed_transforms.managed_transform_edit_response import ManagedTransformEditResponse +from ...types.managed_transforms.managed_transform_list_response import ManagedTransformListResponse __all__ = ["ManagedTransformsResource", "AsyncManagedTransformsResource"] @@ -48,7 +48,7 @@ def with_streaming_response(self) -> ManagedTransformsResourceWithStreamingRespo def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -70,10 +70,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/managed_headers", + path_template("/zones/{zone_id}/managed_headers", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -87,7 +89,7 @@ def list( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -109,11 +111,13 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/zones/{zone_id}/managed_headers", + path_template("/zones/{zone_id}/managed_headers", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -123,7 +127,7 @@ def delete( def edit( self, *, - zone_id: str, + zone_id: str | None = None, managed_request_headers: Iterable[managed_transform_edit_params.ManagedRequestHeader], managed_response_headers: Iterable[managed_transform_edit_params.ManagedResponseHeader], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -151,10 +155,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/managed_headers", + path_template("/zones/{zone_id}/managed_headers", zone_id=zone_id), body=maybe_transform( { "managed_request_headers": managed_request_headers, @@ -196,7 +202,7 @@ def with_streaming_response(self) -> AsyncManagedTransformsResourceWithStreaming async def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -218,10 +224,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/managed_headers", + path_template("/zones/{zone_id}/managed_headers", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -235,7 +243,7 @@ async def list( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -257,11 +265,13 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/zones/{zone_id}/managed_headers", + path_template("/zones/{zone_id}/managed_headers", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -271,7 +281,7 @@ async def delete( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, managed_request_headers: Iterable[managed_transform_edit_params.ManagedRequestHeader], managed_response_headers: Iterable[managed_transform_edit_params.ManagedResponseHeader], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -299,10 +309,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/managed_headers", + path_template("/zones/{zone_id}/managed_headers", zone_id=zone_id), body=await async_maybe_transform( { "managed_request_headers": managed_request_headers, diff --git a/src/cloudflare/resources/memberships/__init__.py b/src/cloudflare/resources/memberships/__init__.py new file mode 100644 index 00000000000..ff832b6abe6 --- /dev/null +++ b/src/cloudflare/resources/memberships/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .memberships import ( + MembershipsResource, + AsyncMembershipsResource, + MembershipsResourceWithRawResponse, + AsyncMembershipsResourceWithRawResponse, + MembershipsResourceWithStreamingResponse, + AsyncMembershipsResourceWithStreamingResponse, +) + +__all__ = [ + "MembershipsResource", + "AsyncMembershipsResource", + "MembershipsResourceWithRawResponse", + "AsyncMembershipsResourceWithRawResponse", + "MembershipsResourceWithStreamingResponse", + "AsyncMembershipsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/memberships/api.md b/src/cloudflare/resources/memberships/api.md new file mode 100644 index 00000000000..50e50405f25 --- /dev/null +++ b/src/cloudflare/resources/memberships/api.md @@ -0,0 +1,19 @@ +# Memberships + +Types: + +```python +from cloudflare.types.memberships import ( + Membership, + MembershipUpdateResponse, + MembershipDeleteResponse, + MembershipGetResponse, +) +``` + +Methods: + +- client.memberships.update(membership_id, \*\*params) -> Optional[MembershipUpdateResponse] +- client.memberships.list(\*\*params) -> SyncV4PagePaginationArray[Membership] +- client.memberships.delete(membership_id) -> Optional[MembershipDeleteResponse] +- client.memberships.get(membership_id) -> Optional[MembershipGetResponse] diff --git a/src/cloudflare/resources/memberships.py b/src/cloudflare/resources/memberships/memberships.py similarity index 93% rename from src/cloudflare/resources/memberships.py rename to src/cloudflare/resources/memberships/memberships.py index 1bc6e6ba7b3..f4ebb84c710 100644 --- a/src/cloudflare/resources/memberships.py +++ b/src/cloudflare/resources/memberships/memberships.py @@ -7,24 +7,24 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, 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.memberships import membership_list_params, membership_update_params -from ..types.memberships.membership import Membership -from ..types.memberships.membership_get_response import MembershipGetResponse -from ..types.memberships.membership_delete_response import MembershipDeleteResponse -from ..types.memberships.membership_update_response import MembershipUpdateResponse +from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.memberships import membership_list_params, membership_update_params +from ...types.memberships.membership import Membership +from ...types.memberships.membership_get_response import MembershipGetResponse +from ...types.memberships.membership_delete_response import MembershipDeleteResponse +from ...types.memberships.membership_update_response import MembershipUpdateResponse __all__ = ["MembershipsResource", "AsyncMembershipsResource"] @@ -80,7 +80,7 @@ def update( if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") return self._put( - f"/memberships/{membership_id}", + path_template("/memberships/{membership_id}", membership_id=membership_id), body=maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -185,7 +185,7 @@ def delete( if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") return self._delete( - f"/memberships/{membership_id}", + path_template("/memberships/{membership_id}", membership_id=membership_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -224,7 +224,7 @@ def get( if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") return self._get( - f"/memberships/{membership_id}", + path_template("/memberships/{membership_id}", membership_id=membership_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -287,7 +287,7 @@ async def update( if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") return await self._put( - f"/memberships/{membership_id}", + path_template("/memberships/{membership_id}", membership_id=membership_id), body=await async_maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -392,7 +392,7 @@ async def delete( if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") return await self._delete( - f"/memberships/{membership_id}", + path_template("/memberships/{membership_id}", membership_id=membership_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -431,7 +431,7 @@ async def get( if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") return await self._get( - f"/memberships/{membership_id}", + path_template("/memberships/{membership_id}", membership_id=membership_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/mtls_certificates/api.md b/src/cloudflare/resources/mtls_certificates/api.md new file mode 100644 index 00000000000..8487b4b82e2 --- /dev/null +++ b/src/cloudflare/resources/mtls_certificates/api.md @@ -0,0 +1,26 @@ +# MTLSCertificates + +Types: + +```python +from cloudflare.types.mtls_certificates import MTLSCertificate, MTLSCertificateCreateResponse +``` + +Methods: + +- client.mtls_certificates.create(\*, account_id, \*\*params) -> Optional[MTLSCertificateCreateResponse] +- client.mtls_certificates.list(\*, account_id, \*\*params) -> SyncSinglePage[MTLSCertificate] +- client.mtls_certificates.delete(mtls_certificate_id, \*, account_id) -> Optional[MTLSCertificate] +- client.mtls_certificates.get(mtls_certificate_id, \*, account_id) -> Optional[MTLSCertificate] + +## Associations + +Types: + +```python +from cloudflare.types.mtls_certificates import CertificateAsssociation +``` + +Methods: + +- client.mtls_certificates.associations.get(mtls_certificate_id, \*, account_id) -> SyncSinglePage[CertificateAsssociation] diff --git a/src/cloudflare/resources/mtls_certificates/associations.py b/src/cloudflare/resources/mtls_certificates/associations.py index a76063559c4..15930bbf7ad 100644 --- a/src/cloudflare/resources/mtls_certificates/associations.py +++ b/src/cloudflare/resources/mtls_certificates/associations.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -44,7 +45,7 @@ def get( self, mtls_certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,6 +69,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not mtls_certificate_id: @@ -75,7 +78,11 @@ def get( f"Expected a non-empty value for `mtls_certificate_id` but received {mtls_certificate_id!r}" ) return self._get_api_list( - f"/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}/associations", + path_template( + "/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}/associations", + account_id=account_id, + mtls_certificate_id=mtls_certificate_id, + ), page=SyncSinglePage[CertificateAsssociation], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -108,7 +115,7 @@ def get( self, mtls_certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -132,6 +139,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not mtls_certificate_id: @@ -139,7 +148,11 @@ def get( f"Expected a non-empty value for `mtls_certificate_id` but received {mtls_certificate_id!r}" ) return self._get_api_list( - f"/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}/associations", + path_template( + "/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}/associations", + account_id=account_id, + mtls_certificate_id=mtls_certificate_id, + ), page=AsyncSinglePage[CertificateAsssociation], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/mtls_certificates/mtls_certificates.py b/src/cloudflare/resources/mtls_certificates/mtls_certificates.py index 419f806abe1..05de8a723c1 100644 --- a/src/cloudflare/resources/mtls_certificates/mtls_certificates.py +++ b/src/cloudflare/resources/mtls_certificates/mtls_certificates.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -62,7 +62,7 @@ def with_streaming_response(self) -> MTLSCertificatesResourceWithStreamingRespon def create( self, *, - account_id: str, + account_id: str | None = None, ca: bool, certificates: str, name: str | Omit = omit, @@ -100,10 +100,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mtls_certificates", + path_template("/accounts/{account_id}/mtls_certificates", account_id=account_id), body=maybe_transform( { "ca": ca, @@ -126,7 +128,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, type: List[Literal["custom", "gateway_managed", "access_managed"]] | 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. @@ -154,10 +156,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mtls_certificates", + path_template("/accounts/{account_id}/mtls_certificates", account_id=account_id), page=SyncSinglePage[MTLSCertificate], options=make_request_options( extra_headers=extra_headers, @@ -173,7 +177,7 @@ def delete( self, mtls_certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -198,6 +202,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not mtls_certificate_id: @@ -205,7 +211,11 @@ def delete( f"Expected a non-empty value for `mtls_certificate_id` but received {mtls_certificate_id!r}" ) return self._delete( - f"/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}", + path_template( + "/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}", + account_id=account_id, + mtls_certificate_id=mtls_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -220,7 +230,7 @@ def get( self, mtls_certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -247,6 +257,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not mtls_certificate_id: @@ -254,7 +266,11 @@ def get( f"Expected a non-empty value for `mtls_certificate_id` but received {mtls_certificate_id!r}" ) return self._get( - f"/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}", + path_template( + "/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}", + account_id=account_id, + mtls_certificate_id=mtls_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -293,7 +309,7 @@ def with_streaming_response(self) -> AsyncMTLSCertificatesResourceWithStreamingR async def create( self, *, - account_id: str, + account_id: str | None = None, ca: bool, certificates: str, name: str | Omit = omit, @@ -331,10 +347,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mtls_certificates", + path_template("/accounts/{account_id}/mtls_certificates", account_id=account_id), body=await async_maybe_transform( { "ca": ca, @@ -357,7 +375,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, type: List[Literal["custom", "gateway_managed", "access_managed"]] | 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. @@ -385,10 +403,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/mtls_certificates", + path_template("/accounts/{account_id}/mtls_certificates", account_id=account_id), page=AsyncSinglePage[MTLSCertificate], options=make_request_options( extra_headers=extra_headers, @@ -404,7 +424,7 @@ async def delete( self, mtls_certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -429,6 +449,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not mtls_certificate_id: @@ -436,7 +458,11 @@ async def delete( f"Expected a non-empty value for `mtls_certificate_id` but received {mtls_certificate_id!r}" ) return await self._delete( - f"/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}", + path_template( + "/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}", + account_id=account_id, + mtls_certificate_id=mtls_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -451,7 +477,7 @@ async def get( self, mtls_certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -478,6 +504,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not mtls_certificate_id: @@ -485,7 +513,11 @@ async def get( f"Expected a non-empty value for `mtls_certificate_id` but received {mtls_certificate_id!r}" ) return await self._get( - f"/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}", + path_template( + "/accounts/{account_id}/mtls_certificates/{mtls_certificate_id}", + account_id=account_id, + mtls_certificate_id=mtls_certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/network_interconnects/api.md b/src/cloudflare/resources/network_interconnects/api.md new file mode 100644 index 00000000000..41adf3f08fc --- /dev/null +++ b/src/cloudflare/resources/network_interconnects/api.md @@ -0,0 +1,70 @@ +# NetworkInterconnects + +## CNIs + +Types: + +```python +from cloudflare.types.network_interconnects import ( + CNICreateResponse, + CNIUpdateResponse, + CNIListResponse, + CNIGetResponse, +) +``` + +Methods: + +- 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 + +## Interconnects + +Types: + +```python +from cloudflare.types.network_interconnects import ( + InterconnectCreateResponse, + InterconnectListResponse, + InterconnectGetResponse, + InterconnectStatusResponse, +) +``` + +Methods: + +- 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 + +## Settings + +Types: + +```python +from cloudflare.types.network_interconnects import SettingUpdateResponse, SettingGetResponse +``` + +Methods: + +- client.network_interconnects.settings.update(\*, account_id, \*\*params) -> SettingUpdateResponse +- client.network_interconnects.settings.get(\*, account_id) -> SettingGetResponse + +## Slots + +Types: + +```python +from cloudflare.types.network_interconnects import SlotListResponse, SlotGetResponse +``` + +Methods: + +- client.network_interconnects.slots.list(\*, account_id, \*\*params) -> SlotListResponse +- client.network_interconnects.slots.get(slot, \*, account_id) -> SlotGetResponse diff --git a/src/cloudflare/resources/network_interconnects/cnis.py b/src/cloudflare/resources/network_interconnects/cnis.py index bdbbcbbd217..33087d76580 100644 --- a/src/cloudflare/resources/network_interconnects/cnis.py +++ b/src/cloudflare/resources/network_interconnects/cnis.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> CNIsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, account: str, interconnect: str, magic: cni_create_params.Magic, @@ -77,10 +77,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/cnis", + path_template("/accounts/{account_id}/cni/cnis", account_id=account_id), body=maybe_transform( { "account": account, @@ -100,7 +102,7 @@ def update( self, cni: str, *, - account_id: str, + account_id: str | None = None, id: str, account: str, cust_ip: str, @@ -139,12 +141,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cni: raise ValueError(f"Expected a non-empty value for `cni` but received {cni!r}") return self._put( - f"/accounts/{account_id}/cni/cnis/{cni}", + path_template("/accounts/{account_id}/cni/cnis/{cni}", account_id=account_id, cni=cni), body=maybe_transform( { "id": id, @@ -166,7 +170,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, cursor: Optional[int] | Omit = omit, limit: Optional[int] | Omit = omit, slot: Optional[str] | Omit = omit, @@ -196,10 +200,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/cnis", + path_template("/accounts/{account_id}/cni/cnis", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -222,7 +228,7 @@ def delete( self, cni: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -244,13 +250,15 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cni: raise ValueError(f"Expected a non-empty value for `cni` but received {cni!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/cni/cnis/{cni}", + path_template("/accounts/{account_id}/cni/cnis/{cni}", account_id=account_id, cni=cni), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -261,7 +269,7 @@ def get( self, cni: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -283,12 +291,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cni: raise ValueError(f"Expected a non-empty value for `cni` but received {cni!r}") return self._get( - f"/accounts/{account_id}/cni/cnis/{cni}", + path_template("/accounts/{account_id}/cni/cnis/{cni}", account_id=account_id, cni=cni), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -319,7 +329,7 @@ def with_streaming_response(self) -> AsyncCNIsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, account: str, interconnect: str, magic: cni_create_params.Magic, @@ -347,10 +357,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/cnis", + path_template("/accounts/{account_id}/cni/cnis", account_id=account_id), body=await async_maybe_transform( { "account": account, @@ -370,7 +382,7 @@ async def update( self, cni: str, *, - account_id: str, + account_id: str | None = None, id: str, account: str, cust_ip: str, @@ -409,12 +421,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cni: raise ValueError(f"Expected a non-empty value for `cni` but received {cni!r}") return await self._put( - f"/accounts/{account_id}/cni/cnis/{cni}", + path_template("/accounts/{account_id}/cni/cnis/{cni}", account_id=account_id, cni=cni), body=await async_maybe_transform( { "id": id, @@ -436,7 +450,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, cursor: Optional[int] | Omit = omit, limit: Optional[int] | Omit = omit, slot: Optional[str] | Omit = omit, @@ -466,10 +480,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/cnis", + path_template("/accounts/{account_id}/cni/cnis", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -492,7 +508,7 @@ async def delete( self, cni: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -514,13 +530,15 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cni: raise ValueError(f"Expected a non-empty value for `cni` but received {cni!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/cni/cnis/{cni}", + path_template("/accounts/{account_id}/cni/cnis/{cni}", account_id=account_id, cni=cni), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -531,7 +549,7 @@ async def get( self, cni: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -553,12 +571,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not cni: raise ValueError(f"Expected a non-empty value for `cni` but received {cni!r}") return await self._get( - f"/accounts/{account_id}/cni/cnis/{cni}", + path_template("/accounts/{account_id}/cni/cnis/{cni}", account_id=account_id, cni=cni), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/network_interconnects/interconnects.py b/src/cloudflare/resources/network_interconnects/interconnects.py index f6f091ecedf..ac00201e599 100644 --- a/src/cloudflare/resources/network_interconnects/interconnects.py +++ b/src/cloudflare/resources/network_interconnects/interconnects.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> InterconnectsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, account: str, slot_id: str, type: str, @@ -83,7 +83,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, account: str, bandwidth: Literal["50M", "100M", "200M", "300M", "400M", "500M", "1G", "2G", "5G", "10G", "20G", "50G"], pairing_key: str, @@ -115,13 +115,11 @@ def create( """ ... - @required_args( - ["account_id", "account", "slot_id", "type"], ["account_id", "account", "bandwidth", "pairing_key", "type"] - ) + @required_args(["account", "slot_id", "type"], ["account", "bandwidth", "pairing_key", "type"]) def create( self, *, - account_id: str, + account_id: str | None = None, account: str, slot_id: str | Omit = omit, type: str, @@ -136,12 +134,14 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InterconnectCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( InterconnectCreateResponse, self._post( - f"/accounts/{account_id}/cni/interconnects", + path_template("/accounts/{account_id}/cni/interconnects", account_id=account_id), body=maybe_transform( { "account": account, @@ -165,7 +165,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, cursor: Optional[int] | Omit = omit, limit: Optional[int] | Omit = omit, site: Optional[str] | Omit = omit, @@ -195,10 +195,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/interconnects", + path_template("/accounts/{account_id}/cni/interconnects", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -221,7 +223,7 @@ def delete( self, icon: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -243,13 +245,15 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not icon: raise ValueError(f"Expected a non-empty value for `icon` but received {icon!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/cni/interconnects/{icon}", + path_template("/accounts/{account_id}/cni/interconnects/{icon}", account_id=account_id, icon=icon), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -260,7 +264,7 @@ def get( self, icon: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -282,6 +286,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not icon: @@ -289,7 +295,7 @@ def get( return cast( InterconnectGetResponse, self._get( - f"/accounts/{account_id}/cni/interconnects/{icon}", + path_template("/accounts/{account_id}/cni/interconnects/{icon}", account_id=account_id, icon=icon), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -303,7 +309,7 @@ def loa( self, icon: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -325,13 +331,15 @@ def loa( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not icon: raise ValueError(f"Expected a non-empty value for `icon` but received {icon!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/cni/interconnects/{icon}/loa", + path_template("/accounts/{account_id}/cni/interconnects/{icon}/loa", account_id=account_id, icon=icon), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -342,7 +350,7 @@ def status( self, icon: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -364,6 +372,8 @@ def status( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not icon: @@ -371,7 +381,9 @@ def status( return cast( InterconnectStatusResponse, self._get( - f"/accounts/{account_id}/cni/interconnects/{icon}/status", + path_template( + "/accounts/{account_id}/cni/interconnects/{icon}/status", account_id=account_id, icon=icon + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -406,7 +418,7 @@ def with_streaming_response(self) -> AsyncInterconnectsResourceWithStreamingResp async def create( self, *, - account_id: str, + account_id: str | None = None, account: str, slot_id: str, type: str, @@ -438,7 +450,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, account: str, bandwidth: Literal["50M", "100M", "200M", "300M", "400M", "500M", "1G", "2G", "5G", "10G", "20G", "50G"], pairing_key: str, @@ -470,13 +482,11 @@ async def create( """ ... - @required_args( - ["account_id", "account", "slot_id", "type"], ["account_id", "account", "bandwidth", "pairing_key", "type"] - ) + @required_args(["account", "slot_id", "type"], ["account", "bandwidth", "pairing_key", "type"]) async def create( self, *, - account_id: str, + account_id: str | None = None, account: str, slot_id: str | Omit = omit, type: str, @@ -491,12 +501,14 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InterconnectCreateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( InterconnectCreateResponse, await self._post( - f"/accounts/{account_id}/cni/interconnects", + path_template("/accounts/{account_id}/cni/interconnects", account_id=account_id), body=await async_maybe_transform( { "account": account, @@ -520,7 +532,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, cursor: Optional[int] | Omit = omit, limit: Optional[int] | Omit = omit, site: Optional[str] | Omit = omit, @@ -550,10 +562,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/interconnects", + path_template("/accounts/{account_id}/cni/interconnects", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -576,7 +590,7 @@ async def delete( self, icon: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -598,13 +612,15 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not icon: raise ValueError(f"Expected a non-empty value for `icon` but received {icon!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/cni/interconnects/{icon}", + path_template("/accounts/{account_id}/cni/interconnects/{icon}", account_id=account_id, icon=icon), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -615,7 +631,7 @@ async def get( self, icon: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -637,6 +653,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not icon: @@ -644,7 +662,7 @@ async def get( return cast( InterconnectGetResponse, await self._get( - f"/accounts/{account_id}/cni/interconnects/{icon}", + path_template("/accounts/{account_id}/cni/interconnects/{icon}", account_id=account_id, icon=icon), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -658,7 +676,7 @@ async def loa( self, icon: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -680,13 +698,15 @@ async def loa( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not icon: raise ValueError(f"Expected a non-empty value for `icon` but received {icon!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/cni/interconnects/{icon}/loa", + path_template("/accounts/{account_id}/cni/interconnects/{icon}/loa", account_id=account_id, icon=icon), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -697,7 +717,7 @@ async def status( self, icon: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -719,6 +739,8 @@ async def status( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not icon: @@ -726,7 +748,9 @@ async def status( return cast( InterconnectStatusResponse, await self._get( - f"/accounts/{account_id}/cni/interconnects/{icon}/status", + path_template( + "/accounts/{account_id}/cni/interconnects/{icon}/status", account_id=account_id, icon=icon + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/network_interconnects/settings.py b/src/cloudflare/resources/network_interconnects/settings.py index 5999015aecb..364783f417f 100644 --- a/src/cloudflare/resources/network_interconnects/settings.py +++ b/src/cloudflare/resources/network_interconnects/settings.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, default_asn: Optional[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. @@ -68,10 +68,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/settings", + path_template("/accounts/{account_id}/cni/settings", account_id=account_id), body=maybe_transform({"default_asn": default_asn}, setting_update_params.SettingUpdateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -82,7 +84,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -102,10 +104,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/settings", + path_template("/accounts/{account_id}/cni/settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -136,7 +140,7 @@ def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: async def update( self, *, - account_id: str, + account_id: str | None = None, default_asn: Optional[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. @@ -157,10 +161,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/settings", + path_template("/accounts/{account_id}/cni/settings", account_id=account_id), body=await async_maybe_transform({"default_asn": default_asn}, setting_update_params.SettingUpdateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -171,7 +177,7 @@ async def update( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -191,10 +197,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/settings", + path_template("/accounts/{account_id}/cni/settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/network_interconnects/slots.py b/src/cloudflare/resources/network_interconnects/slots.py index cdecb4d13d2..a3233a33b86 100644 --- a/src/cloudflare/resources/network_interconnects/slots.py +++ b/src/cloudflare/resources/network_interconnects/slots.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> SlotsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, address_contains: Optional[str] | Omit = omit, cursor: Optional[int] | Omit = omit, limit: Optional[int] | Omit = omit, @@ -83,10 +83,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/slots", + path_template("/accounts/{account_id}/cni/slots", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -111,7 +113,7 @@ def get( self, slot: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -133,12 +135,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not slot: raise ValueError(f"Expected a non-empty value for `slot` but received {slot!r}") return self._get( - f"/accounts/{account_id}/cni/slots/{slot}", + path_template("/accounts/{account_id}/cni/slots/{slot}", account_id=account_id, slot=slot), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -169,7 +173,7 @@ def with_streaming_response(self) -> AsyncSlotsResourceWithStreamingResponse: async def list( self, *, - account_id: str, + account_id: str | None = None, address_contains: Optional[str] | Omit = omit, cursor: Optional[int] | Omit = omit, limit: Optional[int] | Omit = omit, @@ -205,10 +209,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cni/slots", + path_template("/accounts/{account_id}/cni/slots", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -233,7 +239,7 @@ async def get( self, slot: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -255,12 +261,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not slot: raise ValueError(f"Expected a non-empty value for `slot` but received {slot!r}") return await self._get( - f"/accounts/{account_id}/cni/slots/{slot}", + path_template("/accounts/{account_id}/cni/slots/{slot}", account_id=account_id, slot=slot), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/organizations/api.md b/src/cloudflare/resources/organizations/api.md new file mode 100644 index 00000000000..4addbb903b4 --- /dev/null +++ b/src/cloudflare/resources/organizations/api.md @@ -0,0 +1,28 @@ +# 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.organizations import OrganizationProfile +``` + +Methods: + +- client.organizations.organization_profile.update(organization_id, \*\*params) -> None +- client.organizations.organization_profile.get(organization_id) -> Result diff --git a/src/cloudflare/resources/organizations/organization_profile.py b/src/cloudflare/resources/organizations/organization_profile.py index 48efaa1b042..5d11872fc2d 100644 --- a/src/cloudflare/resources/organizations/organization_profile.py +++ b/src/cloudflare/resources/organizations/organization_profile.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NoneType, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -80,7 +80,7 @@ def update( raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._put( - f"/organizations/{organization_id}/profile", + path_template("/organizations/{organization_id}/profile", organization_id=organization_id), body=maybe_transform( { "business_address": business_address, @@ -124,8 +124,8 @@ def get( # pyright: ignore[reportUnknownParameterType] """ if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") - return self._get( # pyright: ignore[reportUnknownVariableType, reportUnknownMemberType, reportUnknownArgumentType] - f"/organizations/{organization_id}/profile", + return self._get( + path_template("/organizations/{organization_id}/profile", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -191,7 +191,7 @@ async def update( raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._put( - f"/organizations/{organization_id}/profile", + path_template("/organizations/{organization_id}/profile", organization_id=organization_id), body=await async_maybe_transform( { "business_address": business_address, @@ -235,8 +235,8 @@ async def get( # pyright: ignore[reportUnknownParameterType] """ if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") - return await self._get( # pyright: ignore[reportUnknownVariableType, reportUnknownMemberType, reportUnknownArgumentType] - f"/organizations/{organization_id}/profile", + return await self._get( + path_template("/organizations/{organization_id}/profile", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/organizations/organizations.py b/src/cloudflare/resources/organizations/organizations.py index 9609b441df2..cf097f97a1c 100644 --- a/src/cloudflare/resources/organizations/organizations.py +++ b/src/cloudflare/resources/organizations/organizations.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -136,7 +136,7 @@ def update( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return self._put( - f"/organizations/{organization_id}", + path_template("/organizations/{organization_id}", organization_id=organization_id), body=maybe_transform( { "name": name, @@ -248,7 +248,7 @@ def delete( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return self._delete( - f"/organizations/{organization_id}", + path_template("/organizations/{organization_id}", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -287,7 +287,7 @@ def get( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return self._get( - f"/organizations/{organization_id}", + path_template("/organizations/{organization_id}", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -401,7 +401,7 @@ async def update( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return await self._put( - f"/organizations/{organization_id}", + path_template("/organizations/{organization_id}", organization_id=organization_id), body=await async_maybe_transform( { "name": name, @@ -513,7 +513,7 @@ async def delete( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return await self._delete( - f"/organizations/{organization_id}", + path_template("/organizations/{organization_id}", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -552,7 +552,7 @@ async def get( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return await self._get( - f"/organizations/{organization_id}", + path_template("/organizations/{organization_id}", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/origin_ca_certificates/__init__.py b/src/cloudflare/resources/origin_ca_certificates/__init__.py new file mode 100644 index 00000000000..66d697314f5 --- /dev/null +++ b/src/cloudflare/resources/origin_ca_certificates/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .origin_ca_certificates import ( + OriginCACertificatesResource, + AsyncOriginCACertificatesResource, + OriginCACertificatesResourceWithRawResponse, + AsyncOriginCACertificatesResourceWithRawResponse, + OriginCACertificatesResourceWithStreamingResponse, + AsyncOriginCACertificatesResourceWithStreamingResponse, +) + +__all__ = [ + "OriginCACertificatesResource", + "AsyncOriginCACertificatesResource", + "OriginCACertificatesResourceWithRawResponse", + "AsyncOriginCACertificatesResourceWithRawResponse", + "OriginCACertificatesResourceWithStreamingResponse", + "AsyncOriginCACertificatesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/origin_ca_certificates/api.md b/src/cloudflare/resources/origin_ca_certificates/api.md new file mode 100644 index 00000000000..2d2f8f6a2d2 --- /dev/null +++ b/src/cloudflare/resources/origin_ca_certificates/api.md @@ -0,0 +1,17 @@ +# OriginCACertificates + +Types: + +```python +from cloudflare.types.origin_ca_certificates import ( + OriginCACertificate, + OriginCACertificateDeleteResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/origin_ca_certificates.py b/src/cloudflare/resources/origin_ca_certificates/origin_ca_certificates.py similarity index 94% rename from src/cloudflare/resources/origin_ca_certificates.py rename to src/cloudflare/resources/origin_ca_certificates/origin_ca_certificates.py index 1943091279a..808d4a56fa5 100644 --- a/src/cloudflare/resources/origin_ca_certificates.py +++ b/src/cloudflare/resources/origin_ca_certificates/origin_ca_certificates.py @@ -6,25 +6,25 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import path_template, 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 ..types.ssl import RequestValidity -from ..pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from .._base_client import AsyncPaginator, make_request_options -from ..types.ssl.request_validity import RequestValidity -from ..types.origin_ca_certificates import origin_ca_certificate_list_params, origin_ca_certificate_create_params -from ..types.shared.certificate_request_type import CertificateRequestType -from ..types.origin_ca_certificates.origin_ca_certificate import OriginCACertificate -from ..types.origin_ca_certificates.origin_ca_certificate_delete_response import OriginCACertificateDeleteResponse +from ..._wrappers import ResultWrapper +from ...types.ssl import RequestValidity +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.ssl.request_validity import RequestValidity +from ...types.origin_ca_certificates import origin_ca_certificate_list_params, origin_ca_certificate_create_params +from ...types.shared.certificate_request_type import CertificateRequestType +from ...types.origin_ca_certificates.origin_ca_certificate import OriginCACertificate +from ...types.origin_ca_certificates.origin_ca_certificate_delete_response import OriginCACertificateDeleteResponse __all__ = ["OriginCACertificatesResource", "AsyncOriginCACertificatesResource"] @@ -207,7 +207,7 @@ def delete( if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._delete( - f"/certificates/{certificate_id}", + path_template("/certificates/{certificate_id}", certificate_id=certificate_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -251,7 +251,7 @@ def get( if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._get( - f"/certificates/{certificate_id}", + path_template("/certificates/{certificate_id}", certificate_id=certificate_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -441,7 +441,7 @@ async def delete( if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._delete( - f"/certificates/{certificate_id}", + path_template("/certificates/{certificate_id}", certificate_id=certificate_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -485,7 +485,7 @@ async def get( if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._get( - f"/certificates/{certificate_id}", + path_template("/certificates/{certificate_id}", certificate_id=certificate_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/origin_post_quantum_encryption/__init__.py b/src/cloudflare/resources/origin_post_quantum_encryption/__init__.py new file mode 100644 index 00000000000..ddfcae1a9c0 --- /dev/null +++ b/src/cloudflare/resources/origin_post_quantum_encryption/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .origin_post_quantum_encryption import ( + OriginPostQuantumEncryptionResource, + AsyncOriginPostQuantumEncryptionResource, + OriginPostQuantumEncryptionResourceWithRawResponse, + AsyncOriginPostQuantumEncryptionResourceWithRawResponse, + OriginPostQuantumEncryptionResourceWithStreamingResponse, + AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse, +) + +__all__ = [ + "OriginPostQuantumEncryptionResource", + "AsyncOriginPostQuantumEncryptionResource", + "OriginPostQuantumEncryptionResourceWithRawResponse", + "AsyncOriginPostQuantumEncryptionResourceWithRawResponse", + "OriginPostQuantumEncryptionResourceWithStreamingResponse", + "AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/origin_post_quantum_encryption/api.md b/src/cloudflare/resources/origin_post_quantum_encryption/api.md new file mode 100644 index 00000000000..d91cbe5990f --- /dev/null +++ b/src/cloudflare/resources/origin_post_quantum_encryption/api.md @@ -0,0 +1,15 @@ +# OriginPostQuantumEncryption + +Types: + +```python +from cloudflare.types.origin_post_quantum_encryption import ( + OriginPostQuantumEncryptionUpdateResponse, + OriginPostQuantumEncryptionGetResponse, +) +``` + +Methods: + +- client.origin_post_quantum_encryption.update(\*, zone_id, \*\*params) -> Optional[OriginPostQuantumEncryptionUpdateResponse] +- client.origin_post_quantum_encryption.get(\*, zone_id) -> Optional[OriginPostQuantumEncryptionGetResponse] diff --git a/src/cloudflare/resources/origin_post_quantum_encryption.py b/src/cloudflare/resources/origin_post_quantum_encryption/origin_post_quantum_encryption.py similarity index 89% rename from src/cloudflare/resources/origin_post_quantum_encryption.py rename to src/cloudflare/resources/origin_post_quantum_encryption/origin_post_quantum_encryption.py index d049002bc21..e29afb53afe 100644 --- a/src/cloudflare/resources/origin_post_quantum_encryption.py +++ b/src/cloudflare/resources/origin_post_quantum_encryption/origin_post_quantum_encryption.py @@ -7,23 +7,23 @@ 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 ( +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template, 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.origin_post_quantum_encryption import origin_post_quantum_encryption_update_params -from ..types.origin_post_quantum_encryption.origin_post_quantum_encryption_get_response import ( +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.origin_post_quantum_encryption import origin_post_quantum_encryption_update_params +from ...types.origin_post_quantum_encryption.origin_post_quantum_encryption_get_response import ( OriginPostQuantumEncryptionGetResponse, ) -from ..types.origin_post_quantum_encryption.origin_post_quantum_encryption_update_response import ( +from ...types.origin_post_quantum_encryption.origin_post_quantum_encryption_update_response import ( OriginPostQuantumEncryptionUpdateResponse, ) @@ -53,7 +53,7 @@ def with_streaming_response(self) -> OriginPostQuantumEncryptionResourceWithStre def update( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["preferred", "supported", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -83,10 +83,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/cache/origin_post_quantum_encryption", + path_template("/zones/{zone_id}/cache/origin_post_quantum_encryption", zone_id=zone_id), body=maybe_transform( {"value": value}, origin_post_quantum_encryption_update_params.OriginPostQuantumEncryptionUpdateParams ), @@ -106,7 +108,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -133,10 +135,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/cache/origin_post_quantum_encryption", + path_template("/zones/{zone_id}/cache/origin_post_quantum_encryption", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -174,7 +178,7 @@ def with_streaming_response(self) -> AsyncOriginPostQuantumEncryptionResourceWit async def update( self, *, - zone_id: str, + zone_id: str | None = None, value: Literal["preferred", "supported", "off"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -204,10 +208,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/cache/origin_post_quantum_encryption", + path_template("/zones/{zone_id}/cache/origin_post_quantum_encryption", zone_id=zone_id), body=await async_maybe_transform( {"value": value}, origin_post_quantum_encryption_update_params.OriginPostQuantumEncryptionUpdateParams ), @@ -227,7 +233,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -254,10 +260,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/cache/origin_post_quantum_encryption", + path_template("/zones/{zone_id}/cache/origin_post_quantum_encryption", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/origin_tls_client_auth/api.md b/src/cloudflare/resources/origin_tls_client_auth/api.md new file mode 100644 index 00000000000..17fe6f3e97d --- /dev/null +++ b/src/cloudflare/resources/origin_tls_client_auth/api.md @@ -0,0 +1,87 @@ +# OriginTLSClientAuth + +Types: + +```python +from cloudflare.types.origin_tls_client_auth import ( + OriginTLSClientAuthCreateResponse, + OriginTLSClientAuthListResponse, + OriginTLSClientAuthDeleteResponse, + OriginTLSClientAuthGetResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.origin_tls_client_auth import AuthenticatedOriginPull, HostnameUpdateResponse +``` + +Methods: + +- client.origin_tls_client_auth.hostnames.update(\*, zone_id, \*\*params) -> SyncSinglePage[HostnameUpdateResponse] +- client.origin_tls_client_auth.hostnames.get(hostname, \*, zone_id) -> Optional[AuthenticatedOriginPull] + +## HostnameCertificates + +Types: + +```python +from cloudflare.types.origin_tls_client_auth import ( + Certificate, + HostnameCertificateCreateResponse, + HostnameCertificateListResponse, + HostnameCertificateDeleteResponse, + HostnameCertificateGetResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.origin_tls_client_auth import SettingUpdateResponse, SettingGetResponse +``` + +Methods: + +- client.origin_tls_client_auth.settings.update(\*, zone_id, \*\*params) -> Optional[SettingUpdateResponse] +- client.origin_tls_client_auth.settings.get(\*, zone_id) -> Optional[SettingGetResponse] diff --git a/src/cloudflare/resources/origin_tls_client_auth/hostname_certificates.py b/src/cloudflare/resources/origin_tls_client_auth/hostname_certificates.py index 34a887f7db5..d1f633c90c2 100644 --- a/src/cloudflare/resources/origin_tls_client_auth/hostname_certificates.py +++ b/src/cloudflare/resources/origin_tls_client_auth/hostname_certificates.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> HostnameCertificatesResourceWithStreamingRe def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, private_key: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -81,10 +81,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth/hostnames/certificates", + path_template("/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates", zone_id=zone_id), body=maybe_transform( { "certificate": certificate, @@ -107,7 +109,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -130,10 +132,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth/hostnames/certificates", + path_template("/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates", zone_id=zone_id), page=SyncSinglePage[HostnameCertificateListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -145,7 +149,7 @@ def delete( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -173,12 +177,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._delete( - f"/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -195,7 +205,7 @@ def get( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -219,12 +229,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._get( - f"/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -259,7 +275,7 @@ def with_streaming_response(self) -> AsyncHostnameCertificatesResourceWithStream async def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, private_key: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -289,10 +305,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth/hostnames/certificates", + path_template("/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates", zone_id=zone_id), body=await async_maybe_transform( { "certificate": certificate, @@ -315,7 +333,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -338,10 +356,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth/hostnames/certificates", + path_template("/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates", zone_id=zone_id), page=AsyncSinglePage[HostnameCertificateListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -353,7 +373,7 @@ async def delete( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -381,12 +401,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._delete( - f"/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -403,7 +429,7 @@ async def get( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -427,12 +453,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._get( - f"/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/hostnames/certificates/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/origin_tls_client_auth/hostnames.py b/src/cloudflare/resources/origin_tls_client_auth/hostnames.py index 7ea1313f8e5..d4261249bfe 100644 --- a/src/cloudflare/resources/origin_tls_client_auth/hostnames.py +++ b/src/cloudflare/resources/origin_tls_client_auth/hostnames.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> HostnamesResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, config: Iterable[hostname_update_params.Config], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -76,10 +76,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth/hostnames", + path_template("/zones/{zone_id}/origin_tls_client_auth/hostnames", zone_id=zone_id), page=SyncSinglePage[HostnameUpdateResponse], body=maybe_transform({"config": config}, hostname_update_params.HostnameUpdateParams), options=make_request_options( @@ -93,7 +95,7 @@ def get( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -119,12 +121,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return self._get( - f"/zones/{zone_id}/origin_tls_client_auth/hostnames/{hostname}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/hostnames/{hostname}", zone_id=zone_id, hostname=hostname + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -159,7 +165,7 @@ def with_streaming_response(self) -> AsyncHostnamesResourceWithStreamingResponse def update( self, *, - zone_id: str, + zone_id: str | None = None, config: Iterable[hostname_update_params.Config], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -186,10 +192,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth/hostnames", + path_template("/zones/{zone_id}/origin_tls_client_auth/hostnames", zone_id=zone_id), page=AsyncSinglePage[HostnameUpdateResponse], body=maybe_transform({"config": config}, hostname_update_params.HostnameUpdateParams), options=make_request_options( @@ -203,7 +211,7 @@ async def get( self, hostname: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -229,12 +237,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not hostname: raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") return await self._get( - f"/zones/{zone_id}/origin_tls_client_auth/hostnames/{hostname}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/hostnames/{hostname}", zone_id=zone_id, hostname=hostname + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/origin_tls_client_auth/origin_tls_client_auth.py b/src/cloudflare/resources/origin_tls_client_auth/origin_tls_client_auth.py index 7db340c4549..84e85c097b6 100644 --- a/src/cloudflare/resources/origin_tls_client_auth/origin_tls_client_auth.py +++ b/src/cloudflare/resources/origin_tls_client_auth/origin_tls_client_auth.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .settings import ( SettingsResource, AsyncSettingsResource, @@ -103,7 +103,7 @@ def with_streaming_response(self) -> OriginTLSClientAuthResourceWithStreamingRes def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, private_key: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -135,10 +135,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth", + path_template("/zones/{zone_id}/origin_tls_client_auth", zone_id=zone_id), body=maybe_transform( { "certificate": certificate, @@ -164,7 +166,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -187,10 +189,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth", + path_template("/zones/{zone_id}/origin_tls_client_auth", zone_id=zone_id), page=SyncSinglePage[OriginTLSClientAuthListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -205,7 +209,7 @@ def delete( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -229,12 +233,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._delete( - f"/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -254,7 +264,7 @@ def get( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -279,12 +289,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._get( - f"/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -338,7 +354,7 @@ def with_streaming_response(self) -> AsyncOriginTLSClientAuthResourceWithStreami async def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, private_key: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -370,10 +386,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth", + path_template("/zones/{zone_id}/origin_tls_client_auth", zone_id=zone_id), body=await async_maybe_transform( { "certificate": certificate, @@ -399,7 +417,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -422,10 +440,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth", + path_template("/zones/{zone_id}/origin_tls_client_auth", zone_id=zone_id), page=AsyncSinglePage[OriginTLSClientAuthListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -440,7 +460,7 @@ async def delete( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -464,12 +484,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._delete( - f"/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -489,7 +515,7 @@ async def get( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -514,12 +540,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._get( - f"/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/origin_tls_client_auth/settings.py b/src/cloudflare/resources/origin_tls_client_auth/settings.py index 9ae74bc3bc1..24eed231e9d 100644 --- a/src/cloudflare/resources/origin_tls_client_auth/settings.py +++ b/src/cloudflare/resources/origin_tls_client_auth/settings.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, enabled: 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. @@ -76,10 +76,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/origin_tls_client_auth/settings", + path_template("/zones/{zone_id}/origin_tls_client_auth/settings", zone_id=zone_id), body=maybe_transform({"enabled": enabled}, setting_update_params.SettingUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -94,7 +96,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -118,10 +120,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/origin_tls_client_auth/settings", + path_template("/zones/{zone_id}/origin_tls_client_auth/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -156,7 +160,7 @@ def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, enabled: 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. @@ -184,10 +188,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/origin_tls_client_auth/settings", + path_template("/zones/{zone_id}/origin_tls_client_auth/settings", zone_id=zone_id), body=await async_maybe_transform({"enabled": enabled}, setting_update_params.SettingUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -202,7 +208,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -226,10 +232,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/origin_tls_client_auth/settings", + path_template("/zones/{zone_id}/origin_tls_client_auth/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/origin_tls_client_auth/zone_certificates.py b/src/cloudflare/resources/origin_tls_client_auth/zone_certificates.py index b424f4e36f0..ac9360a31ea 100644 --- a/src/cloudflare/resources/origin_tls_client_auth/zone_certificates.py +++ b/src/cloudflare/resources/origin_tls_client_auth/zone_certificates.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> ZoneCertificatesResourceWithStreamingRespon def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, private_key: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -83,10 +83,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth", + path_template("/zones/{zone_id}/origin_tls_client_auth", zone_id=zone_id), body=maybe_transform( { "certificate": certificate, @@ -107,7 +109,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -130,10 +132,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth", + path_template("/zones/{zone_id}/origin_tls_client_auth", zone_id=zone_id), page=SyncSinglePage[ZoneCertificateListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -145,7 +149,7 @@ def delete( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -169,12 +173,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._delete( - f"/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -189,7 +199,7 @@ def get( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -214,12 +224,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._get( - f"/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -254,7 +270,7 @@ def with_streaming_response(self) -> AsyncZoneCertificatesResourceWithStreamingR async def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate: str, private_key: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -286,10 +302,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth", + path_template("/zones/{zone_id}/origin_tls_client_auth", zone_id=zone_id), body=await async_maybe_transform( { "certificate": certificate, @@ -310,7 +328,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -333,10 +351,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/origin_tls_client_auth", + path_template("/zones/{zone_id}/origin_tls_client_auth", zone_id=zone_id), page=AsyncSinglePage[ZoneCertificateListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -348,7 +368,7 @@ async def delete( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -372,12 +392,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._delete( - f"/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -392,7 +418,7 @@ async def get( self, certificate_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -417,12 +443,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._get( - f"/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + path_template( + "/zones/{zone_id}/origin_tls_client_auth/{certificate_id}", + zone_id=zone_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/page_rules/__init__.py b/src/cloudflare/resources/page_rules/__init__.py new file mode 100644 index 00000000000..9cf6f382bc3 --- /dev/null +++ b/src/cloudflare/resources/page_rules/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .page_rules import ( + PageRulesResource, + AsyncPageRulesResource, + PageRulesResourceWithRawResponse, + AsyncPageRulesResourceWithRawResponse, + PageRulesResourceWithStreamingResponse, + AsyncPageRulesResourceWithStreamingResponse, +) + +__all__ = [ + "PageRulesResource", + "AsyncPageRulesResource", + "PageRulesResourceWithRawResponse", + "AsyncPageRulesResourceWithRawResponse", + "PageRulesResourceWithStreamingResponse", + "AsyncPageRulesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/page_rules/api.md b/src/cloudflare/resources/page_rules/api.md new file mode 100644 index 00000000000..8c7a94e75b3 --- /dev/null +++ b/src/cloudflare/resources/page_rules/api.md @@ -0,0 +1,21 @@ +# PageRules + +Types: + +```python +from cloudflare.types.page_rules import ( + PageRule, + Target, + PageRuleListResponse, + PageRuleDeleteResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/page_rules.py b/src/cloudflare/resources/page_rules/page_rules.py similarity index 90% rename from src/cloudflare/resources/page_rules.py rename to src/cloudflare/resources/page_rules/page_rules.py index d687a14e8c0..ac3ec8ba84c 100644 --- a/src/cloudflare/resources/page_rules.py +++ b/src/cloudflare/resources/page_rules/page_rules.py @@ -7,28 +7,28 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, 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.page_rules import ( +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.page_rules import ( page_rule_edit_params, page_rule_list_params, page_rule_create_params, page_rule_update_params, ) -from ..types.page_rules.page_rule import PageRule -from ..types.page_rules.target_param import TargetParam -from ..types.page_rules.page_rule_list_response import PageRuleListResponse -from ..types.page_rules.page_rule_delete_response import PageRuleDeleteResponse +from ...types.page_rules.page_rule import PageRule +from ...types.page_rules.target_param import TargetParam +from ...types.page_rules.page_rule_list_response import PageRuleListResponse +from ...types.page_rules.page_rule_delete_response import PageRuleDeleteResponse __all__ = ["PageRulesResource", "AsyncPageRulesResource"] @@ -56,7 +56,7 @@ def with_streaming_response(self) -> PageRulesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[page_rule_create_params.Action], targets: Iterable[TargetParam], priority: int | Omit = omit, @@ -95,10 +95,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/pagerules", + path_template("/zones/{zone_id}/pagerules", zone_id=zone_id), body=maybe_transform( { "actions": actions, @@ -122,7 +124,7 @@ def update( self, pagerule_id: str, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[page_rule_update_params.Action], targets: Iterable[TargetParam], priority: int | Omit = omit, @@ -165,12 +167,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not pagerule_id: raise ValueError(f"Expected a non-empty value for `pagerule_id` but received {pagerule_id!r}") return self._put( - f"/zones/{zone_id}/pagerules/{pagerule_id}", + path_template("/zones/{zone_id}/pagerules/{pagerule_id}", zone_id=zone_id, pagerule_id=pagerule_id), body=maybe_transform( { "actions": actions, @@ -193,7 +197,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, order: Literal["status", "priority"] | Omit = omit, @@ -228,10 +232,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/pagerules", + path_template("/zones/{zone_id}/pagerules", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -255,7 +261,7 @@ def delete( self, pagerule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -279,12 +285,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not pagerule_id: raise ValueError(f"Expected a non-empty value for `pagerule_id` but received {pagerule_id!r}") return self._delete( - f"/zones/{zone_id}/pagerules/{pagerule_id}", + path_template("/zones/{zone_id}/pagerules/{pagerule_id}", zone_id=zone_id, pagerule_id=pagerule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -299,7 +307,7 @@ def edit( self, pagerule_id: str, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[page_rule_edit_params.Action] | Omit = omit, priority: int | Omit = omit, status: Literal["active", "disabled"] | Omit = omit, @@ -340,12 +348,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not pagerule_id: raise ValueError(f"Expected a non-empty value for `pagerule_id` but received {pagerule_id!r}") return self._patch( - f"/zones/{zone_id}/pagerules/{pagerule_id}", + path_template("/zones/{zone_id}/pagerules/{pagerule_id}", zone_id=zone_id, pagerule_id=pagerule_id), body=maybe_transform( { "actions": actions, @@ -369,7 +379,7 @@ def get( self, pagerule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -393,12 +403,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not pagerule_id: raise ValueError(f"Expected a non-empty value for `pagerule_id` but received {pagerule_id!r}") return self._get( - f"/zones/{zone_id}/pagerules/{pagerule_id}", + path_template("/zones/{zone_id}/pagerules/{pagerule_id}", zone_id=zone_id, pagerule_id=pagerule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -433,7 +445,7 @@ def with_streaming_response(self) -> AsyncPageRulesResourceWithStreamingResponse async def create( self, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[page_rule_create_params.Action], targets: Iterable[TargetParam], priority: int | Omit = omit, @@ -472,10 +484,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/pagerules", + path_template("/zones/{zone_id}/pagerules", zone_id=zone_id), body=await async_maybe_transform( { "actions": actions, @@ -499,7 +513,7 @@ async def update( self, pagerule_id: str, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[page_rule_update_params.Action], targets: Iterable[TargetParam], priority: int | Omit = omit, @@ -542,12 +556,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not pagerule_id: raise ValueError(f"Expected a non-empty value for `pagerule_id` but received {pagerule_id!r}") return await self._put( - f"/zones/{zone_id}/pagerules/{pagerule_id}", + path_template("/zones/{zone_id}/pagerules/{pagerule_id}", zone_id=zone_id, pagerule_id=pagerule_id), body=await async_maybe_transform( { "actions": actions, @@ -570,7 +586,7 @@ async def update( async def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, match: Literal["any", "all"] | Omit = omit, order: Literal["status", "priority"] | Omit = omit, @@ -605,10 +621,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/pagerules", + path_template("/zones/{zone_id}/pagerules", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -632,7 +650,7 @@ async def delete( self, pagerule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -656,12 +674,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not pagerule_id: raise ValueError(f"Expected a non-empty value for `pagerule_id` but received {pagerule_id!r}") return await self._delete( - f"/zones/{zone_id}/pagerules/{pagerule_id}", + path_template("/zones/{zone_id}/pagerules/{pagerule_id}", zone_id=zone_id, pagerule_id=pagerule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -676,7 +696,7 @@ async def edit( self, pagerule_id: str, *, - zone_id: str, + zone_id: str | None = None, actions: Iterable[page_rule_edit_params.Action] | Omit = omit, priority: int | Omit = omit, status: Literal["active", "disabled"] | Omit = omit, @@ -717,12 +737,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not pagerule_id: raise ValueError(f"Expected a non-empty value for `pagerule_id` but received {pagerule_id!r}") return await self._patch( - f"/zones/{zone_id}/pagerules/{pagerule_id}", + path_template("/zones/{zone_id}/pagerules/{pagerule_id}", zone_id=zone_id, pagerule_id=pagerule_id), body=await async_maybe_transform( { "actions": actions, @@ -746,7 +768,7 @@ async def get( self, pagerule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -770,12 +792,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not pagerule_id: raise ValueError(f"Expected a non-empty value for `pagerule_id` but received {pagerule_id!r}") return await self._get( - f"/zones/{zone_id}/pagerules/{pagerule_id}", + path_template("/zones/{zone_id}/pagerules/{pagerule_id}", zone_id=zone_id, pagerule_id=pagerule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/page_shield/api.md b/src/cloudflare/resources/page_shield/api.md new file mode 100644 index 00000000000..969cd7c79e6 --- /dev/null +++ b/src/cloudflare/resources/page_shield/api.md @@ -0,0 +1,73 @@ +# PageShield + +Types: + +```python +from cloudflare.types.page_shield import Setting, PageShieldUpdateResponse +``` + +Methods: + +- client.page_shield.update(\*, zone_id, \*\*params) -> Optional[PageShieldUpdateResponse] +- client.page_shield.get(\*, zone_id) -> Optional[Setting] + +## Policies + +Types: + +```python +from cloudflare.types.page_shield import ( + Policy, + PolicyCreateResponse, + PolicyUpdateResponse, + PolicyListResponse, + PolicyGetResponse, +) +``` + +Methods: + +- 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[PolicyGetResponse] + +## Connections + +Types: + +```python +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[Connection] + +## Scripts + +Types: + +```python +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[ScriptGetResponse] + +## Cookies + +Types: + +```python +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[CookieGetResponse] diff --git a/src/cloudflare/resources/page_shield/connections.py b/src/cloudflare/resources/page_shield/connections.py index d04b4fdf6fe..39b35f56263 100644 --- a/src/cloudflare/resources/page_shield/connections.py +++ b/src/cloudflare/resources/page_shield/connections.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> ConnectionsResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, exclude_cdn_cgi: bool | Omit = omit, exclude_urls: str | Omit = omit, @@ -127,10 +127,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/connections", + path_template("/zones/{zone_id}/page_shield/connections", zone_id=zone_id), page=SyncSinglePage[Connection], options=make_request_options( extra_headers=extra_headers, @@ -162,7 +164,7 @@ def get( self, connection_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -186,12 +188,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") return self._get( - f"/zones/{zone_id}/page_shield/connections/{connection_id}", + path_template( + "/zones/{zone_id}/page_shield/connections/{connection_id}", zone_id=zone_id, connection_id=connection_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -226,7 +232,7 @@ def with_streaming_response(self) -> AsyncConnectionsResourceWithStreamingRespon def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, exclude_cdn_cgi: bool | Omit = omit, exclude_urls: str | Omit = omit, @@ -304,10 +310,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/connections", + path_template("/zones/{zone_id}/page_shield/connections", zone_id=zone_id), page=AsyncSinglePage[Connection], options=make_request_options( extra_headers=extra_headers, @@ -339,7 +347,7 @@ async def get( self, connection_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -363,12 +371,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") return await self._get( - f"/zones/{zone_id}/page_shield/connections/{connection_id}", + path_template( + "/zones/{zone_id}/page_shield/connections/{connection_id}", zone_id=zone_id, connection_id=connection_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/page_shield/cookies.py b/src/cloudflare/resources/page_shield/cookies.py index cc5192361bc..0c07ee9c55d 100644 --- a/src/cloudflare/resources/page_shield/cookies.py +++ b/src/cloudflare/resources/page_shield/cookies.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> CookiesResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, domain: str | Omit = omit, export: Literal["csv"] | Omit = omit, @@ -130,10 +130,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/cookies", + path_template("/zones/{zone_id}/page_shield/cookies", zone_id=zone_id), page=SyncSinglePage[CookieListResponse], options=make_request_options( extra_headers=extra_headers, @@ -167,7 +169,7 @@ def get( self, cookie_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -191,12 +193,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not cookie_id: raise ValueError(f"Expected a non-empty value for `cookie_id` but received {cookie_id!r}") return self._get( - f"/zones/{zone_id}/page_shield/cookies/{cookie_id}", + path_template("/zones/{zone_id}/page_shield/cookies/{cookie_id}", zone_id=zone_id, cookie_id=cookie_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -231,7 +235,7 @@ def with_streaming_response(self) -> AsyncCookiesResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, domain: str | Omit = omit, export: Literal["csv"] | Omit = omit, @@ -311,10 +315,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/cookies", + path_template("/zones/{zone_id}/page_shield/cookies", zone_id=zone_id), page=AsyncSinglePage[CookieListResponse], options=make_request_options( extra_headers=extra_headers, @@ -348,7 +354,7 @@ async def get( self, cookie_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -372,12 +378,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not cookie_id: raise ValueError(f"Expected a non-empty value for `cookie_id` but received {cookie_id!r}") return await self._get( - f"/zones/{zone_id}/page_shield/cookies/{cookie_id}", + path_template("/zones/{zone_id}/page_shield/cookies/{cookie_id}", zone_id=zone_id, cookie_id=cookie_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/page_shield/page_shield.py b/src/cloudflare/resources/page_shield/page_shield.py index 671b12446f8..958bb7f0054 100644 --- a/src/cloudflare/resources/page_shield/page_shield.py +++ b/src/cloudflare/resources/page_shield/page_shield.py @@ -23,7 +23,7 @@ AsyncScriptsResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .policies import ( PoliciesResource, AsyncPoliciesResource, @@ -96,7 +96,7 @@ def with_streaming_response(self) -> PageShieldResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, enabled: bool | Omit = omit, use_cloudflare_reporting_endpoint: bool | Omit = omit, use_connection_url_path: bool | Omit = omit, @@ -128,10 +128,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/page_shield", + path_template("/zones/{zone_id}/page_shield", zone_id=zone_id), body=maybe_transform( { "enabled": enabled, @@ -153,7 +155,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -175,10 +177,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/page_shield", + path_template("/zones/{zone_id}/page_shield", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,7 +233,7 @@ def with_streaming_response(self) -> AsyncPageShieldResourceWithStreamingRespons async def update( self, *, - zone_id: str, + zone_id: str | None = None, enabled: bool | Omit = omit, use_cloudflare_reporting_endpoint: bool | Omit = omit, use_connection_url_path: bool | Omit = omit, @@ -261,10 +265,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/page_shield", + path_template("/zones/{zone_id}/page_shield", zone_id=zone_id), body=await async_maybe_transform( { "enabled": enabled, @@ -286,7 +292,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -308,10 +314,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/page_shield", + path_template("/zones/{zone_id}/page_shield", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/page_shield/policies.py b/src/cloudflare/resources/page_shield/policies.py index c14c60eaae1..3fbf27ba258 100644 --- a/src/cloudflare/resources/page_shield/policies.py +++ b/src/cloudflare/resources/page_shield/policies.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, action: Literal["allow", "log", "add_reporting_directives"], description: str, enabled: bool, @@ -90,10 +90,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/policies", + path_template("/zones/{zone_id}/page_shield/policies", zone_id=zone_id), body=maybe_transform( { "action": action, @@ -118,7 +120,7 @@ def update( self, policy_id: str, *, - zone_id: str, + zone_id: str | None = None, action: Literal["allow", "log", "add_reporting_directives"] | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, @@ -158,12 +160,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._put( - f"/zones/{zone_id}/page_shield/policies/{policy_id}", + path_template("/zones/{zone_id}/page_shield/policies/{policy_id}", zone_id=zone_id, policy_id=policy_id), body=maybe_transform( { "action": action, @@ -187,7 +191,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -209,10 +213,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/policies", + path_template("/zones/{zone_id}/page_shield/policies", zone_id=zone_id), page=SyncSinglePage[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -224,7 +230,7 @@ def delete( self, policy_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -248,13 +254,15 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/zones/{zone_id}/page_shield/policies/{policy_id}", + path_template("/zones/{zone_id}/page_shield/policies/{policy_id}", zone_id=zone_id, policy_id=policy_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -265,7 +273,7 @@ def get( self, policy_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -289,12 +297,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get( - f"/zones/{zone_id}/page_shield/policies/{policy_id}", + path_template("/zones/{zone_id}/page_shield/policies/{policy_id}", zone_id=zone_id, policy_id=policy_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -329,7 +339,7 @@ def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, action: Literal["allow", "log", "add_reporting_directives"], description: str, enabled: bool, @@ -367,10 +377,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/policies", + path_template("/zones/{zone_id}/page_shield/policies", zone_id=zone_id), body=await async_maybe_transform( { "action": action, @@ -395,7 +407,7 @@ async def update( self, policy_id: str, *, - zone_id: str, + zone_id: str | None = None, action: Literal["allow", "log", "add_reporting_directives"] | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, @@ -435,12 +447,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._put( - f"/zones/{zone_id}/page_shield/policies/{policy_id}", + path_template("/zones/{zone_id}/page_shield/policies/{policy_id}", zone_id=zone_id, policy_id=policy_id), body=await async_maybe_transform( { "action": action, @@ -464,7 +478,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -486,10 +500,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/policies", + path_template("/zones/{zone_id}/page_shield/policies", zone_id=zone_id), page=AsyncSinglePage[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -501,7 +517,7 @@ async def delete( self, policy_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -525,13 +541,15 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/zones/{zone_id}/page_shield/policies/{policy_id}", + path_template("/zones/{zone_id}/page_shield/policies/{policy_id}", zone_id=zone_id, policy_id=policy_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -542,7 +560,7 @@ async def get( self, policy_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -566,12 +584,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._get( - f"/zones/{zone_id}/page_shield/policies/{policy_id}", + path_template("/zones/{zone_id}/page_shield/policies/{policy_id}", zone_id=zone_id, policy_id=policy_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/page_shield/scripts.py b/src/cloudflare/resources/page_shield/scripts.py index 08198419498..aabe35b99b7 100644 --- a/src/cloudflare/resources/page_shield/scripts.py +++ b/src/cloudflare/resources/page_shield/scripts.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> ScriptsResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, exclude_cdn_cgi: bool | Omit = omit, exclude_duplicates: bool | Omit = omit, @@ -133,10 +133,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/scripts", + path_template("/zones/{zone_id}/page_shield/scripts", zone_id=zone_id), page=SyncSinglePage[Script], options=make_request_options( extra_headers=extra_headers, @@ -169,7 +171,7 @@ def get( self, script_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -193,12 +195,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not script_id: raise ValueError(f"Expected a non-empty value for `script_id` but received {script_id!r}") return self._get( - f"/zones/{zone_id}/page_shield/scripts/{script_id}", + path_template("/zones/{zone_id}/page_shield/scripts/{script_id}", zone_id=zone_id, script_id=script_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -233,7 +237,7 @@ def with_streaming_response(self) -> AsyncScriptsResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, exclude_cdn_cgi: bool | Omit = omit, exclude_duplicates: bool | Omit = omit, @@ -316,10 +320,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/page_shield/scripts", + path_template("/zones/{zone_id}/page_shield/scripts", zone_id=zone_id), page=AsyncSinglePage[Script], options=make_request_options( extra_headers=extra_headers, @@ -352,7 +358,7 @@ async def get( self, script_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -376,12 +382,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not script_id: raise ValueError(f"Expected a non-empty value for `script_id` but received {script_id!r}") return await self._get( - f"/zones/{zone_id}/page_shield/scripts/{script_id}", + path_template("/zones/{zone_id}/page_shield/scripts/{script_id}", zone_id=zone_id, script_id=script_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/pages/api.md b/src/cloudflare/resources/pages/api.md new file mode 100644 index 00000000000..c8d1cc4548e --- /dev/null +++ b/src/cloudflare/resources/pages/api.md @@ -0,0 +1,64 @@ +# Pages + +## Projects + +Types: + +```python +from cloudflare.types.pages import Deployment, Project, Stage +``` + +Methods: + +- 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 + +### Deployments + +Methods: + +- 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, \*\*params) -> 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 + +#### History + +##### Logs + +Types: + +```python +from cloudflare.types.pages.projects.deployments.history import LogGetResponse +``` + +Methods: + +- client.pages.projects.deployments.history.logs.get(deployment_id, \*, account_id, project_name) -> LogGetResponse + +### Domains + +Types: + +```python +from cloudflare.types.pages.projects import ( + DomainCreateResponse, + DomainListResponse, + DomainEditResponse, + DomainGetResponse, +) +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/pages/projects/deployments/deployments.py b/src/cloudflare/resources/pages/projects/deployments/deployments.py index 6f0c6a5b3e7..307538717c8 100644 --- a/src/cloudflare/resources/pages/projects/deployments/deployments.py +++ b/src/cloudflare/resources/pages/projects/deployments/deployments.py @@ -8,7 +8,7 @@ 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 ....._utils import extract_files, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -28,7 +28,7 @@ AsyncHistoryResourceWithStreamingResponse, ) from ....._base_client import AsyncPaginator, make_request_options -from .....types.pages.projects import deployment_list_params, deployment_create_params +from .....types.pages.projects import deployment_list_params, deployment_create_params, deployment_delete_params from .....types.pages.deployment import Deployment __all__ = ["DeploymentsResource", "AsyncDeploymentsResource"] @@ -62,7 +62,7 @@ def create( self, project_name: str, *, - account_id: str, + account_id: str | None = None, _headers: FileTypes | Omit = omit, _redirects: FileTypes | Omit = omit, _routes_json: FileTypes | Omit = omit, @@ -132,6 +132,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -169,7 +171,11 @@ def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments", + account_id=account_id, + project_name=project_name, + ), body=maybe_transform(body, deployment_create_params.DeploymentCreateParams), files=files, options=make_request_options( @@ -186,7 +192,7 @@ def list( self, project_name: str, *, - account_id: str, + account_id: str | None = None, env: Literal["production", "preview"] | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -219,12 +225,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return self._get_api_list( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments", + account_id=account_id, + project_name=project_name, + ), page=SyncV4PagePaginationArray[Deployment], options=make_request_options( extra_headers=extra_headers, @@ -247,8 +259,9 @@ def delete( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_name: str, + force: 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, @@ -266,6 +279,9 @@ def delete( deployment_id: Identifier. + force: Allow deletion of aliased non-production deployments when a normal delete would + be rejected. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -274,6 +290,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -281,12 +299,18 @@ def delete( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return self._delete( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, + query=maybe_transform({"force": force}, deployment_delete_params.DeploymentDeleteParams), post_parser=ResultWrapper[Optional[object]]._unwrapper, ), cast_to=cast(Type[object], ResultWrapper[object]), @@ -296,7 +320,7 @@ def get( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -323,6 +347,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -330,7 +356,12 @@ def get( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return self._get( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -345,7 +376,7 @@ def retry( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -372,6 +403,8 @@ def retry( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -379,7 +412,12 @@ def retry( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/retry", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/retry", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -394,7 +432,7 @@ def rollback( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -423,6 +461,8 @@ def rollback( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -430,7 +470,12 @@ def rollback( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/rollback", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/rollback", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -470,7 +515,7 @@ async def create( self, project_name: str, *, - account_id: str, + account_id: str | None = None, _headers: FileTypes | Omit = omit, _redirects: FileTypes | Omit = omit, _routes_json: FileTypes | Omit = omit, @@ -540,6 +585,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -577,7 +624,11 @@ async def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments", + account_id=account_id, + project_name=project_name, + ), body=await async_maybe_transform(body, deployment_create_params.DeploymentCreateParams), files=files, options=make_request_options( @@ -594,7 +645,7 @@ def list( self, project_name: str, *, - account_id: str, + account_id: str | None = None, env: Literal["production", "preview"] | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -627,12 +678,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return self._get_api_list( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments", + account_id=account_id, + project_name=project_name, + ), page=AsyncV4PagePaginationArray[Deployment], options=make_request_options( extra_headers=extra_headers, @@ -655,8 +712,9 @@ async def delete( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_name: str, + force: 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, @@ -674,6 +732,9 @@ async def delete( deployment_id: Identifier. + force: Allow deletion of aliased non-production deployments when a normal delete would + be rejected. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -682,6 +743,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -689,12 +752,18 @@ async def delete( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return await self._delete( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, + query=await async_maybe_transform({"force": force}, deployment_delete_params.DeploymentDeleteParams), post_parser=ResultWrapper[Optional[object]]._unwrapper, ), cast_to=cast(Type[object], ResultWrapper[object]), @@ -704,7 +773,7 @@ async def get( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -731,6 +800,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -738,7 +809,12 @@ async def get( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return await self._get( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -753,7 +829,7 @@ async def retry( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -780,6 +856,8 @@ async def retry( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -787,7 +865,12 @@ async def retry( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return await self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/retry", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/retry", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -802,7 +885,7 @@ async def rollback( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -831,6 +914,8 @@ async def rollback( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -838,7 +923,12 @@ async def rollback( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return await self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/rollback", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/rollback", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/pages/projects/deployments/history/logs.py b/src/cloudflare/resources/pages/projects/deployments/history/logs.py index 4cc468de7a0..06c00834088 100644 --- a/src/cloudflare/resources/pages/projects/deployments/history/logs.py +++ b/src/cloudflare/resources/pages/projects/deployments/history/logs.py @@ -7,6 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given +from ......_utils import path_template from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -46,7 +47,7 @@ def get( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -73,6 +74,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -80,7 +83,12 @@ def get( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return self._get( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/history/logs", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/history/logs", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -116,7 +124,7 @@ async def get( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -143,6 +151,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -150,7 +160,12 @@ async def get( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return await self._get( - f"/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/history/logs", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/history/logs", + account_id=account_id, + project_name=project_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/pages/projects/domains.py b/src/cloudflare/resources/pages/projects/domains.py index 58f4f9317d5..49e44c2c5f7 100644 --- a/src/cloudflare/resources/pages/projects/domains.py +++ b/src/cloudflare/resources/pages/projects/domains.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def create( self, project_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -79,12 +79,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/domains", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains", + account_id=account_id, + project_name=project_name, + ), body=maybe_transform({"name": name}, domain_create_params.DomainCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -100,7 +106,7 @@ def list( self, project_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -124,12 +130,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return self._get_api_list( - f"/accounts/{account_id}/pages/projects/{project_name}/domains", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains", + account_id=account_id, + project_name=project_name, + ), page=SyncSinglePage[DomainListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -141,7 +153,7 @@ def delete( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -168,6 +180,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -175,7 +189,12 @@ def delete( if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return self._delete( - f"/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + account_id=account_id, + project_name=project_name, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -190,7 +209,7 @@ def edit( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -217,6 +236,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -224,7 +245,12 @@ def edit( if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return self._patch( - f"/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + account_id=account_id, + project_name=project_name, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -239,7 +265,7 @@ def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -266,6 +292,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -273,7 +301,12 @@ def get( if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return self._get( - f"/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + account_id=account_id, + project_name=project_name, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -309,7 +342,7 @@ async def create( self, project_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -336,12 +369,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return await self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/domains", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains", + account_id=account_id, + project_name=project_name, + ), body=await async_maybe_transform({"name": name}, domain_create_params.DomainCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -357,7 +396,7 @@ def list( self, project_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -381,12 +420,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return self._get_api_list( - f"/accounts/{account_id}/pages/projects/{project_name}/domains", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains", + account_id=account_id, + project_name=project_name, + ), page=AsyncSinglePage[DomainListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -398,7 +443,7 @@ async def delete( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -425,6 +470,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -432,7 +479,12 @@ async def delete( if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return await self._delete( - f"/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + account_id=account_id, + project_name=project_name, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -447,7 +499,7 @@ async def edit( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -474,6 +526,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -481,7 +535,12 @@ async def edit( if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return await self._patch( - f"/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + account_id=account_id, + project_name=project_name, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -496,7 +555,7 @@ async def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, project_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. @@ -523,6 +582,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: @@ -530,7 +591,12 @@ async def get( if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return await self._get( - f"/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/domains/{domain_name}", + account_id=account_id, + project_name=project_name, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/pages/projects/projects.py b/src/cloudflare/resources/pages/projects/projects.py index 8fb14ca403c..cc25f2e0b38 100644 --- a/src/cloudflare/resources/pages/projects/projects.py +++ b/src/cloudflare/resources/pages/projects/projects.py @@ -15,7 +15,7 @@ AsyncDomainsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -72,7 +72,7 @@ def with_streaming_response(self) -> ProjectsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, production_branch: str, build_config: project_create_params.BuildConfig | Omit = omit, @@ -109,10 +109,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pages/projects", + path_template("/accounts/{account_id}/pages/projects", account_id=account_id), body=maybe_transform( { "name": name, @@ -136,7 +138,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -164,10 +166,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pages/projects", + path_template("/accounts/{account_id}/pages/projects", account_id=account_id), page=SyncV4PagePaginationArray[Project], options=make_request_options( extra_headers=extra_headers, @@ -189,7 +193,7 @@ def delete( self, project_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -213,12 +217,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return self._delete( - f"/accounts/{account_id}/pages/projects/{project_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}", account_id=account_id, project_name=project_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -233,7 +241,7 @@ def edit( self, project_name: str, *, - account_id: str, + account_id: str | None = None, build_config: project_edit_params.BuildConfig | Omit = omit, deployment_configs: project_edit_params.DeploymentConfigs | Omit = omit, name: str | Omit = omit, @@ -274,12 +282,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return self._patch( - f"/accounts/{account_id}/pages/projects/{project_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}", account_id=account_id, project_name=project_name + ), body=maybe_transform( { "build_config": build_config, @@ -304,7 +316,7 @@ def get( self, project_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -328,12 +340,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return self._get( - f"/accounts/{account_id}/pages/projects/{project_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}", account_id=account_id, project_name=project_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -348,7 +364,7 @@ def purge_build_cache( self, project_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -372,12 +388,18 @@ def purge_build_cache( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/purge_build_cache", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/purge_build_cache", + account_id=account_id, + project_name=project_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -420,7 +442,7 @@ def with_streaming_response(self) -> AsyncProjectsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, production_branch: str, build_config: project_create_params.BuildConfig | Omit = omit, @@ -457,10 +479,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pages/projects", + path_template("/accounts/{account_id}/pages/projects", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -484,7 +508,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -512,10 +536,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pages/projects", + path_template("/accounts/{account_id}/pages/projects", account_id=account_id), page=AsyncV4PagePaginationArray[Project], options=make_request_options( extra_headers=extra_headers, @@ -537,7 +563,7 @@ async def delete( self, project_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -561,12 +587,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return await self._delete( - f"/accounts/{account_id}/pages/projects/{project_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}", account_id=account_id, project_name=project_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -581,7 +611,7 @@ async def edit( self, project_name: str, *, - account_id: str, + account_id: str | None = None, build_config: project_edit_params.BuildConfig | Omit = omit, deployment_configs: project_edit_params.DeploymentConfigs | Omit = omit, name: str | Omit = omit, @@ -622,12 +652,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return await self._patch( - f"/accounts/{account_id}/pages/projects/{project_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}", account_id=account_id, project_name=project_name + ), body=await async_maybe_transform( { "build_config": build_config, @@ -652,7 +686,7 @@ async def get( self, project_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -676,12 +710,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return await self._get( - f"/accounts/{account_id}/pages/projects/{project_name}", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}", account_id=account_id, project_name=project_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -696,7 +734,7 @@ async def purge_build_cache( self, project_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -720,12 +758,18 @@ async def purge_build_cache( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") return await self._post( - f"/accounts/{account_id}/pages/projects/{project_name}/purge_build_cache", + path_template( + "/accounts/{account_id}/pages/projects/{project_name}/purge_build_cache", + account_id=account_id, + project_name=project_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/pipelines/api.md b/src/cloudflare/resources/pipelines/api.md new file mode 100644 index 00000000000..acf4580a23b --- /dev/null +++ b/src/cloudflare/resources/pipelines/api.md @@ -0,0 +1,65 @@ +# Pipelines + +Types: + +```python +from cloudflare.types.pipelines import ( + PipelineCreateResponse, + PipelineUpdateResponse, + PipelineListResponse, + PipelineCreateV1Response, + PipelineGetResponse, + PipelineGetV1Response, + PipelineListV1Response, + PipelineValidateSqlResponse, +) +``` + +Methods: + +- 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) -> object +- 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 + +## Sinks + +Types: + +```python +from cloudflare.types.pipelines import SinkCreateResponse, SinkListResponse, SinkGetResponse +``` + +Methods: + +- 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) -> object +- client.pipelines.sinks.get(sink_id, \*, account_id) -> SinkGetResponse + +## Streams + +Types: + +```python +from cloudflare.types.pipelines import ( + StreamCreateResponse, + StreamUpdateResponse, + StreamListResponse, + StreamGetResponse, +) +``` + +Methods: + +- 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) -> object +- client.pipelines.streams.get(stream_id, \*, account_id) -> StreamGetResponse diff --git a/src/cloudflare/resources/pipelines/pipelines.py b/src/cloudflare/resources/pipelines/pipelines.py index 2c2f42d7756..5bb100dee43 100644 --- a/src/cloudflare/resources/pipelines/pipelines.py +++ b/src/cloudflare/resources/pipelines/pipelines.py @@ -24,7 +24,7 @@ AsyncStreamsResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -88,7 +88,7 @@ def with_streaming_response(self) -> PipelinesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, destination: pipeline_create_params.Destination, name: str, source: Iterable[pipeline_create_params.Source], @@ -117,10 +117,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines", + path_template("/accounts/{account_id}/pipelines", account_id=account_id), body=maybe_transform( { "destination": destination, @@ -144,7 +146,7 @@ def update( self, pipeline_name: str, *, - account_id: str, + account_id: str | None = None, destination: pipeline_update_params.Destination, name: str, source: Iterable[pipeline_update_params.Source], @@ -175,12 +177,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_name: raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}") return self._put( - f"/accounts/{account_id}/pipelines/{pipeline_name}", + path_template( + "/accounts/{account_id}/pipelines/{pipeline_name}", account_id=account_id, pipeline_name=pipeline_name + ), body=maybe_transform( { "destination": destination, @@ -203,7 +209,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: str | Omit = omit, per_page: str | Omit = omit, search: str | Omit = omit, @@ -236,10 +242,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines", + path_template("/accounts/{account_id}/pipelines", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -262,7 +270,7 @@ def delete( self, pipeline_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -288,13 +296,17 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_name: raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/pipelines/{pipeline_name}", + path_template( + "/accounts/{account_id}/pipelines/{pipeline_name}", account_id=account_id, pipeline_name=pipeline_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -304,7 +316,7 @@ def delete( def create_v1( self, *, - account_id: str, + account_id: str | None = None, name: str, sql: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -332,10 +344,12 @@ def create_v1( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/pipelines", + path_template("/accounts/{account_id}/pipelines/v1/pipelines", account_id=account_id), body=maybe_transform( { "name": name, @@ -357,7 +371,7 @@ def delete_v1( self, pipeline_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -381,12 +395,18 @@ def delete_v1( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_id: raise ValueError(f"Expected a non-empty value for `pipeline_id` but received {pipeline_id!r}") return self._delete( - f"/accounts/{account_id}/pipelines/v1/pipelines/{pipeline_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/pipelines/{pipeline_id}", + account_id=account_id, + pipeline_id=pipeline_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -402,7 +422,7 @@ def get( self, pipeline_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -428,12 +448,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_name: raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}") return self._get( - f"/accounts/{account_id}/pipelines/{pipeline_name}", + path_template( + "/accounts/{account_id}/pipelines/{pipeline_name}", account_id=account_id, pipeline_name=pipeline_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -448,7 +472,7 @@ def get_v1( self, pipeline_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -472,12 +496,18 @@ def get_v1( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_id: raise ValueError(f"Expected a non-empty value for `pipeline_id` but received {pipeline_id!r}") return self._get( - f"/accounts/{account_id}/pipelines/v1/pipelines/{pipeline_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/pipelines/{pipeline_id}", + account_id=account_id, + pipeline_id=pipeline_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -491,7 +521,7 @@ def get_v1( def list_v1( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -515,10 +545,12 @@ def list_v1( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/pipelines", + path_template("/accounts/{account_id}/pipelines/v1/pipelines", account_id=account_id), page=SyncV4PagePaginationArray[PipelineListV1Response], options=make_request_options( extra_headers=extra_headers, @@ -539,7 +571,7 @@ def list_v1( def validate_sql( self, *, - account_id: str, + account_id: str | None = None, sql: 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. @@ -564,10 +596,12 @@ def validate_sql( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/validate_sql", + path_template("/accounts/{account_id}/pipelines/v1/validate_sql", account_id=account_id), body=maybe_transform({"sql": sql}, pipeline_validate_sql_params.PipelineValidateSqlParams), options=make_request_options( extra_headers=extra_headers, @@ -612,7 +646,7 @@ def with_streaming_response(self) -> AsyncPipelinesResourceWithStreamingResponse async def create( self, *, - account_id: str, + account_id: str | None = None, destination: pipeline_create_params.Destination, name: str, source: Iterable[pipeline_create_params.Source], @@ -641,10 +675,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines", + path_template("/accounts/{account_id}/pipelines", account_id=account_id), body=await async_maybe_transform( { "destination": destination, @@ -668,7 +704,7 @@ async def update( self, pipeline_name: str, *, - account_id: str, + account_id: str | None = None, destination: pipeline_update_params.Destination, name: str, source: Iterable[pipeline_update_params.Source], @@ -699,12 +735,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_name: raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}") return await self._put( - f"/accounts/{account_id}/pipelines/{pipeline_name}", + path_template( + "/accounts/{account_id}/pipelines/{pipeline_name}", account_id=account_id, pipeline_name=pipeline_name + ), body=await async_maybe_transform( { "destination": destination, @@ -727,7 +767,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, page: str | Omit = omit, per_page: str | Omit = omit, search: str | Omit = omit, @@ -760,10 +800,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines", + path_template("/accounts/{account_id}/pipelines", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -786,7 +828,7 @@ async def delete( self, pipeline_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -812,13 +854,17 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_name: raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/pipelines/{pipeline_name}", + path_template( + "/accounts/{account_id}/pipelines/{pipeline_name}", account_id=account_id, pipeline_name=pipeline_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -828,7 +874,7 @@ async def delete( async def create_v1( self, *, - account_id: str, + account_id: str | None = None, name: str, sql: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -856,10 +902,12 @@ async def create_v1( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/pipelines", + path_template("/accounts/{account_id}/pipelines/v1/pipelines", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -881,7 +929,7 @@ async def delete_v1( self, pipeline_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -905,12 +953,18 @@ async def delete_v1( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_id: raise ValueError(f"Expected a non-empty value for `pipeline_id` but received {pipeline_id!r}") return await self._delete( - f"/accounts/{account_id}/pipelines/v1/pipelines/{pipeline_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/pipelines/{pipeline_id}", + account_id=account_id, + pipeline_id=pipeline_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -926,7 +980,7 @@ async def get( self, pipeline_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -952,12 +1006,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_name: raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}") return await self._get( - f"/accounts/{account_id}/pipelines/{pipeline_name}", + path_template( + "/accounts/{account_id}/pipelines/{pipeline_name}", account_id=account_id, pipeline_name=pipeline_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -972,7 +1030,7 @@ async def get_v1( self, pipeline_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -996,12 +1054,18 @@ async def get_v1( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pipeline_id: raise ValueError(f"Expected a non-empty value for `pipeline_id` but received {pipeline_id!r}") return await self._get( - f"/accounts/{account_id}/pipelines/v1/pipelines/{pipeline_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/pipelines/{pipeline_id}", + account_id=account_id, + pipeline_id=pipeline_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1015,7 +1079,7 @@ async def get_v1( def list_v1( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -1039,10 +1103,12 @@ def list_v1( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/pipelines", + path_template("/accounts/{account_id}/pipelines/v1/pipelines", account_id=account_id), page=AsyncV4PagePaginationArray[PipelineListV1Response], options=make_request_options( extra_headers=extra_headers, @@ -1063,7 +1129,7 @@ def list_v1( async def validate_sql( self, *, - account_id: str, + account_id: str | None = None, sql: 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. @@ -1088,10 +1154,12 @@ async def validate_sql( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/validate_sql", + path_template("/accounts/{account_id}/pipelines/v1/validate_sql", account_id=account_id), body=await async_maybe_transform({"sql": sql}, pipeline_validate_sql_params.PipelineValidateSqlParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/pipelines/sinks.py b/src/cloudflare/resources/pipelines/sinks.py index 6a751337462..c806ab64196 100644 --- a/src/cloudflare/resources/pipelines/sinks.py +++ b/src/cloudflare/resources/pipelines/sinks.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> SinksResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, type: Literal["r2", "r2_data_catalog"], config: sink_create_params.Config | Omit = omit, @@ -84,10 +84,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/sinks", + path_template("/accounts/{account_id}/pipelines/v1/sinks", account_id=account_id), body=maybe_transform( { "name": name, @@ -111,7 +113,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, page: float | Omit = omit, per_page: float | Omit = omit, pipeline_id: str | Omit = omit, @@ -136,10 +138,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/sinks", + path_template("/accounts/{account_id}/pipelines/v1/sinks", account_id=account_id), page=SyncV4PagePaginationArray[SinkListResponse], options=make_request_options( extra_headers=extra_headers, @@ -162,7 +166,7 @@ def delete( self, sink_id: str, *, - account_id: str, + account_id: str | None = None, force: 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. @@ -189,12 +193,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sink_id: raise ValueError(f"Expected a non-empty value for `sink_id` but received {sink_id!r}") return self._delete( - f"/accounts/{account_id}/pipelines/v1/sinks/{sink_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/sinks/{sink_id}", account_id=account_id, sink_id=sink_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -210,7 +218,7 @@ def get( self, sink_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -234,12 +242,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sink_id: raise ValueError(f"Expected a non-empty value for `sink_id` but received {sink_id!r}") return self._get( - f"/accounts/{account_id}/pipelines/v1/sinks/{sink_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/sinks/{sink_id}", account_id=account_id, sink_id=sink_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -274,7 +286,7 @@ def with_streaming_response(self) -> AsyncSinksResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, type: Literal["r2", "r2_data_catalog"], config: sink_create_params.Config | Omit = omit, @@ -307,10 +319,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/sinks", + path_template("/accounts/{account_id}/pipelines/v1/sinks", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -334,7 +348,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, page: float | Omit = omit, per_page: float | Omit = omit, pipeline_id: str | Omit = omit, @@ -359,10 +373,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/sinks", + path_template("/accounts/{account_id}/pipelines/v1/sinks", account_id=account_id), page=AsyncV4PagePaginationArray[SinkListResponse], options=make_request_options( extra_headers=extra_headers, @@ -385,7 +401,7 @@ async def delete( self, sink_id: str, *, - account_id: str, + account_id: str | None = None, force: 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. @@ -412,12 +428,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sink_id: raise ValueError(f"Expected a non-empty value for `sink_id` but received {sink_id!r}") return await self._delete( - f"/accounts/{account_id}/pipelines/v1/sinks/{sink_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/sinks/{sink_id}", account_id=account_id, sink_id=sink_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -433,7 +453,7 @@ async def get( self, sink_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -457,12 +477,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sink_id: raise ValueError(f"Expected a non-empty value for `sink_id` but received {sink_id!r}") return await self._get( - f"/accounts/{account_id}/pipelines/v1/sinks/{sink_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/sinks/{sink_id}", account_id=account_id, sink_id=sink_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/pipelines/streams.py b/src/cloudflare/resources/pipelines/streams.py index dcece13f72c..a6d25101d01 100644 --- a/src/cloudflare/resources/pipelines/streams.py +++ b/src/cloudflare/resources/pipelines/streams.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> StreamsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, format: stream_create_params.Format | Omit = omit, http: stream_create_params.HTTP | Omit = omit, @@ -80,10 +80,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/streams", + path_template("/accounts/{account_id}/pipelines/v1/streams", account_id=account_id), body=maybe_transform( { "name": name, @@ -108,7 +110,7 @@ def update( self, stream_id: str, *, - account_id: str, + account_id: str | None = None, http: stream_update_params.HTTP | Omit = omit, worker_binding: stream_update_params.WorkerBinding | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -134,12 +136,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not stream_id: raise ValueError(f"Expected a non-empty value for `stream_id` but received {stream_id!r}") return self._patch( - f"/accounts/{account_id}/pipelines/v1/streams/{stream_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/streams/{stream_id}", account_id=account_id, stream_id=stream_id + ), body=maybe_transform( { "http": http, @@ -160,7 +166,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: float | Omit = omit, per_page: float | Omit = omit, pipeline_id: str | Omit = omit, @@ -187,10 +193,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/streams", + path_template("/accounts/{account_id}/pipelines/v1/streams", account_id=account_id), page=SyncV4PagePaginationArray[StreamListResponse], options=make_request_options( extra_headers=extra_headers, @@ -213,7 +221,7 @@ def delete( self, stream_id: str, *, - account_id: str, + account_id: str | None = None, force: 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. @@ -240,12 +248,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not stream_id: raise ValueError(f"Expected a non-empty value for `stream_id` but received {stream_id!r}") return self._delete( - f"/accounts/{account_id}/pipelines/v1/streams/{stream_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/streams/{stream_id}", account_id=account_id, stream_id=stream_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -261,7 +273,7 @@ def get( self, stream_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -285,12 +297,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not stream_id: raise ValueError(f"Expected a non-empty value for `stream_id` but received {stream_id!r}") return self._get( - f"/accounts/{account_id}/pipelines/v1/streams/{stream_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/streams/{stream_id}", account_id=account_id, stream_id=stream_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -325,7 +341,7 @@ def with_streaming_response(self) -> AsyncStreamsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, format: stream_create_params.Format | Omit = omit, http: stream_create_params.HTTP | Omit = omit, @@ -354,10 +370,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/streams", + path_template("/accounts/{account_id}/pipelines/v1/streams", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -382,7 +400,7 @@ async def update( self, stream_id: str, *, - account_id: str, + account_id: str | None = None, http: stream_update_params.HTTP | Omit = omit, worker_binding: stream_update_params.WorkerBinding | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -408,12 +426,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not stream_id: raise ValueError(f"Expected a non-empty value for `stream_id` but received {stream_id!r}") return await self._patch( - f"/accounts/{account_id}/pipelines/v1/streams/{stream_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/streams/{stream_id}", account_id=account_id, stream_id=stream_id + ), body=await async_maybe_transform( { "http": http, @@ -434,7 +456,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: float | Omit = omit, per_page: float | Omit = omit, pipeline_id: str | Omit = omit, @@ -461,10 +483,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/pipelines/v1/streams", + path_template("/accounts/{account_id}/pipelines/v1/streams", account_id=account_id), page=AsyncV4PagePaginationArray[StreamListResponse], options=make_request_options( extra_headers=extra_headers, @@ -487,7 +511,7 @@ async def delete( self, stream_id: str, *, - account_id: str, + account_id: str | None = None, force: 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. @@ -514,12 +538,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not stream_id: raise ValueError(f"Expected a non-empty value for `stream_id` but received {stream_id!r}") return await self._delete( - f"/accounts/{account_id}/pipelines/v1/streams/{stream_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/streams/{stream_id}", account_id=account_id, stream_id=stream_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -535,7 +563,7 @@ async def get( self, stream_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -559,12 +587,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not stream_id: raise ValueError(f"Expected a non-empty value for `stream_id` but received {stream_id!r}") return await self._get( - f"/accounts/{account_id}/pipelines/v1/streams/{stream_id}", + path_template( + "/accounts/{account_id}/pipelines/v1/streams/{stream_id}", account_id=account_id, stream_id=stream_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/queues/api.md b/src/cloudflare/resources/queues/api.md new file mode 100644 index 00000000000..377d7d6186b --- /dev/null +++ b/src/cloudflare/resources/queues/api.md @@ -0,0 +1,87 @@ +# Queues + +Types: + +```python +from cloudflare.types.queues import Queue, QueueDeleteResponse +``` + +Methods: + +- 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) -> QueueDeleteResponse +- client.queues.edit(queue_id, \*, account_id, \*\*params) -> Optional[Queue] +- client.queues.get(queue_id, \*, account_id) -> Optional[Queue] + +## Messages + +Types: + +```python +from cloudflare.types.queues import ( + MessageAckResponse, + MessageBulkPushResponse, + MessagePullResponse, + MessagePushResponse, +) +``` + +Methods: + +- client.queues.messages.ack(queue_id, \*, account_id, \*\*params) -> Optional[MessageAckResponse] +- client.queues.messages.bulk_push(queue_id, \*, account_id, \*\*params) -> Optional[MessageBulkPushResponse] +- client.queues.messages.pull(queue_id, \*, account_id, \*\*params) -> Optional[MessagePullResponse] +- client.queues.messages.push(queue_id, \*, account_id, \*\*params) -> Optional[MessagePushResponse] + +## 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 ( + SubscriptionCreateResponse, + SubscriptionUpdateResponse, + SubscriptionListResponse, + SubscriptionDeleteResponse, + SubscriptionGetResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/queues/consumers.py b/src/cloudflare/resources/queues/consumers.py index 109a2646d75..1e3f5a0d80c 100644 --- a/src/cloudflare/resources/queues/consumers.py +++ b/src/cloudflare/resources/queues/consumers.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def create( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, script_name: str, type: Literal["worker"], dead_letter_queue: str | Omit = omit, @@ -89,7 +89,7 @@ def create( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, type: Literal["http_pull"], dead_letter_queue: str | Omit = omit, settings: consumer_create_params.MqHTTPConsumerRequestSettings | Omit = omit, @@ -118,12 +118,12 @@ def create( """ ... - @required_args(["account_id", "script_name", "type"], ["account_id", "type"]) + @required_args(["script_name", "type"], ["type"]) def create( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, script_name: str | Omit = omit, type: Literal["worker"] | Literal["http_pull"], dead_letter_queue: str | Omit = omit, @@ -137,6 +137,8 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Consumer]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: @@ -144,7 +146,9 @@ def create( return cast( Optional[Consumer], self._post( - f"/accounts/{account_id}/queues/{queue_id}/consumers", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers", account_id=account_id, queue_id=queue_id + ), body=maybe_transform( { "script_name": script_name, @@ -172,7 +176,7 @@ def update( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_id: str, script_name: str, type: Literal["worker"], @@ -212,7 +216,7 @@ def update( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_id: str, type: Literal["http_pull"], dead_letter_queue: str | Omit = omit, @@ -244,12 +248,12 @@ def update( """ ... - @required_args(["account_id", "queue_id", "script_name", "type"], ["account_id", "queue_id", "type"]) + @required_args(["queue_id", "script_name", "type"], ["queue_id", "type"]) def update( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_id: str, script_name: str | Omit = omit, type: Literal["worker"] | Literal["http_pull"], @@ -264,6 +268,8 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Consumer]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: @@ -273,7 +279,12 @@ def update( return cast( Optional[Consumer], self._put( - f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + account_id=account_id, + queue_id=queue_id, + consumer_id=consumer_id, + ), body=maybe_transform( { "script_name": script_name, @@ -300,7 +311,7 @@ def list( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -324,12 +335,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._get_api_list( - f"/accounts/{account_id}/queues/{queue_id}/consumers", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers", account_id=account_id, queue_id=queue_id + ), page=SyncSinglePage[Consumer], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -341,7 +356,7 @@ def delete( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_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. @@ -368,6 +383,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: @@ -375,7 +392,12 @@ def delete( if not consumer_id: raise ValueError(f"Expected a non-empty value for `consumer_id` but received {consumer_id!r}") return self._delete( - f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + account_id=account_id, + queue_id=queue_id, + consumer_id=consumer_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -386,7 +408,7 @@ def get( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_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. @@ -413,6 +435,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: @@ -422,7 +446,12 @@ def get( return cast( Optional[Consumer], self._get( - f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + account_id=account_id, + queue_id=queue_id, + consumer_id=consumer_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -462,7 +491,7 @@ async def create( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, script_name: str, type: Literal["worker"], dead_letter_queue: str | Omit = omit, @@ -499,7 +528,7 @@ async def create( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, type: Literal["http_pull"], dead_letter_queue: str | Omit = omit, settings: consumer_create_params.MqHTTPConsumerRequestSettings | Omit = omit, @@ -528,12 +557,12 @@ async def create( """ ... - @required_args(["account_id", "script_name", "type"], ["account_id", "type"]) + @required_args(["script_name", "type"], ["type"]) async def create( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, script_name: str | Omit = omit, type: Literal["worker"] | Literal["http_pull"], dead_letter_queue: str | Omit = omit, @@ -547,6 +576,8 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Consumer]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: @@ -554,7 +585,9 @@ async def create( return cast( Optional[Consumer], await self._post( - f"/accounts/{account_id}/queues/{queue_id}/consumers", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers", account_id=account_id, queue_id=queue_id + ), body=await async_maybe_transform( { "script_name": script_name, @@ -582,7 +615,7 @@ async def update( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_id: str, script_name: str, type: Literal["worker"], @@ -622,7 +655,7 @@ async def update( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_id: str, type: Literal["http_pull"], dead_letter_queue: str | Omit = omit, @@ -654,12 +687,12 @@ async def update( """ ... - @required_args(["account_id", "queue_id", "script_name", "type"], ["account_id", "queue_id", "type"]) + @required_args(["queue_id", "script_name", "type"], ["queue_id", "type"]) async def update( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_id: str, script_name: str | Omit = omit, type: Literal["worker"] | Literal["http_pull"], @@ -674,6 +707,8 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Consumer]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: @@ -683,7 +718,12 @@ async def update( return cast( Optional[Consumer], await self._put( - f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + account_id=account_id, + queue_id=queue_id, + consumer_id=consumer_id, + ), body=await async_maybe_transform( { "script_name": script_name, @@ -710,7 +750,7 @@ def list( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -734,12 +774,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._get_api_list( - f"/accounts/{account_id}/queues/{queue_id}/consumers", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers", account_id=account_id, queue_id=queue_id + ), page=AsyncSinglePage[Consumer], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -751,7 +795,7 @@ async def delete( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_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. @@ -778,6 +822,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: @@ -785,7 +831,12 @@ async def delete( if not consumer_id: raise ValueError(f"Expected a non-empty value for `consumer_id` but received {consumer_id!r}") return await self._delete( - f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + account_id=account_id, + queue_id=queue_id, + consumer_id=consumer_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -796,7 +847,7 @@ async def get( self, consumer_id: str, *, - account_id: str, + account_id: str | None = None, queue_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. @@ -823,6 +874,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: @@ -832,7 +885,12 @@ async def get( return cast( Optional[Consumer], await self._get( - f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + path_template( + "/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", + account_id=account_id, + queue_id=queue_id, + consumer_id=consumer_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/queues/messages.py b/src/cloudflare/resources/queues/messages.py index 9148e296028..69e9a3d1341 100644 --- a/src/cloudflare/resources/queues/messages.py +++ b/src/cloudflare/resources/queues/messages.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def ack( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, acks: Iterable[message_ack_params.Ack] | Omit = omit, retries: Iterable[message_ack_params.Retry] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -78,12 +78,16 @@ def ack( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._post( - f"/accounts/{account_id}/queues/{queue_id}/messages/ack", + path_template( + "/accounts/{account_id}/queues/{queue_id}/messages/ack", account_id=account_id, queue_id=queue_id + ), body=maybe_transform( { "acks": acks, @@ -105,7 +109,7 @@ def bulk_push( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, delay_seconds: float | Omit = omit, messages: Iterable[message_bulk_push_params.Message] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -114,7 +118,7 @@ def bulk_push( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> MessageBulkPushResponse: + ) -> Optional[MessageBulkPushResponse]: """ Push a batch of message to a Queue @@ -133,12 +137,16 @@ def bulk_push( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._post( - f"/accounts/{account_id}/queues/{queue_id}/messages/batch", + path_template( + "/accounts/{account_id}/queues/{queue_id}/messages/batch", account_id=account_id, queue_id=queue_id + ), body=maybe_transform( { "delay_seconds": delay_seconds, @@ -147,16 +155,20 @@ def bulk_push( message_bulk_push_params.MessageBulkPushParams, ), 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, + post_parser=ResultWrapper[Optional[MessageBulkPushResponse]]._unwrapper, ), - cast_to=MessageBulkPushResponse, + cast_to=cast(Type[Optional[MessageBulkPushResponse]], ResultWrapper[MessageBulkPushResponse]), ) def pull( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, batch_size: float | Omit = omit, visibility_timeout_ms: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -187,12 +199,16 @@ def pull( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._post( - f"/accounts/{account_id}/queues/{queue_id}/messages/pull", + path_template( + "/accounts/{account_id}/queues/{queue_id}/messages/pull", account_id=account_id, queue_id=queue_id + ), body=maybe_transform( { "batch_size": batch_size, @@ -215,7 +231,7 @@ def push( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, body: str | Omit = omit, content_type: Literal["text"] | Omit = omit, delay_seconds: float | Omit = omit, @@ -225,7 +241,7 @@ def push( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> MessagePushResponse: + ) -> Optional[MessagePushResponse]: """ Push a message to a Queue @@ -252,7 +268,7 @@ def push( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, body: object | Omit = omit, content_type: Literal["json"] | Omit = omit, delay_seconds: float | Omit = omit, @@ -262,7 +278,7 @@ def push( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> MessagePushResponse: + ) -> Optional[MessagePushResponse]: """ Push a message to a Queue @@ -284,12 +300,11 @@ def push( """ ... - @required_args(["account_id"]) def push( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, body: str | object | Omit = omit, content_type: Literal["text"] | Literal["json"] | Omit = omit, delay_seconds: float | Omit = omit, @@ -299,13 +314,17 @@ def push( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> MessagePushResponse: + ) -> Optional[MessagePushResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._post( - f"/accounts/{account_id}/queues/{queue_id}/messages", + path_template( + "/accounts/{account_id}/queues/{queue_id}/messages", account_id=account_id, queue_id=queue_id + ), body=maybe_transform( { "body": body, @@ -315,9 +334,13 @@ def push( message_push_params.MessagePushParams, ), 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, + post_parser=ResultWrapper[Optional[MessagePushResponse]]._unwrapper, ), - cast_to=MessagePushResponse, + cast_to=cast(Type[Optional[MessagePushResponse]], ResultWrapper[MessagePushResponse]), ) @@ -345,7 +368,7 @@ async def ack( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, acks: Iterable[message_ack_params.Ack] | Omit = omit, retries: Iterable[message_ack_params.Retry] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -371,12 +394,16 @@ async def ack( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._post( - f"/accounts/{account_id}/queues/{queue_id}/messages/ack", + path_template( + "/accounts/{account_id}/queues/{queue_id}/messages/ack", account_id=account_id, queue_id=queue_id + ), body=await async_maybe_transform( { "acks": acks, @@ -398,7 +425,7 @@ async def bulk_push( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, delay_seconds: float | Omit = omit, messages: Iterable[message_bulk_push_params.Message] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -407,7 +434,7 @@ async def bulk_push( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> MessageBulkPushResponse: + ) -> Optional[MessageBulkPushResponse]: """ Push a batch of message to a Queue @@ -426,12 +453,16 @@ async def bulk_push( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._post( - f"/accounts/{account_id}/queues/{queue_id}/messages/batch", + path_template( + "/accounts/{account_id}/queues/{queue_id}/messages/batch", account_id=account_id, queue_id=queue_id + ), body=await async_maybe_transform( { "delay_seconds": delay_seconds, @@ -440,16 +471,20 @@ async def bulk_push( message_bulk_push_params.MessageBulkPushParams, ), 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, + post_parser=ResultWrapper[Optional[MessageBulkPushResponse]]._unwrapper, ), - cast_to=MessageBulkPushResponse, + cast_to=cast(Type[Optional[MessageBulkPushResponse]], ResultWrapper[MessageBulkPushResponse]), ) async def pull( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, batch_size: float | Omit = omit, visibility_timeout_ms: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -480,12 +515,16 @@ async def pull( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._post( - f"/accounts/{account_id}/queues/{queue_id}/messages/pull", + path_template( + "/accounts/{account_id}/queues/{queue_id}/messages/pull", account_id=account_id, queue_id=queue_id + ), body=await async_maybe_transform( { "batch_size": batch_size, @@ -508,7 +547,7 @@ async def push( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, body: str | Omit = omit, content_type: Literal["text"] | Omit = omit, delay_seconds: float | Omit = omit, @@ -518,7 +557,7 @@ async def push( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> MessagePushResponse: + ) -> Optional[MessagePushResponse]: """ Push a message to a Queue @@ -545,7 +584,7 @@ async def push( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, body: object | Omit = omit, content_type: Literal["json"] | Omit = omit, delay_seconds: float | Omit = omit, @@ -555,7 +594,7 @@ async def push( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> MessagePushResponse: + ) -> Optional[MessagePushResponse]: """ Push a message to a Queue @@ -577,12 +616,11 @@ async def push( """ ... - @required_args(["account_id"]) async def push( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, body: str | object | Omit = omit, content_type: Literal["text"] | Literal["json"] | Omit = omit, delay_seconds: float | Omit = omit, @@ -592,13 +630,17 @@ async def push( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> MessagePushResponse: + ) -> Optional[MessagePushResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._post( - f"/accounts/{account_id}/queues/{queue_id}/messages", + path_template( + "/accounts/{account_id}/queues/{queue_id}/messages", account_id=account_id, queue_id=queue_id + ), body=await async_maybe_transform( { "body": body, @@ -608,9 +650,13 @@ async def push( message_push_params.MessagePushParams, ), 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, + post_parser=ResultWrapper[Optional[MessagePushResponse]]._unwrapper, ), - cast_to=MessagePushResponse, + cast_to=cast(Type[Optional[MessagePushResponse]], ResultWrapper[MessagePushResponse]), ) diff --git a/src/cloudflare/resources/queues/purge.py b/src/cloudflare/resources/queues/purge.py index 01b13589546..8b35b693f4c 100644 --- a/src/cloudflare/resources/queues/purge.py +++ b/src/cloudflare/resources/queues/purge.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def start( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, delete_messages_permanently: 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. @@ -76,12 +76,14 @@ def start( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._post( - f"/accounts/{account_id}/queues/{queue_id}/purge", + path_template("/accounts/{account_id}/queues/{queue_id}/purge", account_id=account_id, queue_id=queue_id), body=maybe_transform( {"delete_messages_permanently": delete_messages_permanently}, purge_start_params.PurgeStartParams ), @@ -99,7 +101,7 @@ def status( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,12 +125,14 @@ def status( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._get( - f"/accounts/{account_id}/queues/{queue_id}/purge", + path_template("/accounts/{account_id}/queues/{queue_id}/purge", account_id=account_id, queue_id=queue_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -164,7 +168,7 @@ async def start( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, delete_messages_permanently: 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. @@ -191,12 +195,14 @@ async def start( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._post( - f"/accounts/{account_id}/queues/{queue_id}/purge", + path_template("/accounts/{account_id}/queues/{queue_id}/purge", account_id=account_id, queue_id=queue_id), body=await async_maybe_transform( {"delete_messages_permanently": delete_messages_permanently}, purge_start_params.PurgeStartParams ), @@ -214,7 +220,7 @@ async def status( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -238,12 +244,14 @@ async def status( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._get( - f"/accounts/{account_id}/queues/{queue_id}/purge", + path_template("/accounts/{account_id}/queues/{queue_id}/purge", account_id=account_id, queue_id=queue_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/queues/queues.py b/src/cloudflare/resources/queues/queues.py index 3e5d9cc27c0..1595d106cb0 100644 --- a/src/cloudflare/resources/queues/queues.py +++ b/src/cloudflare/resources/queues/queues.py @@ -15,7 +15,7 @@ AsyncPurgeResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .messages import ( MessagesResource, AsyncMessagesResource, @@ -97,7 +97,7 @@ def with_streaming_response(self) -> QueuesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, queue_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. @@ -120,10 +120,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/queues", + path_template("/accounts/{account_id}/queues", account_id=account_id), body=maybe_transform({"queue_name": queue_name}, queue_create_params.QueueCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -139,7 +141,7 @@ def update( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, queue_name: str | Omit = omit, settings: queue_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. @@ -168,12 +170,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._put( - f"/accounts/{account_id}/queues/{queue_id}", + path_template("/accounts/{account_id}/queues/{queue_id}", account_id=account_id, queue_id=queue_id), body=maybe_transform( { "queue_name": queue_name, @@ -194,7 +198,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -216,10 +220,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/queues", + path_template("/accounts/{account_id}/queues", account_id=account_id), page=SyncSinglePage[Queue], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -231,7 +237,7 @@ def delete( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -255,12 +261,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._delete( - f"/accounts/{account_id}/queues/{queue_id}", + path_template("/accounts/{account_id}/queues/{queue_id}", account_id=account_id, queue_id=queue_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -271,7 +279,7 @@ def edit( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, queue_name: str | Omit = omit, settings: queue_edit_params.Settings | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -297,12 +305,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._patch( - f"/accounts/{account_id}/queues/{queue_id}", + path_template("/accounts/{account_id}/queues/{queue_id}", account_id=account_id, queue_id=queue_id), body=maybe_transform( { "queue_name": queue_name, @@ -324,7 +334,7 @@ def get( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -348,12 +358,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._get( - f"/accounts/{account_id}/queues/{queue_id}", + path_template("/accounts/{account_id}/queues/{queue_id}", account_id=account_id, queue_id=queue_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -404,7 +416,7 @@ def with_streaming_response(self) -> AsyncQueuesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, queue_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. @@ -427,10 +439,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/queues", + path_template("/accounts/{account_id}/queues", account_id=account_id), body=await async_maybe_transform({"queue_name": queue_name}, queue_create_params.QueueCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -446,7 +460,7 @@ async def update( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, queue_name: str | Omit = omit, settings: queue_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. @@ -475,12 +489,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._put( - f"/accounts/{account_id}/queues/{queue_id}", + path_template("/accounts/{account_id}/queues/{queue_id}", account_id=account_id, queue_id=queue_id), body=await async_maybe_transform( { "queue_name": queue_name, @@ -501,7 +517,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -523,10 +539,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/queues", + path_template("/accounts/{account_id}/queues", account_id=account_id), page=AsyncSinglePage[Queue], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -538,7 +556,7 @@ async def delete( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -562,12 +580,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._delete( - f"/accounts/{account_id}/queues/{queue_id}", + path_template("/accounts/{account_id}/queues/{queue_id}", account_id=account_id, queue_id=queue_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -578,7 +598,7 @@ async def edit( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, queue_name: str | Omit = omit, settings: queue_edit_params.Settings | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -604,12 +624,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._patch( - f"/accounts/{account_id}/queues/{queue_id}", + path_template("/accounts/{account_id}/queues/{queue_id}", account_id=account_id, queue_id=queue_id), body=await async_maybe_transform( { "queue_name": queue_name, @@ -631,7 +653,7 @@ async def get( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -655,12 +677,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not queue_id: raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._get( - f"/accounts/{account_id}/queues/{queue_id}", + path_template("/accounts/{account_id}/queues/{queue_id}", account_id=account_id, queue_id=queue_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/queues/subscriptions.py b/src/cloudflare/resources/queues/subscriptions.py index 14ec39cc5ce..7f3ea3adda5 100644 --- a/src/cloudflare/resources/queues/subscriptions.py +++ b/src/cloudflare/resources/queues/subscriptions.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> SubscriptionsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, destination: subscription_create_params.Destination | Omit = omit, enabled: bool | Omit = omit, events: SequenceNotStr[str] | Omit = omit, @@ -90,10 +90,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/event_subscriptions/subscriptions", + path_template("/accounts/{account_id}/event_subscriptions/subscriptions", account_id=account_id), body=maybe_transform( { "destination": destination, @@ -118,7 +120,7 @@ def update( self, subscription_id: str, *, - account_id: str, + account_id: str | None = None, destination: subscription_update_params.Destination | Omit = omit, enabled: bool | Omit = omit, events: SequenceNotStr[str] | Omit = omit, @@ -154,12 +156,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_id: raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}") return self._patch( - f"/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + path_template( + "/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + account_id=account_id, + subscription_id=subscription_id, + ), body=maybe_transform( { "destination": destination, @@ -182,7 +190,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["created_at", "name", "enabled", "source"] | Omit = omit, page: int | Omit = omit, @@ -216,10 +224,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/event_subscriptions/subscriptions", + path_template("/accounts/{account_id}/event_subscriptions/subscriptions", account_id=account_id), page=SyncV4PagePaginationArray[SubscriptionListResponse], options=make_request_options( extra_headers=extra_headers, @@ -243,7 +253,7 @@ def delete( self, subscription_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -267,12 +277,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_id: raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}") return self._delete( - f"/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + path_template( + "/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + account_id=account_id, + subscription_id=subscription_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -287,7 +303,7 @@ def get( self, subscription_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -311,12 +327,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_id: raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}") return self._get( - f"/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + path_template( + "/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + account_id=account_id, + subscription_id=subscription_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -351,7 +373,7 @@ def with_streaming_response(self) -> AsyncSubscriptionsResourceWithStreamingResp async def create( self, *, - account_id: str, + account_id: str | None = None, destination: subscription_create_params.Destination | Omit = omit, enabled: bool | Omit = omit, events: SequenceNotStr[str] | Omit = omit, @@ -388,10 +410,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/event_subscriptions/subscriptions", + path_template("/accounts/{account_id}/event_subscriptions/subscriptions", account_id=account_id), body=await async_maybe_transform( { "destination": destination, @@ -416,7 +440,7 @@ async def update( self, subscription_id: str, *, - account_id: str, + account_id: str | None = None, destination: subscription_update_params.Destination | Omit = omit, enabled: bool | Omit = omit, events: SequenceNotStr[str] | Omit = omit, @@ -452,12 +476,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_id: raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}") return await self._patch( - f"/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + path_template( + "/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + account_id=account_id, + subscription_id=subscription_id, + ), body=await async_maybe_transform( { "destination": destination, @@ -480,7 +510,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["created_at", "name", "enabled", "source"] | Omit = omit, page: int | Omit = omit, @@ -514,10 +544,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/event_subscriptions/subscriptions", + path_template("/accounts/{account_id}/event_subscriptions/subscriptions", account_id=account_id), page=AsyncV4PagePaginationArray[SubscriptionListResponse], options=make_request_options( extra_headers=extra_headers, @@ -541,7 +573,7 @@ async def delete( self, subscription_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -565,12 +597,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_id: raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}") return await self._delete( - f"/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + path_template( + "/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + account_id=account_id, + subscription_id=subscription_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -585,7 +623,7 @@ async def get( self, subscription_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -609,12 +647,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subscription_id: raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}") return await self._get( - f"/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + path_template( + "/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}", + account_id=account_id, + subscription_id=subscription_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/api.md b/src/cloudflare/resources/r2/api.md new file mode 100644 index 00000000000..7b2b74dc56f --- /dev/null +++ b/src/cloudflare/resources/r2/api.md @@ -0,0 +1,205 @@ +# R2 + +## Buckets + +Types: + +```python +from cloudflare.types.r2 import Bucket, BucketListResponse +``` + +Methods: + +- 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 + +### Lifecycle + +Types: + +```python +from cloudflare.types.r2.buckets import LifecycleGetResponse +``` + +Methods: + +- client.r2.buckets.lifecycle.update(bucket_name, \*, account_id, \*\*params) -> object +- client.r2.buckets.lifecycle.get(bucket_name, \*, account_id) -> LifecycleGetResponse + +### CORS + +Types: + +```python +from cloudflare.types.r2.buckets import CORSGetResponse +``` + +Methods: + +- 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 + +### Domains + +#### Custom + +Types: + +```python +from cloudflare.types.r2.buckets.domains import ( + CustomCreateResponse, + CustomUpdateResponse, + CustomListResponse, + CustomDeleteResponse, + CustomGetResponse, +) +``` + +Methods: + +- 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 + +#### Managed + +Types: + +```python +from cloudflare.types.r2.buckets.domains import ManagedUpdateResponse, ManagedListResponse +``` + +Methods: + +- client.r2.buckets.domains.managed.update(bucket_name, \*, account_id, \*\*params) -> ManagedUpdateResponse +- client.r2.buckets.domains.managed.list(bucket_name, \*, account_id) -> ManagedListResponse + +### EventNotifications + +Types: + +```python +from cloudflare.types.r2.buckets import EventNotificationListResponse, EventNotificationGetResponse +``` + +Methods: + +- 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 + +### Locks + +Types: + +```python +from cloudflare.types.r2.buckets import LockGetResponse +``` + +Methods: + +- client.r2.buckets.locks.update(bucket_name, \*, account_id, \*\*params) -> object +- client.r2.buckets.locks.get(bucket_name, \*, account_id) -> LockGetResponse + +### Metrics + +Types: + +```python +from cloudflare.types.r2.buckets import MetricListResponse +``` + +Methods: + +- client.r2.buckets.metrics.list(\*, account_id) -> MetricListResponse + +### Sippy + +Types: + +```python +from cloudflare.types.r2.buckets import Provider, Sippy, SippyDeleteResponse +``` + +Methods: + +- 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 + +## TemporaryCredentials + +Types: + +```python +from cloudflare.types.r2 import TemporaryCredential, TemporaryCredentialCreateResponse +``` + +Methods: + +- client.r2.temporary_credentials.create(\*, account_id, \*\*params) -> TemporaryCredentialCreateResponse + +## SuperSlurper + +### Jobs + +Types: + +```python +from cloudflare.types.r2.super_slurper import ( + JobCreateResponse, + JobListResponse, + JobAbortResponse, + JobAbortAllResponse, + JobGetResponse, + JobPauseResponse, + JobProgressResponse, + JobResumeResponse, +) +``` + +Methods: + +- 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 + +#### Logs + +Types: + +```python +from cloudflare.types.r2.super_slurper.jobs import LogListResponse +``` + +Methods: + +- client.r2.super_slurper.jobs.logs.list(job_id, \*, account_id, \*\*params) -> SyncSinglePage[LogListResponse] + +### ConnectivityPrecheck + +Types: + +```python +from cloudflare.types.r2.super_slurper import ( + ConnectivityPrecheckSourceResponse, + ConnectivityPrecheckTargetResponse, +) +``` + +Methods: + +- client.r2.super_slurper.connectivity_precheck.source(\*, account_id, \*\*params) -> Optional[ConnectivityPrecheckSourceResponse] +- client.r2.super_slurper.connectivity_precheck.target(\*, account_id, \*\*params) -> Optional[ConnectivityPrecheckTargetResponse] diff --git a/src/cloudflare/resources/r2/buckets/buckets.py b/src/cloudflare/resources/r2/buckets/buckets.py index 5f7f5e1885d..e78b6c60a80 100644 --- a/src/cloudflare/resources/r2/buckets/buckets.py +++ b/src/cloudflare/resources/r2/buckets/buckets.py @@ -40,7 +40,7 @@ AsyncMetricsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ...._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from .lifecycle import ( LifecycleResource, AsyncLifecycleResource, @@ -133,7 +133,7 @@ def with_streaming_response(self) -> BucketsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, location_hint: Literal["apac", "eeur", "enam", "weur", "wnam", "oc"] | Omit = omit, storage_class: Literal["Standard", "InfrequentAccess"] | Omit = omit, @@ -167,6 +167,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -174,7 +176,7 @@ def create( **(extra_headers or {}), } return self._post( - f"/accounts/{account_id}/r2/buckets", + path_template("/accounts/{account_id}/r2/buckets", account_id=account_id), body=maybe_transform( { "name": name, @@ -196,7 +198,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, name_contains: str | Omit = omit, @@ -241,6 +243,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -248,7 +252,7 @@ def list( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/r2/buckets", + path_template("/accounts/{account_id}/r2/buckets", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -274,7 +278,7 @@ def delete( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -301,6 +305,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -310,7 +316,9 @@ def delete( **(extra_headers or {}), } return self._delete( - f"/accounts/{account_id}/r2/buckets/{bucket_name}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -325,7 +333,7 @@ def edit( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, storage_class: Literal["Standard", "InfrequentAccess"], jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -355,6 +363,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -369,7 +379,9 @@ def edit( **(extra_headers or {}), } return self._patch( - f"/accounts/{account_id}/r2/buckets/{bucket_name}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -384,7 +396,7 @@ def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -411,6 +423,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -420,7 +434,9 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -483,7 +499,7 @@ def with_streaming_response(self) -> AsyncBucketsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, location_hint: Literal["apac", "eeur", "enam", "weur", "wnam", "oc"] | Omit = omit, storage_class: Literal["Standard", "InfrequentAccess"] | Omit = omit, @@ -517,6 +533,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -524,7 +542,7 @@ async def create( **(extra_headers or {}), } return await self._post( - f"/accounts/{account_id}/r2/buckets", + path_template("/accounts/{account_id}/r2/buckets", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -546,7 +564,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, name_contains: str | Omit = omit, @@ -591,6 +609,8 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = { @@ -598,7 +618,7 @@ async def list( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/r2/buckets", + path_template("/accounts/{account_id}/r2/buckets", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -624,7 +644,7 @@ async def delete( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -651,6 +671,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -660,7 +682,9 @@ async def delete( **(extra_headers or {}), } return await self._delete( - f"/accounts/{account_id}/r2/buckets/{bucket_name}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -675,7 +699,7 @@ async def edit( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, storage_class: Literal["Standard", "InfrequentAccess"], jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -705,6 +729,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -719,7 +745,9 @@ async def edit( **(extra_headers or {}), } return await self._patch( - f"/accounts/{account_id}/r2/buckets/{bucket_name}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -734,7 +762,7 @@ async def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -761,6 +789,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -770,7 +800,9 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/buckets/cors.py b/src/cloudflare/resources/r2/buckets/cors.py index 7868e6da1ce..7c190781897 100644 --- a/src/cloudflare/resources/r2/buckets/cors.py +++ b/src/cloudflare/resources/r2/buckets/cors.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ...._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, rules: Iterable[cors_update_params.Rule] | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,6 +77,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -86,7 +88,9 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/cors", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/cors", account_id=account_id, bucket_name=bucket_name + ), body=maybe_transform({"rules": rules}, cors_update_params.CORSUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -102,7 +106,7 @@ def delete( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -129,6 +133,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -138,7 +144,9 @@ def delete( **(extra_headers or {}), } return self._delete( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/cors", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/cors", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -153,7 +161,7 @@ def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -180,6 +188,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -189,7 +199,9 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/cors", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/cors", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -225,7 +237,7 @@ async def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, rules: Iterable[cors_update_params.Rule] | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -253,6 +265,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -262,7 +276,9 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/cors", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/cors", account_id=account_id, bucket_name=bucket_name + ), body=await async_maybe_transform({"rules": rules}, cors_update_params.CORSUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -278,7 +294,7 @@ async def delete( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -305,6 +321,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -314,7 +332,9 @@ async def delete( **(extra_headers or {}), } return await self._delete( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/cors", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/cors", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -329,7 +349,7 @@ async def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -356,6 +376,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -365,7 +387,9 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/cors", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/cors", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/buckets/domains/custom.py b/src/cloudflare/resources/r2/buckets/domains/custom.py index 800a8520141..6b1bc2cd7e0 100644 --- a/src/cloudflare/resources/r2/buckets/domains/custom.py +++ b/src/cloudflare/resources/r2/buckets/domains/custom.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ....._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -53,7 +53,7 @@ def create( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, domain: str, enabled: bool, zone_id: str, @@ -98,6 +98,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -107,7 +109,11 @@ def create( **(extra_headers or {}), } return self._post( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom", + account_id=account_id, + bucket_name=bucket_name, + ), body=maybe_transform( { "domain": domain, @@ -132,7 +138,7 @@ def update( self, domain: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, ciphers: SequenceNotStr[str] | Omit = omit, enabled: bool | Omit = omit, @@ -173,6 +179,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -184,7 +192,12 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + account_id=account_id, + bucket_name=bucket_name, + domain=domain, + ), body=maybe_transform( { "ciphers": ciphers, @@ -207,7 +220,7 @@ def list( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -234,6 +247,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -243,7 +258,11 @@ def list( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -258,7 +277,7 @@ def delete( self, domain: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -288,6 +307,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -299,7 +320,12 @@ def delete( **(extra_headers or {}), } return self._delete( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + account_id=account_id, + bucket_name=bucket_name, + domain=domain, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -314,7 +340,7 @@ def get( self, domain: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -344,6 +370,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -355,7 +383,12 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + account_id=account_id, + bucket_name=bucket_name, + domain=domain, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -391,7 +424,7 @@ async def create( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, domain: str, enabled: bool, zone_id: str, @@ -436,6 +469,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -445,7 +480,11 @@ async def create( **(extra_headers or {}), } return await self._post( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom", + account_id=account_id, + bucket_name=bucket_name, + ), body=await async_maybe_transform( { "domain": domain, @@ -470,7 +509,7 @@ async def update( self, domain: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, ciphers: SequenceNotStr[str] | Omit = omit, enabled: bool | Omit = omit, @@ -511,6 +550,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -522,7 +563,12 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + account_id=account_id, + bucket_name=bucket_name, + domain=domain, + ), body=await async_maybe_transform( { "ciphers": ciphers, @@ -545,7 +591,7 @@ async def list( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -572,6 +618,8 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -581,7 +629,11 @@ async def list( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -596,7 +648,7 @@ async def delete( self, domain: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -626,6 +678,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -637,7 +691,12 @@ async def delete( **(extra_headers or {}), } return await self._delete( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + account_id=account_id, + bucket_name=bucket_name, + domain=domain, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -652,7 +711,7 @@ async def get( self, domain: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -682,6 +741,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -693,7 +754,12 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}", + account_id=account_id, + bucket_name=bucket_name, + domain=domain, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/buckets/domains/managed.py b/src/cloudflare/resources/r2/buckets/domains/managed.py index 393631a44fa..0ced68fd5c5 100644 --- a/src/cloudflare/resources/r2/buckets/domains/managed.py +++ b/src/cloudflare/resources/r2/buckets/domains/managed.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ....._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -50,7 +50,7 @@ def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, enabled: bool, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -80,6 +80,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -89,7 +91,11 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed", + account_id=account_id, + bucket_name=bucket_name, + ), body=maybe_transform({"enabled": enabled}, managed_update_params.ManagedUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -105,7 +111,7 @@ def list( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -132,6 +138,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -141,7 +149,11 @@ def list( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -177,7 +189,7 @@ async def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, enabled: bool, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -207,6 +219,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -216,7 +230,11 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed", + account_id=account_id, + bucket_name=bucket_name, + ), body=await async_maybe_transform({"enabled": enabled}, managed_update_params.ManagedUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -232,7 +250,7 @@ async def list( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -259,6 +277,8 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -268,7 +288,11 @@ async def list( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/buckets/event_notifications.py b/src/cloudflare/resources/r2/buckets/event_notifications.py index dae2a99ed1a..93613fcaf8e 100644 --- a/src/cloudflare/resources/r2/buckets/event_notifications.py +++ b/src/cloudflare/resources/r2/buckets/event_notifications.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ...._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def update( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, rules: Iterable[event_notification_update_params.Rule], jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, @@ -83,6 +83,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -94,7 +96,12 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + path_template( + "/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + account_id=account_id, + bucket_name=bucket_name, + queue_id=queue_id, + ), body=maybe_transform({"rules": rules}, event_notification_update_params.EventNotificationUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -110,7 +117,7 @@ def list( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -137,6 +144,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -146,7 +155,11 @@ def list( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration", + path_template( + "/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -161,7 +174,7 @@ def delete( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -193,6 +206,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -204,7 +219,12 @@ def delete( **(extra_headers or {}), } return self._delete( - f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + path_template( + "/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + account_id=account_id, + bucket_name=bucket_name, + queue_id=queue_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -219,7 +239,7 @@ def get( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -249,6 +269,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -260,7 +282,12 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + path_template( + "/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + account_id=account_id, + bucket_name=bucket_name, + queue_id=queue_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -296,7 +323,7 @@ async def update( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, rules: Iterable[event_notification_update_params.Rule], jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, @@ -329,6 +356,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -340,7 +369,12 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + path_template( + "/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + account_id=account_id, + bucket_name=bucket_name, + queue_id=queue_id, + ), body=await async_maybe_transform( {"rules": rules}, event_notification_update_params.EventNotificationUpdateParams ), @@ -358,7 +392,7 @@ async def list( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -385,6 +419,8 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -394,7 +430,11 @@ async def list( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration", + path_template( + "/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -409,7 +449,7 @@ async def delete( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -441,6 +481,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -452,7 +494,12 @@ async def delete( **(extra_headers or {}), } return await self._delete( - f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + path_template( + "/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + account_id=account_id, + bucket_name=bucket_name, + queue_id=queue_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -467,7 +514,7 @@ async def get( self, queue_id: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -497,6 +544,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -508,7 +557,12 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + path_template( + "/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}", + account_id=account_id, + bucket_name=bucket_name, + queue_id=queue_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/buckets/lifecycle.py b/src/cloudflare/resources/r2/buckets/lifecycle.py index 03ec914c78c..9f6a37aba29 100644 --- a/src/cloudflare/resources/r2/buckets/lifecycle.py +++ b/src/cloudflare/resources/r2/buckets/lifecycle.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ...._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, rules: Iterable[lifecycle_update_params.Rule] | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,6 +77,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -86,7 +88,11 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle", + account_id=account_id, + bucket_name=bucket_name, + ), body=maybe_transform({"rules": rules}, lifecycle_update_params.LifecycleUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -102,7 +108,7 @@ def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -129,6 +135,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -138,7 +146,11 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -174,7 +186,7 @@ async def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, rules: Iterable[lifecycle_update_params.Rule] | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -202,6 +214,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -211,7 +225,11 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle", + account_id=account_id, + bucket_name=bucket_name, + ), body=await async_maybe_transform({"rules": rules}, lifecycle_update_params.LifecycleUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -227,7 +245,7 @@ async def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -254,6 +272,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -263,7 +283,11 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/buckets/locks.py b/src/cloudflare/resources/r2/buckets/locks.py index 27ddaf78b47..c704a5166d1 100644 --- a/src/cloudflare/resources/r2/buckets/locks.py +++ b/src/cloudflare/resources/r2/buckets/locks.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ...._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, rules: Iterable[lock_update_params.Rule] | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,6 +77,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -86,7 +88,9 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/lock", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/lock", account_id=account_id, bucket_name=bucket_name + ), body=maybe_transform({"rules": rules}, lock_update_params.LockUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -102,7 +106,7 @@ def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -129,6 +133,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -138,7 +144,9 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/lock", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/lock", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -174,7 +182,7 @@ async def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, rules: Iterable[lock_update_params.Rule] | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -202,6 +210,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -211,7 +221,9 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/lock", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/lock", account_id=account_id, bucket_name=bucket_name + ), body=await async_maybe_transform({"rules": rules}, lock_update_params.LockUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -227,7 +239,7 @@ async def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -254,6 +266,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -263,7 +277,9 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/lock", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/lock", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/buckets/metrics.py b/src/cloudflare/resources/r2/buckets/metrics.py index 3be10e1dea6..74747457e17 100644 --- a/src/cloudflare/resources/r2/buckets/metrics.py +++ b/src/cloudflare/resources/r2/buckets/metrics.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> MetricsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -69,10 +70,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/r2/metrics", + path_template("/accounts/{account_id}/r2/metrics", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -107,7 +110,7 @@ def with_streaming_response(self) -> AsyncMetricsResourceWithStreamingResponse: async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -131,10 +134,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/r2/metrics", + path_template("/accounts/{account_id}/r2/metrics", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/buckets/sippy.py b/src/cloudflare/resources/r2/buckets/sippy.py index af73499657f..1d812c34a99 100644 --- a/src/cloudflare/resources/r2/buckets/sippy.py +++ b/src/cloudflare/resources/r2/buckets/sippy.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import is_given, required_args, maybe_transform, strip_not_given, async_maybe_transform +from ...._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, destination: sippy_update_params.R2EnableSippyAwsDestination | Omit = omit, source: sippy_update_params.R2EnableSippyAwsSource | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, @@ -91,7 +91,7 @@ def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, destination: sippy_update_params.R2EnableSippyGcsDestination | Omit = omit, source: sippy_update_params.R2EnableSippyGcsSource | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, @@ -131,7 +131,7 @@ def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, destination: sippy_update_params.R2EnableSippyS3Destination | Omit = omit, source: sippy_update_params.R2EnableSippyS3Source | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, @@ -166,12 +166,11 @@ def update( """ ... - @required_args(["account_id"]) def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, destination: sippy_update_params.R2EnableSippyAwsDestination | sippy_update_params.R2EnableSippyGcsDestination | sippy_update_params.R2EnableSippyS3Destination @@ -188,6 +187,8 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Sippy: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -197,7 +198,9 @@ def update( **(extra_headers or {}), } return self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", account_id=account_id, bucket_name=bucket_name + ), body=maybe_transform( { "destination": destination, @@ -219,7 +222,7 @@ def delete( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -246,6 +249,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -255,7 +260,9 @@ def delete( **(extra_headers or {}), } return self._delete( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -270,7 +277,7 @@ def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -297,6 +304,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -306,7 +315,9 @@ def get( **(extra_headers or {}), } return self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -343,7 +354,7 @@ async def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, destination: sippy_update_params.R2EnableSippyAwsDestination | Omit = omit, source: sippy_update_params.R2EnableSippyAwsSource | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, @@ -383,7 +394,7 @@ async def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, destination: sippy_update_params.R2EnableSippyGcsDestination | Omit = omit, source: sippy_update_params.R2EnableSippyGcsSource | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, @@ -423,7 +434,7 @@ async def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, destination: sippy_update_params.R2EnableSippyS3Destination | Omit = omit, source: sippy_update_params.R2EnableSippyS3Source | Omit = omit, jurisdiction: Literal["default", "eu", "fedramp"] | Omit = omit, @@ -458,12 +469,11 @@ async def update( """ ... - @required_args(["account_id"]) async def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, destination: sippy_update_params.R2EnableSippyAwsDestination | sippy_update_params.R2EnableSippyGcsDestination | sippy_update_params.R2EnableSippyS3Destination @@ -480,6 +490,8 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Sippy: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -489,7 +501,9 @@ async def update( **(extra_headers or {}), } return await self._put( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", account_id=account_id, bucket_name=bucket_name + ), body=await async_maybe_transform( { "destination": destination, @@ -511,7 +525,7 @@ async def delete( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -538,6 +552,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -547,7 +563,9 @@ async def delete( **(extra_headers or {}), } return await self._delete( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -562,7 +580,7 @@ async def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, jurisdiction: Literal["default", "eu", "fedramp"] | 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. @@ -589,6 +607,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -598,7 +618,9 @@ async def get( **(extra_headers or {}), } return await self._get( - f"/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", + path_template( + "/accounts/{account_id}/r2/buckets/{bucket_name}/sippy", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/super_slurper/connectivity_precheck.py b/src/cloudflare/resources/r2/super_slurper/connectivity_precheck.py index 9c06a8df785..7639235c36e 100644 --- a/src/cloudflare/resources/r2/super_slurper/connectivity_precheck.py +++ b/src/cloudflare/resources/r2/super_slurper/connectivity_precheck.py @@ -8,7 +8,7 @@ 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 ...._utils import path_template, required_args, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> ConnectivityPrecheckResourceWithStreamingRe def source( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_source_params.R2SlurperS3SourceSchemaSecret, vendor: Literal["s3"], @@ -85,7 +85,7 @@ def source( def source( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_source_params.R2SlurperGcsSourceSchemaSecret, vendor: Literal["gcs"], @@ -116,7 +116,7 @@ def source( def source( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_source_params.R2SlurperR2SourceSchemaSecret, vendor: Provider, @@ -144,11 +144,11 @@ def source( """ ... - @required_args(["account_id", "bucket", "secret", "vendor"]) + @required_args(["bucket", "secret", "vendor"]) def source( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_source_params.R2SlurperS3SourceSchemaSecret | connectivity_precheck_source_params.R2SlurperGcsSourceSchemaSecret @@ -166,10 +166,12 @@ def source( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ConnectivityPrecheckSourceResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/source/connectivity-precheck", + path_template("/accounts/{account_id}/slurper/source/connectivity-precheck", account_id=account_id), body=maybe_transform( { "bucket": bucket, @@ -198,7 +200,7 @@ def source( def target( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_target_params.Secret, vendor: Provider, @@ -222,10 +224,12 @@ def target( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/target/connectivity-precheck", + path_template("/accounts/{account_id}/slurper/target/connectivity-precheck", account_id=account_id), body=maybe_transform( { "bucket": bucket, @@ -272,7 +276,7 @@ def with_streaming_response(self) -> AsyncConnectivityPrecheckResourceWithStream async def source( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_source_params.R2SlurperS3SourceSchemaSecret, vendor: Literal["s3"], @@ -305,7 +309,7 @@ async def source( async def source( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_source_params.R2SlurperGcsSourceSchemaSecret, vendor: Literal["gcs"], @@ -336,7 +340,7 @@ async def source( async def source( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_source_params.R2SlurperR2SourceSchemaSecret, vendor: Provider, @@ -364,11 +368,11 @@ async def source( """ ... - @required_args(["account_id", "bucket", "secret", "vendor"]) + @required_args(["bucket", "secret", "vendor"]) async def source( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_source_params.R2SlurperS3SourceSchemaSecret | connectivity_precheck_source_params.R2SlurperGcsSourceSchemaSecret @@ -386,10 +390,12 @@ async def source( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ConnectivityPrecheckSourceResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/source/connectivity-precheck", + path_template("/accounts/{account_id}/slurper/source/connectivity-precheck", account_id=account_id), body=await async_maybe_transform( { "bucket": bucket, @@ -418,7 +424,7 @@ async def source( async def target( self, *, - account_id: str, + account_id: str | None = None, bucket: str, secret: connectivity_precheck_target_params.Secret, vendor: Provider, @@ -442,10 +448,12 @@ async def target( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/target/connectivity-precheck", + path_template("/accounts/{account_id}/slurper/target/connectivity-precheck", account_id=account_id), body=await async_maybe_transform( { "bucket": bucket, diff --git a/src/cloudflare/resources/r2/super_slurper/jobs/jobs.py b/src/cloudflare/resources/r2/super_slurper/jobs/jobs.py index 0b55a417eef..4214cde360d 100644 --- a/src/cloudflare/resources/r2/super_slurper/jobs/jobs.py +++ b/src/cloudflare/resources/r2/super_slurper/jobs/jobs.py @@ -15,7 +15,7 @@ AsyncLogsResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -67,7 +67,7 @@ def with_streaming_response(self) -> JobsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, overwrite: bool | Omit = omit, source: job_create_params.Source | Omit = omit, target: job_create_params.Target | Omit = omit, @@ -91,10 +91,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/jobs", + path_template("/accounts/{account_id}/slurper/jobs", account_id=account_id), body=maybe_transform( { "overwrite": overwrite, @@ -116,7 +118,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -138,10 +140,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/jobs", + path_template("/accounts/{account_id}/slurper/jobs", account_id=account_id), page=SyncSinglePage[JobListResponse], options=make_request_options( extra_headers=extra_headers, @@ -163,7 +167,7 @@ def abort( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -185,12 +189,14 @@ def abort( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return self._put( - f"/accounts/{account_id}/slurper/jobs/{job_id}/abort", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}/abort", account_id=account_id, job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -204,7 +210,7 @@ def abort( def abort_all( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -227,10 +233,12 @@ def abort_all( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/jobs/abortAll", + path_template("/accounts/{account_id}/slurper/jobs/abortAll", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -245,7 +253,7 @@ def get( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -266,12 +274,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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}/slurper/jobs/{job_id}", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}", account_id=account_id, job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +296,7 @@ def pause( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -308,12 +318,14 @@ def pause( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return self._put( - f"/accounts/{account_id}/slurper/jobs/{job_id}/pause", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}/pause", account_id=account_id, job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -328,7 +340,7 @@ def progress( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -348,12 +360,16 @@ def progress( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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}/slurper/jobs/{job_id}/progress", + path_template( + "/accounts/{account_id}/slurper/jobs/{job_id}/progress", account_id=account_id, job_id=job_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -368,7 +384,7 @@ def resume( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -389,12 +405,14 @@ def resume( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return self._put( - f"/accounts/{account_id}/slurper/jobs/{job_id}/resume", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}/resume", account_id=account_id, job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -433,7 +451,7 @@ def with_streaming_response(self) -> AsyncJobsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, overwrite: bool | Omit = omit, source: job_create_params.Source | Omit = omit, target: job_create_params.Target | Omit = omit, @@ -457,10 +475,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/jobs", + path_template("/accounts/{account_id}/slurper/jobs", account_id=account_id), body=await async_maybe_transform( { "overwrite": overwrite, @@ -482,7 +502,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -504,10 +524,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/jobs", + path_template("/accounts/{account_id}/slurper/jobs", account_id=account_id), page=AsyncSinglePage[JobListResponse], options=make_request_options( extra_headers=extra_headers, @@ -529,7 +551,7 @@ async def abort( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -551,12 +573,14 @@ async def abort( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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._put( - f"/accounts/{account_id}/slurper/jobs/{job_id}/abort", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}/abort", account_id=account_id, job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -570,7 +594,7 @@ async def abort( async def abort_all( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -593,10 +617,12 @@ async def abort_all( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/slurper/jobs/abortAll", + path_template("/accounts/{account_id}/slurper/jobs/abortAll", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -611,7 +637,7 @@ async def get( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -632,12 +658,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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}/slurper/jobs/{job_id}", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}", account_id=account_id, job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -652,7 +680,7 @@ async def pause( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -674,12 +702,14 @@ async def pause( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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._put( - f"/accounts/{account_id}/slurper/jobs/{job_id}/pause", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}/pause", account_id=account_id, job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -694,7 +724,7 @@ async def progress( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -714,12 +744,16 @@ async def progress( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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}/slurper/jobs/{job_id}/progress", + path_template( + "/accounts/{account_id}/slurper/jobs/{job_id}/progress", account_id=account_id, job_id=job_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -734,7 +768,7 @@ async def resume( self, job_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -755,12 +789,14 @@ async def resume( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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._put( - f"/accounts/{account_id}/slurper/jobs/{job_id}/resume", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}/resume", account_id=account_id, job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2/super_slurper/jobs/logs.py b/src/cloudflare/resources/r2/super_slurper/jobs/logs.py index 461bf6e4c60..82ea9973b1d 100644 --- a/src/cloudflare/resources/r2/super_slurper/jobs/logs.py +++ b/src/cloudflare/resources/r2/super_slurper/jobs/logs.py @@ -5,7 +5,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +46,7 @@ def list( self, job_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -69,12 +69,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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_api_list( - f"/accounts/{account_id}/slurper/jobs/{job_id}/logs", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}/logs", account_id=account_id, job_id=job_id), page=SyncSinglePage[LogListResponse], options=make_request_options( extra_headers=extra_headers, @@ -117,7 +119,7 @@ def list( self, job_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -140,12 +142,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_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_api_list( - f"/accounts/{account_id}/slurper/jobs/{job_id}/logs", + path_template("/accounts/{account_id}/slurper/jobs/{job_id}/logs", account_id=account_id, job_id=job_id), page=AsyncSinglePage[LogListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/r2/temporary_credentials.py b/src/cloudflare/resources/r2/temporary_credentials.py index da82f727df8..0fa765f4e28 100644 --- a/src/cloudflare/resources/r2/temporary_credentials.py +++ b/src/cloudflare/resources/r2/temporary_credentials.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ...types.r2 import temporary_credential_create_params from ..._resource import SyncAPIResource, AsyncAPIResource @@ -48,7 +48,7 @@ def with_streaming_response(self) -> TemporaryCredentialsResourceWithStreamingRe def create( self, *, - account_id: str, + account_id: str | None = None, bucket: str, parent_access_key_id: str, permission: Literal["admin-read-write", "admin-read-only", "object-read-write", "object-read-only"], @@ -89,10 +89,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/r2/temp-access-credentials", + path_template("/accounts/{account_id}/r2/temp-access-credentials", account_id=account_id), body=maybe_transform( { "bucket": bucket, @@ -138,7 +140,7 @@ def with_streaming_response(self) -> AsyncTemporaryCredentialsResourceWithStream async def create( self, *, - account_id: str, + account_id: str | None = None, bucket: str, parent_access_key_id: str, permission: Literal["admin-read-write", "admin-read-only", "object-read-write", "object-read-only"], @@ -179,10 +181,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/r2/temp-access-credentials", + path_template("/accounts/{account_id}/r2/temp-access-credentials", account_id=account_id), body=await async_maybe_transform( { "bucket": bucket, diff --git a/src/cloudflare/resources/r2_data_catalog/api.md b/src/cloudflare/resources/r2_data_catalog/api.md new file mode 100644 index 00000000000..ed93a1f4d67 --- /dev/null +++ b/src/cloudflare/resources/r2_data_catalog/api.md @@ -0,0 +1,80 @@ +# R2DataCatalog + +Types: + +```python +from cloudflare.types.r2_data_catalog import ( + R2DataCatalogListResponse, + R2DataCatalogEnableResponse, + R2DataCatalogGetResponse, +) +``` + +Methods: + +- 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] + +## MaintenanceConfigs + +Types: + +```python +from cloudflare.types.r2_data_catalog import ( + MaintenanceConfigUpdateResponse, + MaintenanceConfigGetResponse, +) +``` + +Methods: + +- 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 + +## Namespaces + +Types: + +```python +from cloudflare.types.r2_data_catalog import NamespaceListResponse +``` + +Methods: + +- client.r2_data_catalog.namespaces.list(bucket_name, \*, account_id, \*\*params) -> Optional[NamespaceListResponse] + +### Tables + +Types: + +```python +from cloudflare.types.r2_data_catalog.namespaces import TableListResponse +``` + +Methods: + +- client.r2_data_catalog.namespaces.tables.list(namespace, \*, account_id, bucket_name, \*\*params) -> Optional[TableListResponse] + +#### MaintenanceConfigs + +Types: + +```python +from cloudflare.types.r2_data_catalog.namespaces.tables import ( + MaintenanceConfigUpdateResponse, + MaintenanceConfigGetResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/r2_data_catalog/credentials.py b/src/cloudflare/resources/r2_data_catalog/credentials.py index 90e2aded873..799269c2605 100644 --- a/src/cloudflare/resources/r2_data_catalog/credentials.py +++ b/src/cloudflare/resources/r2_data_catalog/credentials.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def create( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, token: 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. @@ -76,12 +76,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/credential", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/credential", + account_id=account_id, + bucket_name=bucket_name, + ), body=maybe_transform({"token": token}, credential_create_params.CredentialCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -118,7 +124,7 @@ async def create( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, token: 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. @@ -147,12 +153,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return await self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/credential", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/credential", + account_id=account_id, + bucket_name=bucket_name, + ), body=await async_maybe_transform({"token": token}, credential_create_params.CredentialCreateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/r2_data_catalog/maintenance_configs.py b/src/cloudflare/resources/r2_data_catalog/maintenance_configs.py index a5c71ba3736..c286cdd5c65 100644 --- a/src/cloudflare/resources/r2_data_catalog/maintenance_configs.py +++ b/src/cloudflare/resources/r2_data_catalog/maintenance_configs.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, compaction: maintenance_config_update_params.Compaction | Omit = omit, snapshot_expiration: maintenance_config_update_params.SnapshotExpiration | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -81,12 +81,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs", + account_id=account_id, + bucket_name=bucket_name, + ), body=maybe_transform( { "compaction": compaction, @@ -110,7 +116,7 @@ def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -135,12 +141,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -176,7 +188,7 @@ async def update( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, compaction: maintenance_config_update_params.Compaction | Omit = omit, snapshot_expiration: maintenance_config_update_params.SnapshotExpiration | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -208,12 +220,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return await self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs", + account_id=account_id, + bucket_name=bucket_name, + ), body=await async_maybe_transform( { "compaction": compaction, @@ -237,7 +255,7 @@ async def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -262,12 +280,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return await self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2_data_catalog/namespaces/namespaces.py b/src/cloudflare/resources/r2_data_catalog/namespaces/namespaces.py index 5aeb314566b..ef66e5c123b 100644 --- a/src/cloudflare/resources/r2_data_catalog/namespaces/namespaces.py +++ b/src/cloudflare/resources/r2_data_catalog/namespaces/namespaces.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -60,7 +60,7 @@ def list( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, page_size: int | Omit = omit, page_token: str | Omit = omit, parent: str | Omit = omit, @@ -106,12 +106,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -161,7 +167,7 @@ async def list( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, page_size: int | Omit = omit, page_token: str | Omit = omit, parent: str | Omit = omit, @@ -207,12 +213,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return await self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2_data_catalog/namespaces/tables/maintenance_configs.py b/src/cloudflare/resources/r2_data_catalog/namespaces/tables/maintenance_configs.py index ee8859bf3cb..cded2e8c16e 100644 --- a/src/cloudflare/resources/r2_data_catalog/namespaces/tables/maintenance_configs.py +++ b/src/cloudflare/resources/r2_data_catalog/namespaces/tables/maintenance_configs.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -51,7 +51,7 @@ def update( self, table_name: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, namespace: str, compaction: maintenance_config_update_params.Compaction | Omit = omit, @@ -85,6 +85,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -94,7 +96,13 @@ def update( if not table_name: raise ValueError(f"Expected a non-empty value for `table_name` but received {table_name!r}") return self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs", + account_id=account_id, + bucket_name=bucket_name, + namespace=namespace, + table_name=table_name, + ), body=maybe_transform( { "compaction": compaction, @@ -118,7 +126,7 @@ def get( self, table_name: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, namespace: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -145,6 +153,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -154,7 +164,13 @@ def get( if not table_name: raise ValueError(f"Expected a non-empty value for `table_name` but received {table_name!r}") return self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs", + account_id=account_id, + bucket_name=bucket_name, + namespace=namespace, + table_name=table_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -190,7 +206,7 @@ async def update( self, table_name: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, namespace: str, compaction: maintenance_config_update_params.Compaction | Omit = omit, @@ -224,6 +240,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -233,7 +251,13 @@ async def update( if not table_name: raise ValueError(f"Expected a non-empty value for `table_name` but received {table_name!r}") return await self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs", + account_id=account_id, + bucket_name=bucket_name, + namespace=namespace, + table_name=table_name, + ), body=await async_maybe_transform( { "compaction": compaction, @@ -257,7 +281,7 @@ async def get( self, table_name: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, namespace: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -284,6 +308,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -293,7 +319,13 @@ async def get( if not table_name: raise ValueError(f"Expected a non-empty value for `table_name` but received {table_name!r}") return await self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs", + account_id=account_id, + bucket_name=bucket_name, + namespace=namespace, + table_name=table_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2_data_catalog/namespaces/tables/tables.py b/src/cloudflare/resources/r2_data_catalog/namespaces/tables/tables.py index 6ebef6aa50d..fae6540c757 100644 --- a/src/cloudflare/resources/r2_data_catalog/namespaces/tables/tables.py +++ b/src/cloudflare/resources/r2_data_catalog/namespaces/tables/tables.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -60,7 +60,7 @@ def list( self, namespace: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, page_size: int | Omit = omit, page_token: str | Omit = omit, @@ -102,6 +102,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -109,7 +111,12 @@ def list( if not namespace: raise ValueError(f"Expected a non-empty value for `namespace` but received {namespace!r}") return self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables", + account_id=account_id, + bucket_name=bucket_name, + namespace=namespace, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -158,7 +165,7 @@ async def list( self, namespace: str, *, - account_id: str, + account_id: str | None = None, bucket_name: str, page_size: int | Omit = omit, page_token: str | Omit = omit, @@ -200,6 +207,8 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: @@ -207,7 +216,12 @@ async def list( if not namespace: raise ValueError(f"Expected a non-empty value for `namespace` but received {namespace!r}") return await self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables", + account_id=account_id, + bucket_name=bucket_name, + namespace=namespace, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/r2_data_catalog/r2_data_catalog.py b/src/cloudflare/resources/r2_data_catalog/r2_data_catalog.py index 58d3948f248..a201b27315a 100644 --- a/src/cloudflare/resources/r2_data_catalog/r2_data_catalog.py +++ b/src/cloudflare/resources/r2_data_catalog/r2_data_catalog.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NoneType, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -83,7 +84,7 @@ def with_streaming_response(self) -> R2DataCatalogResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -107,10 +108,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/r2-catalog", + path_template("/accounts/{account_id}/r2-catalog", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -125,7 +128,7 @@ def disable( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -151,13 +154,19 @@ def disable( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/disable", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/disable", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -168,7 +177,7 @@ def enable( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -195,12 +204,16 @@ def enable( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/enable", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/enable", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -215,7 +228,7 @@ def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -240,12 +253,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -292,7 +309,7 @@ def with_streaming_response(self) -> AsyncR2DataCatalogResourceWithStreamingResp async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -316,10 +333,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/r2-catalog", + path_template("/accounts/{account_id}/r2-catalog", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -334,7 +353,7 @@ async def disable( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -360,13 +379,19 @@ async def disable( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/disable", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/disable", + account_id=account_id, + bucket_name=bucket_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -377,7 +402,7 @@ async def enable( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -404,12 +429,16 @@ async def enable( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return await self._post( - f"/accounts/{account_id}/r2-catalog/{bucket_name}/enable", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}/enable", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -424,7 +453,7 @@ async def get( self, bucket_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -449,12 +478,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bucket_name: raise ValueError(f"Expected a non-empty value for `bucket_name` but received {bucket_name!r}") return await self._get( - f"/accounts/{account_id}/r2-catalog/{bucket_name}", + path_template( + "/accounts/{account_id}/r2-catalog/{bucket_name}", account_id=account_id, bucket_name=bucket_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/__init__.py b/src/cloudflare/resources/radar/__init__.py index 2c3d00a3fd1..d614aace062 100644 --- a/src/cloudflare/resources/radar/__init__.py +++ b/src/cloudflare/resources/radar/__init__.py @@ -168,6 +168,14 @@ VerifiedBotsResourceWithStreamingResponse, AsyncVerifiedBotsResourceWithStreamingResponse, ) +from .agent_readiness import ( + AgentReadinessResource, + AsyncAgentReadinessResource, + AgentReadinessResourceWithRawResponse, + AsyncAgentReadinessResourceWithRawResponse, + AgentReadinessResourceWithStreamingResponse, + AsyncAgentReadinessResourceWithStreamingResponse, +) from .traffic_anomalies import ( TrafficAnomaliesResource, AsyncTrafficAnomaliesResource, @@ -194,6 +202,12 @@ ) __all__ = [ + "AgentReadinessResource", + "AsyncAgentReadinessResource", + "AgentReadinessResourceWithRawResponse", + "AsyncAgentReadinessResourceWithRawResponse", + "AgentReadinessResourceWithStreamingResponse", + "AsyncAgentReadinessResourceWithStreamingResponse", "AIResource", "AsyncAIResource", "AIResourceWithRawResponse", diff --git a/src/cloudflare/resources/radar/agent_readiness.py b/src/cloudflare/resources/radar/agent_readiness.py new file mode 100644 index 00000000000..917ad6bbbcd --- /dev/null +++ b/src/cloudflare/resources/radar/agent_readiness.py @@ -0,0 +1,228 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Union, cast +from datetime import date +from typing_extensions import Literal + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import path_template, 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 ...types.radar import agent_readiness_summary_params +from ..._base_client import make_request_options +from ...types.radar.agent_readiness_summary_response import AgentReadinessSummaryResponse + +__all__ = ["AgentReadinessResource", "AsyncAgentReadinessResource"] + + +class AgentReadinessResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AgentReadinessResourceWithRawResponse: + """ + 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 AgentReadinessResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AgentReadinessResourceWithStreamingResponse: + """ + 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 AgentReadinessResourceWithStreamingResponse(self) + + def summary( + self, + dimension: Literal["CHECK"], + *, + date: Union[str, date] | Omit = omit, + domain_category: SequenceNotStr[str] | Omit = omit, + format: Literal["JSON", "CSV"] | Omit = omit, + name: 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, + ) -> AgentReadinessSummaryResponse: + """ + Returns a summary of AI agent readiness scores across scanned domains, grouped + by the specified dimension. Data is sourced from weekly bulk scans. All values + are raw domain counts. + + Args: + dimension: Specifies the agent readiness data dimension by which to group the results. + + date: Filters results by the specified date. + + domain_category: Filters results by domain category. + + format: Format in which results will be returned. + + name: Array of names used to label the series in the response. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 dimension: + raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") + return self._get( + path_template("/radar/agent_readiness/summary/{dimension}", dimension=dimension), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "date": date, + "domain_category": domain_category, + "format": format, + "name": name, + }, + agent_readiness_summary_params.AgentReadinessSummaryParams, + ), + post_parser=ResultWrapper[AgentReadinessSummaryResponse]._unwrapper, + ), + cast_to=cast(Type[AgentReadinessSummaryResponse], ResultWrapper[AgentReadinessSummaryResponse]), + ) + + +class AsyncAgentReadinessResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAgentReadinessResourceWithRawResponse: + """ + 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 AsyncAgentReadinessResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAgentReadinessResourceWithStreamingResponse: + """ + 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 AsyncAgentReadinessResourceWithStreamingResponse(self) + + async def summary( + self, + dimension: Literal["CHECK"], + *, + date: Union[str, date] | Omit = omit, + domain_category: SequenceNotStr[str] | Omit = omit, + format: Literal["JSON", "CSV"] | Omit = omit, + name: 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, + ) -> AgentReadinessSummaryResponse: + """ + Returns a summary of AI agent readiness scores across scanned domains, grouped + by the specified dimension. Data is sourced from weekly bulk scans. All values + are raw domain counts. + + Args: + dimension: Specifies the agent readiness data dimension by which to group the results. + + date: Filters results by the specified date. + + domain_category: Filters results by domain category. + + format: Format in which results will be returned. + + name: Array of names used to label the series in the response. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 dimension: + raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") + return await self._get( + path_template("/radar/agent_readiness/summary/{dimension}", dimension=dimension), + 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, + "domain_category": domain_category, + "format": format, + "name": name, + }, + agent_readiness_summary_params.AgentReadinessSummaryParams, + ), + post_parser=ResultWrapper[AgentReadinessSummaryResponse]._unwrapper, + ), + cast_to=cast(Type[AgentReadinessSummaryResponse], ResultWrapper[AgentReadinessSummaryResponse]), + ) + + +class AgentReadinessResourceWithRawResponse: + def __init__(self, agent_readiness: AgentReadinessResource) -> None: + self._agent_readiness = agent_readiness + + self.summary = to_raw_response_wrapper( + agent_readiness.summary, + ) + + +class AsyncAgentReadinessResourceWithRawResponse: + def __init__(self, agent_readiness: AsyncAgentReadinessResource) -> None: + self._agent_readiness = agent_readiness + + self.summary = async_to_raw_response_wrapper( + agent_readiness.summary, + ) + + +class AgentReadinessResourceWithStreamingResponse: + def __init__(self, agent_readiness: AgentReadinessResource) -> None: + self._agent_readiness = agent_readiness + + self.summary = to_streamed_response_wrapper( + agent_readiness.summary, + ) + + +class AsyncAgentReadinessResourceWithStreamingResponse: + def __init__(self, agent_readiness: AsyncAgentReadinessResource) -> None: + self._agent_readiness = agent_readiness + + self.summary = async_to_streamed_response_wrapper( + agent_readiness.summary, + ) diff --git a/src/cloudflare/resources/radar/ai/__init__.py b/src/cloudflare/resources/radar/ai/__init__.py index 5b5048adbe1..11131dfe584 100644 --- a/src/cloudflare/resources/radar/ai/__init__.py +++ b/src/cloudflare/resources/radar/ai/__init__.py @@ -40,6 +40,14 @@ TimeseriesGroupsResourceWithStreamingResponse, AsyncTimeseriesGroupsResourceWithStreamingResponse, ) +from .markdown_for_agents import ( + MarkdownForAgentsResource, + AsyncMarkdownForAgentsResource, + MarkdownForAgentsResourceWithRawResponse, + AsyncMarkdownForAgentsResourceWithRawResponse, + MarkdownForAgentsResourceWithStreamingResponse, + AsyncMarkdownForAgentsResourceWithStreamingResponse, +) __all__ = [ "ToMarkdownResource", @@ -66,6 +74,12 @@ "AsyncTimeseriesGroupsResourceWithRawResponse", "TimeseriesGroupsResourceWithStreamingResponse", "AsyncTimeseriesGroupsResourceWithStreamingResponse", + "MarkdownForAgentsResource", + "AsyncMarkdownForAgentsResource", + "MarkdownForAgentsResourceWithRawResponse", + "AsyncMarkdownForAgentsResourceWithRawResponse", + "MarkdownForAgentsResourceWithStreamingResponse", + "AsyncMarkdownForAgentsResourceWithStreamingResponse", "AIResource", "AsyncAIResource", "AIResourceWithRawResponse", diff --git a/src/cloudflare/resources/radar/ai/ai.py b/src/cloudflare/resources/radar/ai/ai.py index a0b5b483650..69e33c0d169 100644 --- a/src/cloudflare/resources/radar/ai/ai.py +++ b/src/cloudflare/resources/radar/ai/ai.py @@ -36,6 +36,14 @@ InferenceResourceWithStreamingResponse, AsyncInferenceResourceWithStreamingResponse, ) +from .markdown_for_agents import ( + MarkdownForAgentsResource, + AsyncMarkdownForAgentsResource, + MarkdownForAgentsResourceWithRawResponse, + AsyncMarkdownForAgentsResourceWithRawResponse, + MarkdownForAgentsResourceWithStreamingResponse, + AsyncMarkdownForAgentsResourceWithStreamingResponse, +) __all__ = ["AIResource", "AsyncAIResource"] @@ -57,6 +65,10 @@ def bots(self) -> BotsResource: def timeseries_groups(self) -> TimeseriesGroupsResource: return TimeseriesGroupsResource(self._client) + @cached_property + def markdown_for_agents(self) -> MarkdownForAgentsResource: + return MarkdownForAgentsResource(self._client) + @cached_property def with_raw_response(self) -> AIResourceWithRawResponse: """ @@ -94,6 +106,10 @@ def bots(self) -> AsyncBotsResource: def timeseries_groups(self) -> AsyncTimeseriesGroupsResource: return AsyncTimeseriesGroupsResource(self._client) + @cached_property + def markdown_for_agents(self) -> AsyncMarkdownForAgentsResource: + return AsyncMarkdownForAgentsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAIResourceWithRawResponse: """ @@ -134,6 +150,10 @@ def bots(self) -> BotsResourceWithRawResponse: def timeseries_groups(self) -> TimeseriesGroupsResourceWithRawResponse: return TimeseriesGroupsResourceWithRawResponse(self._ai.timeseries_groups) + @cached_property + def markdown_for_agents(self) -> MarkdownForAgentsResourceWithRawResponse: + return MarkdownForAgentsResourceWithRawResponse(self._ai.markdown_for_agents) + class AsyncAIResourceWithRawResponse: def __init__(self, ai: AsyncAIResource) -> None: @@ -155,6 +175,10 @@ def bots(self) -> AsyncBotsResourceWithRawResponse: def timeseries_groups(self) -> AsyncTimeseriesGroupsResourceWithRawResponse: return AsyncTimeseriesGroupsResourceWithRawResponse(self._ai.timeseries_groups) + @cached_property + def markdown_for_agents(self) -> AsyncMarkdownForAgentsResourceWithRawResponse: + return AsyncMarkdownForAgentsResourceWithRawResponse(self._ai.markdown_for_agents) + class AIResourceWithStreamingResponse: def __init__(self, ai: AIResource) -> None: @@ -176,6 +200,10 @@ def bots(self) -> BotsResourceWithStreamingResponse: def timeseries_groups(self) -> TimeseriesGroupsResourceWithStreamingResponse: return TimeseriesGroupsResourceWithStreamingResponse(self._ai.timeseries_groups) + @cached_property + def markdown_for_agents(self) -> MarkdownForAgentsResourceWithStreamingResponse: + return MarkdownForAgentsResourceWithStreamingResponse(self._ai.markdown_for_agents) + class AsyncAIResourceWithStreamingResponse: def __init__(self, ai: AsyncAIResource) -> None: @@ -196,3 +224,7 @@ def bots(self) -> AsyncBotsResourceWithStreamingResponse: @cached_property def timeseries_groups(self) -> AsyncTimeseriesGroupsResourceWithStreamingResponse: return AsyncTimeseriesGroupsResourceWithStreamingResponse(self._ai.timeseries_groups) + + @cached_property + def markdown_for_agents(self) -> AsyncMarkdownForAgentsResourceWithStreamingResponse: + return AsyncMarkdownForAgentsResourceWithStreamingResponse(self._ai.markdown_for_agents) diff --git a/src/cloudflare/resources/radar/ai/bots/bots.py b/src/cloudflare/resources/radar/ai/bots/bots.py index 579d2e5ff16..7da39261e0c 100644 --- a/src/cloudflare/resources/radar/ai/bots/bots.py +++ b/src/cloudflare/resources/radar/ai/bots/bots.py @@ -17,7 +17,7 @@ AsyncSummaryResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -181,7 +181,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/ai/bots/summary/{dimension}", + path_template("/radar/ai/bots/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -488,7 +488,7 @@ def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/ai/bots/timeseries_groups/{dimension}", + path_template("/radar/ai/bots/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -668,7 +668,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/ai/bots/summary/{dimension}", + path_template("/radar/ai/bots/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -975,7 +975,7 @@ async def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/ai/bots/timeseries_groups/{dimension}", + path_template("/radar/ai/bots/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/ai/inference/inference.py b/src/cloudflare/resources/radar/ai/inference/inference.py index 08ae1e5b9ce..133f6fbe226 100644 --- a/src/cloudflare/resources/radar/ai/inference/inference.py +++ b/src/cloudflare/resources/radar/ai/inference/inference.py @@ -17,7 +17,7 @@ AsyncSummaryResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -138,7 +138,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/ai/inference/summary/{dimension}", + path_template("/radar/ai/inference/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -239,7 +239,7 @@ def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/ai/inference/timeseries_groups/{dimension}", + path_template("/radar/ai/inference/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -362,7 +362,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/ai/inference/summary/{dimension}", + path_template("/radar/ai/inference/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -463,7 +463,7 @@ async def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/ai/inference/timeseries_groups/{dimension}", + path_template("/radar/ai/inference/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/ai/markdown_for_agents.py b/src/cloudflare/resources/radar/ai/markdown_for_agents.py new file mode 100644 index 00000000000..41bfbf82758 --- /dev/null +++ b/src/cloudflare/resources/radar/ai/markdown_for_agents.py @@ -0,0 +1,377 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Union, cast +from datetime import datetime +from typing_extensions import Literal + +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 ...._base_client import make_request_options +from ....types.radar.ai import markdown_for_agent_summary_params, markdown_for_agent_timeseries_params +from ....types.radar.ai.markdown_for_agent_summary_response import MarkdownForAgentSummaryResponse +from ....types.radar.ai.markdown_for_agent_timeseries_response import MarkdownForAgentTimeseriesResponse + +__all__ = ["MarkdownForAgentsResource", "AsyncMarkdownForAgentsResource"] + + +class MarkdownForAgentsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> MarkdownForAgentsResourceWithRawResponse: + """ + 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 MarkdownForAgentsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> MarkdownForAgentsResourceWithStreamingResponse: + """ + 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 MarkdownForAgentsResourceWithStreamingResponse(self) + + def summary( + self, + *, + date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit, + date_range: SequenceNotStr[str] | Omit = omit, + date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit, + format: Literal["JSON", "CSV"] | Omit = omit, + name: 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, + ) -> MarkdownForAgentSummaryResponse: + """ + Retrieves the overall median HTML-to-markdown reduction ratio for AI agent + requests over the given date range. + + Args: + date_end: End of the date range (inclusive). + + date_range: Filters results by date range. For example, use `7d` and `7dcontrol` to compare + this week with the previous week. Use this parameter or set specific start and + end dates (`dateStart` and `dateEnd` parameters). + + date_start: Start of the date range. + + format: Format in which results will be returned. + + name: Array of names used to label the series in the response. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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._get( + "/radar/ai/markdown_for_agents/summary", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "name": name, + }, + markdown_for_agent_summary_params.MarkdownForAgentSummaryParams, + ), + post_parser=ResultWrapper[MarkdownForAgentSummaryResponse]._unwrapper, + ), + cast_to=cast(Type[MarkdownForAgentSummaryResponse], ResultWrapper[MarkdownForAgentSummaryResponse]), + ) + + def timeseries( + self, + *, + agg_interval: Literal["15m", "1h", "1d", "1w"] | Omit = omit, + date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit, + date_range: SequenceNotStr[str] | Omit = omit, + date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit, + format: Literal["JSON", "CSV"] | Omit = omit, + name: 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, + ) -> MarkdownForAgentTimeseriesResponse: + """ + Retrieves the median HTML-to-markdown reduction ratio over time for AI agent + requests. + + Args: + agg_interval: Aggregation interval of the results (e.g., in 15 minutes or 1 hour intervals). + Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + + date_end: End of the date range (inclusive). + + date_range: Filters results by date range. For example, use `7d` and `7dcontrol` to compare + this week with the previous week. Use this parameter or set specific start and + end dates (`dateStart` and `dateEnd` parameters). + + date_start: Start of the date range. + + format: Format in which results will be returned. + + name: Array of names used to label the series in the response. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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._get( + "/radar/ai/markdown_for_agents/timeseries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "agg_interval": agg_interval, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "name": name, + }, + markdown_for_agent_timeseries_params.MarkdownForAgentTimeseriesParams, + ), + post_parser=ResultWrapper[MarkdownForAgentTimeseriesResponse]._unwrapper, + ), + cast_to=cast(Type[MarkdownForAgentTimeseriesResponse], ResultWrapper[MarkdownForAgentTimeseriesResponse]), + ) + + +class AsyncMarkdownForAgentsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncMarkdownForAgentsResourceWithRawResponse: + """ + 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 AsyncMarkdownForAgentsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncMarkdownForAgentsResourceWithStreamingResponse: + """ + 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 AsyncMarkdownForAgentsResourceWithStreamingResponse(self) + + async def summary( + self, + *, + date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit, + date_range: SequenceNotStr[str] | Omit = omit, + date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit, + format: Literal["JSON", "CSV"] | Omit = omit, + name: 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, + ) -> MarkdownForAgentSummaryResponse: + """ + Retrieves the overall median HTML-to-markdown reduction ratio for AI agent + requests over the given date range. + + Args: + date_end: End of the date range (inclusive). + + date_range: Filters results by date range. For example, use `7d` and `7dcontrol` to compare + this week with the previous week. Use this parameter or set specific start and + end dates (`dateStart` and `dateEnd` parameters). + + date_start: Start of the date range. + + format: Format in which results will be returned. + + name: Array of names used to label the series in the response. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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._get( + "/radar/ai/markdown_for_agents/summary", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "name": name, + }, + markdown_for_agent_summary_params.MarkdownForAgentSummaryParams, + ), + post_parser=ResultWrapper[MarkdownForAgentSummaryResponse]._unwrapper, + ), + cast_to=cast(Type[MarkdownForAgentSummaryResponse], ResultWrapper[MarkdownForAgentSummaryResponse]), + ) + + async def timeseries( + self, + *, + agg_interval: Literal["15m", "1h", "1d", "1w"] | Omit = omit, + date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit, + date_range: SequenceNotStr[str] | Omit = omit, + date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit, + format: Literal["JSON", "CSV"] | Omit = omit, + name: 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, + ) -> MarkdownForAgentTimeseriesResponse: + """ + Retrieves the median HTML-to-markdown reduction ratio over time for AI agent + requests. + + Args: + agg_interval: Aggregation interval of the results (e.g., in 15 minutes or 1 hour intervals). + Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + + date_end: End of the date range (inclusive). + + date_range: Filters results by date range. For example, use `7d` and `7dcontrol` to compare + this week with the previous week. Use this parameter or set specific start and + end dates (`dateStart` and `dateEnd` parameters). + + date_start: Start of the date range. + + format: Format in which results will be returned. + + name: Array of names used to label the series in the response. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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._get( + "/radar/ai/markdown_for_agents/timeseries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "agg_interval": agg_interval, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "name": name, + }, + markdown_for_agent_timeseries_params.MarkdownForAgentTimeseriesParams, + ), + post_parser=ResultWrapper[MarkdownForAgentTimeseriesResponse]._unwrapper, + ), + cast_to=cast(Type[MarkdownForAgentTimeseriesResponse], ResultWrapper[MarkdownForAgentTimeseriesResponse]), + ) + + +class MarkdownForAgentsResourceWithRawResponse: + def __init__(self, markdown_for_agents: MarkdownForAgentsResource) -> None: + self._markdown_for_agents = markdown_for_agents + + self.summary = to_raw_response_wrapper( + markdown_for_agents.summary, + ) + self.timeseries = to_raw_response_wrapper( + markdown_for_agents.timeseries, + ) + + +class AsyncMarkdownForAgentsResourceWithRawResponse: + def __init__(self, markdown_for_agents: AsyncMarkdownForAgentsResource) -> None: + self._markdown_for_agents = markdown_for_agents + + self.summary = async_to_raw_response_wrapper( + markdown_for_agents.summary, + ) + self.timeseries = async_to_raw_response_wrapper( + markdown_for_agents.timeseries, + ) + + +class MarkdownForAgentsResourceWithStreamingResponse: + def __init__(self, markdown_for_agents: MarkdownForAgentsResource) -> None: + self._markdown_for_agents = markdown_for_agents + + self.summary = to_streamed_response_wrapper( + markdown_for_agents.summary, + ) + self.timeseries = to_streamed_response_wrapper( + markdown_for_agents.timeseries, + ) + + +class AsyncMarkdownForAgentsResourceWithStreamingResponse: + def __init__(self, markdown_for_agents: AsyncMarkdownForAgentsResource) -> None: + self._markdown_for_agents = markdown_for_agents + + self.summary = async_to_streamed_response_wrapper( + markdown_for_agents.summary, + ) + self.timeseries = async_to_streamed_response_wrapper( + markdown_for_agents.timeseries, + ) diff --git a/src/cloudflare/resources/radar/ai/timeseries_groups.py b/src/cloudflare/resources/radar/ai/timeseries_groups.py index d3322e8ea4f..4c154efaac6 100644 --- a/src/cloudflare/resources/radar/ai/timeseries_groups.py +++ b/src/cloudflare/resources/radar/ai/timeseries_groups.py @@ -10,7 +10,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -179,7 +179,7 @@ def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/ai/bots/summary/{dimension}", + path_template("/radar/ai/bots/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -492,7 +492,7 @@ def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/ai/bots/timeseries_groups/{dimension}", + path_template("/radar/ai/bots/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -768,7 +768,7 @@ async def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/ai/bots/summary/{dimension}", + path_template("/radar/ai/bots/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1081,7 +1081,7 @@ async def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/ai/bots/timeseries_groups/{dimension}", + path_template("/radar/ai/bots/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/ai/to_markdown.py b/src/cloudflare/resources/radar/ai/to_markdown.py index 1e675de3355..4320c9f20a4 100644 --- a/src/cloudflare/resources/radar/ai/to_markdown.py +++ b/src/cloudflare/resources/radar/ai/to_markdown.py @@ -16,7 +16,7 @@ SequenceNotStr, not_given, ) -from ...._utils import extract_files, maybe_transform, deepcopy_minimal +from ...._utils import extract_files, path_template, maybe_transform, deepcopy_minimal from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -59,7 +59,7 @@ def with_streaming_response(self) -> ToMarkdownResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, files: SequenceNotStr[FileTypes], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -80,6 +80,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") body = deepcopy_minimal({"files": files}) @@ -88,8 +90,8 @@ def create( # 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", + return self._get_api_list( + path_template("/accounts/{account_id}/ai/tomarkdown", account_id=account_id), page=SyncSinglePage[ToMarkdownCreateResponse], body=maybe_transform(body, to_markdown_create_params.ToMarkdownCreateParams), files=extracted_files, # pyright: ignore[reportCallIssue] # type: ignore[call-arg] @@ -127,7 +129,7 @@ def with_streaming_response(self) -> AsyncToMarkdownResourceWithStreamingRespons def create( self, *, - account_id: str, + account_id: str | None = None, files: SequenceNotStr[FileTypes], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -148,6 +150,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") body = deepcopy_minimal({"files": files}) @@ -156,8 +160,8 @@ def create( # 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", + return self._get_api_list( + path_template("/accounts/{account_id}/ai/tomarkdown", account_id=account_id), page=AsyncSinglePage[ToMarkdownCreateResponse], body=maybe_transform(body, to_markdown_create_params.ToMarkdownCreateParams), files=extracted_files, # pyright: ignore[reportCallIssue] # type: ignore[call-arg] diff --git a/src/cloudflare/resources/radar/api.md b/src/cloudflare/resources/radar/api.md new file mode 100644 index 00000000000..1b322eb9563 --- /dev/null +++ b/src/cloudflare/resources/radar/api.md @@ -0,0 +1,1629 @@ +# Radar + +## AgentReadiness + +Types: + +```python +from cloudflare.types.radar import AgentReadinessSummaryResponse +``` + +Methods: + +- client.radar.agent_readiness.summary(dimension, \*\*params) -> AgentReadinessSummaryResponse + +## 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 + +### MarkdownForAgents + +Types: + +```python +from cloudflare.types.radar.ai import ( + MarkdownForAgentSummaryResponse, + MarkdownForAgentTimeseriesResponse, +) +``` + +Methods: + +- client.radar.ai.markdown_for_agents.summary(\*\*params) -> MarkdownForAgentSummaryResponse +- client.radar.ai.markdown_for_agents.timeseries(\*\*params) -> MarkdownForAgentTimeseriesResponse + +## 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 + +## PostQuantum + +### Origin + +Types: + +```python +from cloudflare.types.radar.post_quantum import ( + OriginSummaryResponse, + OriginTimeseriesGroupsResponse, +) +``` + +Methods: + +- client.radar.post_quantum.origin.summary(dimension, \*\*params) -> OriginSummaryResponse +- client.radar.post_quantum.origin.timeseries_groups(dimension, \*\*params) -> OriginTimeseriesGroupsResponse + +### TLS + +Types: + +```python +from cloudflare.types.radar.post_quantum import TLSSupportResponse +``` + +Methods: + +- client.radar.post_quantum.tls.support(\*\*params) -> TLSSupportResponse + +## 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.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 + +### Top + +Types: + +```python +from cloudflare.types.radar.as112 import ( + TopDNSSECResponse, + TopEdnsResponse, + TopIPVersionResponse, + TopLocationsResponse, +) +``` + +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 + +## Email + +Types: + +```python +from cloudflare.types.radar import RadarEmailSeries, RadarEmailSummary +``` + +### Routing + +Types: + +```python +from cloudflare.types.radar.email import RoutingSummaryV2Response, RoutingTimeseriesGroupsV2Response +``` + +Methods: + +- client.radar.email.routing.summary_v2(dimension, \*\*params) -> RoutingSummaryV2Response +- client.radar.email.routing.timeseries_groups_v2(dimension, \*\*params) -> RoutingTimeseriesGroupsV2Response + +#### Summary + +Types: + +```python +from cloudflare.types.radar.email.routing import ( + SummaryARCResponse, + SummaryDKIMResponse, + SummaryDMARCResponse, + SummaryEncryptedResponse, + SummaryIPVersionResponse, + SummarySPFResponse, +) +``` + +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 + +#### TimeseriesGroups + +Types: + +```python +from cloudflare.types.radar.email.routing import ( + TimeseriesGroupARCResponse, + TimeseriesGroupDKIMResponse, + TimeseriesGroupDMARCResponse, + TimeseriesGroupEncryptedResponse, + TimeseriesGroupIPVersionResponse, + TimeseriesGroupSPFResponse, +) +``` + +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 + +Types: + +```python +from cloudflare.types.radar.email import ( + SecuritySummaryV2Response, + SecurityTimeseriesGroupsV2Response, +) +``` + +Methods: + +- client.radar.email.security.summary_v2(dimension, \*\*params) -> SecuritySummaryV2Response +- client.radar.email.security.timeseries_groups_v2(dimension, \*\*params) -> SecurityTimeseriesGroupsV2Response + +#### Top + +##### TLDs + +Types: + +```python +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.radar.attacks.layer3.top.attacks(\*\*params) -> TopAttacksResponse +- client.radar.attacks.layer3.top.industry(\*\*params) -> TopIndustryResponse +- client.radar.attacks.layer3.top.vertical(\*\*params) -> TopVerticalResponse + +##### Locations + +Types: + +```python +from cloudflare.types.radar.attacks.layer3.top import LocationOriginResponse, LocationTargetResponse +``` + +Methods: + +- client.radar.attacks.layer3.top.locations.origin(\*\*params) -> LocationOriginResponse +- client.radar.attacks.layer3.top.locations.target(\*\*params) -> LocationTargetResponse + +### Layer7 + +Types: + +```python +from cloudflare.types.radar.attacks import ( + Layer7SummaryV2Response, + Layer7TimeseriesResponse, + Layer7TimeseriesGroupsV2Response, +) +``` + +Methods: + +- 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 + +#### Summary + +Types: + +```python +from cloudflare.types.radar.attacks.layer7 import ( + SummaryHTTPMethodResponse, + SummaryHTTPVersionResponse, + SummaryIndustryResponse, + SummaryIPVersionResponse, + SummaryManagedRulesResponse, + SummaryMitigationProductResponse, + SummaryVerticalResponse, +) +``` + +Methods: + +- 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 + +#### TimeseriesGroups + +Types: + +```python +from cloudflare.types.radar.attacks.layer7 import ( + TimeseriesGroupHTTPMethodResponse, + TimeseriesGroupHTTPVersionResponse, + TimeseriesGroupIndustryResponse, + TimeseriesGroupIPVersionResponse, + TimeseriesGroupManagedRulesResponse, + TimeseriesGroupMitigationProductResponse, + TimeseriesGroupVerticalResponse, +) +``` + +Methods: + +- 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 + +#### Top + +Types: + +```python +from cloudflare.types.radar.attacks.layer7 import ( + TopAttacksResponse, + TopIndustryResponse, + TopVerticalResponse, +) +``` + +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 + +##### Locations + +Types: + +```python +from cloudflare.types.radar.attacks.layer7.top import LocationOriginResponse, LocationTargetResponse +``` + +Methods: + +- client.radar.attacks.layer7.top.locations.origin(\*\*params) -> LocationOriginResponse +- client.radar.attacks.layer7.top.locations.target(\*\*params) -> LocationTargetResponse + +##### Ases + +Types: + +```python +from cloudflare.types.radar.attacks.layer7.top import AseOriginResponse +``` + +Methods: + +- client.radar.attacks.layer7.top.ases.origin(\*\*params) -> AseOriginResponse + +## Entities + +Types: + +```python +from cloudflare.types.radar import EntityGetResponse +``` + +Methods: + +- client.radar.entities.get(\*\*params) -> EntityGetResponse + +### ASNs + +Types: + +```python +from cloudflare.types.radar.entities import ( + ASNListResponse, + ASNAsSetResponse, + ASNBotnetThreatFeedResponse, + ASNGetResponse, + ASNIPResponse, + ASNRelResponse, +) +``` + +Methods: + +- client.radar.entities.asns.list(\*\*params) -> ASNListResponse +- client.radar.entities.asns.as_set(asn, \*\*params) -> ASNAsSetResponse +- client.radar.entities.asns.botnet_threat_feed(\*\*params) -> ASNBotnetThreatFeedResponse +- client.radar.entities.asns.get(asn, \*\*params) -> ASNGetResponse +- client.radar.entities.asns.ip(\*\*params) -> ASNIPResponse +- client.radar.entities.asns.rel(asn, \*\*params) -> ASNRelResponse + +### Locations + +Types: + +```python +from cloudflare.types.radar.entities import LocationListResponse, LocationGetResponse +``` + +Methods: + +- client.radar.entities.locations.list(\*\*params) -> LocationListResponse +- client.radar.entities.locations.get(location, \*\*params) -> LocationGetResponse + +## Geolocations + +Types: + +```python +from cloudflare.types.radar import GeolocationListResponse, GeolocationGetResponse +``` + +Methods: + +- client.radar.geolocations.list(\*\*params) -> GeolocationListResponse +- client.radar.geolocations.get(geo_id, \*\*params) -> GeolocationGetResponse + +## HTTP + +Types: + +```python +from cloudflare.types.radar import ( + HTTPSummaryV2Response, + HTTPTimeseriesResponse, + HTTPTimeseriesGroupsV2Response, +) +``` + +Methods: + +- client.radar.http.summary_v2(dimension, \*\*params) -> HTTPSummaryV2Response +- client.radar.http.timeseries(\*\*params) -> HTTPTimeseriesResponse +- client.radar.http.timeseries_groups_v2(dimension, \*\*params) -> HTTPTimeseriesGroupsV2Response + +### Locations + +Types: + +```python +from cloudflare.types.radar.http import LocationGetResponse +``` + +Methods: + +- client.radar.http.locations.get(\*\*params) -> LocationGetResponse + +#### BotClass + +Types: + +```python +from cloudflare.types.radar.http.locations import BotClassGetResponse +``` + +Methods: + +- client.radar.http.locations.bot_class.get(bot_class, \*\*params) -> BotClassGetResponse + +#### DeviceType + +Types: + +```python +from cloudflare.types.radar.http.locations import DeviceTypeGetResponse +``` + +Methods: + +- client.radar.http.locations.device_type.get(device_type, \*\*params) -> DeviceTypeGetResponse + +#### HTTPProtocol + +Types: + +```python +from cloudflare.types.radar.http.locations import HTTPProtocolGetResponse +``` + +Methods: + +- client.radar.http.locations.http_protocol.get(http_protocol, \*\*params) -> HTTPProtocolGetResponse + +#### HTTPMethod + +Types: + +```python +from cloudflare.types.radar.http.locations import HTTPMethodGetResponse +``` + +Methods: + +- client.radar.http.locations.http_method.get(http_version, \*\*params) -> HTTPMethodGetResponse + +#### IPVersion + +Types: + +```python +from cloudflare.types.radar.http.locations import IPVersionGetResponse +``` + +Methods: + +- client.radar.http.locations.ip_version.get(ip_version, \*\*params) -> IPVersionGetResponse + +#### OS + +Types: + +```python +from cloudflare.types.radar.http.locations import OSGetResponse +``` + +Methods: + +- client.radar.http.locations.os.get(os, \*\*params) -> OSGetResponse + +#### TLSVersion + +Types: + +```python +from cloudflare.types.radar.http.locations import TLSVersionGetResponse +``` + +Methods: + +- client.radar.http.locations.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse + +#### BrowserFamily + +Types: + +```python +from cloudflare.types.radar.http.locations import BrowserFamilyGetResponse +``` + +Methods: + +- client.radar.http.locations.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse + +### Ases + +Types: + +```python +from cloudflare.types.radar.http import AseGetResponse +``` + +Methods: + +- client.radar.http.ases.get(\*\*params) -> AseGetResponse + +#### BotClass + +Types: + +```python +from cloudflare.types.radar.http.ases import BotClassGetResponse +``` + +Methods: + +- client.radar.http.ases.bot_class.get(bot_class, \*\*params) -> BotClassGetResponse + +#### DeviceType + +Types: + +```python +from cloudflare.types.radar.http.ases import DeviceTypeGetResponse +``` + +Methods: + +- client.radar.http.ases.device_type.get(device_type, \*\*params) -> DeviceTypeGetResponse + +#### HTTPProtocol + +Types: + +```python +from cloudflare.types.radar.http.ases import HTTPProtocolGetResponse +``` + +Methods: + +- client.radar.http.ases.http_protocol.get(http_protocol, \*\*params) -> HTTPProtocolGetResponse + +#### HTTPMethod + +Types: + +```python +from cloudflare.types.radar.http.ases import HTTPMethodGetResponse +``` + +Methods: + +- client.radar.http.ases.http_method.get(http_version, \*\*params) -> HTTPMethodGetResponse + +#### IPVersion + +Types: + +```python +from cloudflare.types.radar.http.ases import IPVersionGetResponse +``` + +Methods: + +- client.radar.http.ases.ip_version.get(ip_version, \*\*params) -> IPVersionGetResponse + +#### OS + +Types: + +```python +from cloudflare.types.radar.http.ases import OSGetResponse +``` + +Methods: + +- client.radar.http.ases.os.get(os, \*\*params) -> OSGetResponse + +#### TLSVersion + +Types: + +```python +from cloudflare.types.radar.http.ases import TLSVersionGetResponse +``` + +Methods: + +- client.radar.http.ases.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse + +#### BrowserFamily + +Types: + +```python +from cloudflare.types.radar.http.ases import BrowserFamilyGetResponse +``` + +Methods: + +- client.radar.http.ases.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse + +### Summary + +Types: + +```python +from cloudflare.types.radar.http import ( + SummaryBotClassResponse, + SummaryDeviceTypeResponse, + SummaryHTTPProtocolResponse, + SummaryHTTPVersionResponse, + SummaryIPVersionResponse, + SummaryOSResponse, + SummaryPostQuantumResponse, + SummaryTLSVersionResponse, +) +``` + +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 + +### TimeseriesGroups + +Types: + +```python +from cloudflare.types.radar.http import ( + TimeseriesGroupBotClassResponse, + TimeseriesGroupBrowserResponse, + TimeseriesGroupBrowserFamilyResponse, + TimeseriesGroupDeviceTypeResponse, + TimeseriesGroupHTTPProtocolResponse, + TimeseriesGroupHTTPVersionResponse, + TimeseriesGroupIPVersionResponse, + TimeseriesGroupOSResponse, + TimeseriesGroupPostQuantumResponse, + TimeseriesGroupTLSVersionResponse, +) +``` + +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 + +### Top + +Types: + +```python +from cloudflare.types.radar.http import TopBrowserResponse, TopBrowserFamilyResponse +``` + +Methods: + +- client.radar.http.top.browser(\*\*params) -> TopBrowserResponse +- client.radar.http.top.browser_family(\*\*params) -> TopBrowserFamilyResponse + +## Quality + +### IQI + +Types: + +```python +from cloudflare.types.radar.quality import IQISummaryResponse, IQITimeseriesGroupsResponse +``` + +Methods: + +- client.radar.quality.iqi.summary(\*\*params) -> IQISummaryResponse +- client.radar.quality.iqi.timeseries_groups(\*\*params) -> IQITimeseriesGroupsResponse + +### Speed + +Types: + +```python +from cloudflare.types.radar.quality import SpeedHistogramResponse, SpeedSummaryResponse +``` + +Methods: + +- client.radar.quality.speed.histogram(\*\*params) -> SpeedHistogramResponse +- client.radar.quality.speed.summary(\*\*params) -> SpeedSummaryResponse + +#### Top + +Types: + +```python +from cloudflare.types.radar.quality.speed import TopAsesResponse, TopLocationsResponse +``` + +Methods: + +- client.radar.quality.speed.top.ases(\*\*params) -> TopAsesResponse +- client.radar.quality.speed.top.locations(\*\*params) -> TopLocationsResponse + +## Ranking + +Types: + +```python +from cloudflare.types.radar import RankingTimeseriesGroupsResponse, RankingTopResponse +``` + +Methods: + +- client.radar.ranking.timeseries_groups(\*\*params) -> RankingTimeseriesGroupsResponse +- client.radar.ranking.top(\*\*params) -> RankingTopResponse + +### Domain + +Types: + +```python +from cloudflare.types.radar.ranking import DomainGetResponse +``` + +Methods: + +- client.radar.ranking.domain.get(domain, \*\*params) -> DomainGetResponse + +### InternetServices + +Types: + +```python +from cloudflare.types.radar.ranking import ( + InternetServiceCategoriesResponse, + InternetServiceTimeseriesGroupsResponse, + InternetServiceTopResponse, +) +``` + +Methods: + +- 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 + +## TrafficAnomalies + +Types: + +```python +from cloudflare.types.radar import TrafficAnomalyGetResponse +``` + +Methods: + +- client.radar.traffic_anomalies.get(\*\*params) -> TrafficAnomalyGetResponse + +### Locations + +Types: + +```python +from cloudflare.types.radar.traffic_anomalies import LocationGetResponse +``` + +Methods: + +- client.radar.traffic_anomalies.locations.get(\*\*params) -> LocationGetResponse + +## TCPResetsTimeouts + +Types: + +```python +from cloudflare.types.radar import ( + TCPResetsTimeoutSummaryResponse, + TCPResetsTimeoutTimeseriesGroupsResponse, +) +``` + +Methods: + +- client.radar.tcp_resets_timeouts.summary(\*\*params) -> TCPResetsTimeoutSummaryResponse +- client.radar.tcp_resets_timeouts.timeseries_groups(\*\*params) -> TCPResetsTimeoutTimeseriesGroupsResponse + +## RobotsTXT + +### Top + +Types: + +```python +from cloudflare.types.radar.robots_txt import TopDomainCategoriesResponse +``` + +Methods: + +- client.radar.robots_txt.top.domain_categories(\*\*params) -> TopDomainCategoriesResponse + +#### UserAgents + +Types: + +```python +from cloudflare.types.radar.robots_txt.top import UserAgentDirectiveResponse +``` + +Methods: + +- client.radar.robots_txt.top.user_agents.directive(\*\*params) -> UserAgentDirectiveResponse + +## LeakedCredentials + +Types: + +```python +from cloudflare.types.radar import ( + LeakedCredentialSummaryV2Response, + LeakedCredentialTimeseriesGroupsV2Response, +) +``` + +Methods: + +- client.radar.leaked_credentials.summary_v2(dimension, \*\*params) -> LeakedCredentialSummaryV2Response +- client.radar.leaked_credentials.timeseries_groups_v2(dimension, \*\*params) -> LeakedCredentialTimeseriesGroupsV2Response + +### Summary + +Types: + +```python +from cloudflare.types.radar.leaked_credentials import ( + SummaryBotClassResponse, + SummaryCompromisedResponse, +) +``` + +Methods: + +- client.radar.leaked_credentials.summary.bot_class(\*\*params) -> SummaryBotClassResponse +- client.radar.leaked_credentials.summary.compromised(\*\*params) -> SummaryCompromisedResponse + +### TimeseriesGroups + +Types: + +```python +from cloudflare.types.radar.leaked_credentials import ( + TimeseriesGroupBotClassResponse, + TimeseriesGroupCompromisedResponse, +) +``` + +Methods: + +- client.radar.leaked_credentials.timeseries_groups.bot_class(\*\*params) -> TimeseriesGroupBotClassResponse +- client.radar.leaked_credentials.timeseries_groups.compromised(\*\*params) -> TimeseriesGroupCompromisedResponse diff --git a/src/cloudflare/resources/radar/as112/as112.py b/src/cloudflare/resources/radar/as112/as112.py index da7fbe2bcca..c58ace2df45 100644 --- a/src/cloudflare/resources/radar/as112/as112.py +++ b/src/cloudflare/resources/radar/as112/as112.py @@ -25,7 +25,7 @@ AsyncSummaryResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -270,7 +270,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/as112/summary/{dimension}", + path_template("/radar/as112/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -696,7 +696,7 @@ def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/as112/timeseries_groups/{dimension}", + path_template("/radar/as112/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -943,7 +943,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/as112/summary/{dimension}", + path_template("/radar/as112/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1369,7 +1369,7 @@ async def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/as112/timeseries_groups/{dimension}", + path_template("/radar/as112/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/as112/top.py b/src/cloudflare/resources/radar/as112/top.py index 2d22f91c78e..0de25cd350f 100644 --- a/src/cloudflare/resources/radar/as112/top.py +++ b/src/cloudflare/resources/radar/as112/top.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -108,7 +108,7 @@ def dnssec( if not dnssec: raise ValueError(f"Expected a non-empty value for `dnssec` but received {dnssec!r}") return self._get( - f"/radar/as112/top/locations/dnssec/{dnssec}", + path_template("/radar/as112/top/locations/dnssec/{dnssec}", dnssec=dnssec), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -191,7 +191,7 @@ def edns( if not edns: raise ValueError(f"Expected a non-empty value for `edns` but received {edns!r}") return self._get( - f"/radar/as112/top/locations/edns/{edns}", + path_template("/radar/as112/top/locations/edns/{edns}", edns=edns), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -273,7 +273,7 @@ def ip_version( if not ip_version: raise ValueError(f"Expected a non-empty value for `ip_version` but received {ip_version!r}") return self._get( - f"/radar/as112/top/locations/ip_version/{ip_version}", + path_template("/radar/as112/top/locations/ip_version/{ip_version}", ip_version=ip_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -454,7 +454,7 @@ async def dnssec( if not dnssec: raise ValueError(f"Expected a non-empty value for `dnssec` but received {dnssec!r}") return await self._get( - f"/radar/as112/top/locations/dnssec/{dnssec}", + path_template("/radar/as112/top/locations/dnssec/{dnssec}", dnssec=dnssec), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -537,7 +537,7 @@ async def edns( if not edns: raise ValueError(f"Expected a non-empty value for `edns` but received {edns!r}") return await self._get( - f"/radar/as112/top/locations/edns/{edns}", + path_template("/radar/as112/top/locations/edns/{edns}", edns=edns), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -619,7 +619,7 @@ async def ip_version( if not ip_version: raise ValueError(f"Expected a non-empty value for `ip_version` but received {ip_version!r}") return await self._get( - f"/radar/as112/top/locations/ip_version/{ip_version}", + path_template("/radar/as112/top/locations/ip_version/{ip_version}", ip_version=ip_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/attacks/layer3/layer3.py b/src/cloudflare/resources/radar/attacks/layer3/layer3.py index 54e7fdffaef..9284bb56828 100644 --- a/src/cloudflare/resources/radar/attacks/layer3/layer3.py +++ b/src/cloudflare/resources/radar/attacks/layer3/layer3.py @@ -25,7 +25,7 @@ AsyncTopResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -158,7 +158,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/attacks/layer3/summary/{dimension}", + path_template("/radar/attacks/layer3/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -372,7 +372,7 @@ def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/attacks/layer3/timeseries_groups/{dimension}", + path_template("/radar/attacks/layer3/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -504,7 +504,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/attacks/layer3/summary/{dimension}", + path_template("/radar/attacks/layer3/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -718,7 +718,7 @@ async def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/attacks/layer3/timeseries_groups/{dimension}", + path_template("/radar/attacks/layer3/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/attacks/layer7/layer7.py b/src/cloudflare/resources/radar/attacks/layer7/layer7.py index 675d45fe24b..19f08719d5a 100644 --- a/src/cloudflare/resources/radar/attacks/layer7/layer7.py +++ b/src/cloudflare/resources/radar/attacks/layer7/layer7.py @@ -25,7 +25,7 @@ AsyncTopResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -223,7 +223,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/attacks/layer7/summary/{dimension}", + path_template("/radar/attacks/layer7/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -558,7 +558,7 @@ def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/attacks/layer7/timeseries_groups/{dimension}", + path_template("/radar/attacks/layer7/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -757,7 +757,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/attacks/layer7/summary/{dimension}", + path_template("/radar/attacks/layer7/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1092,7 +1092,7 @@ async def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/attacks/layer7/timeseries_groups/{dimension}", + path_template("/radar/attacks/layer7/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/bots/bots.py b/src/cloudflare/resources/radar/bots/bots.py index e3ef5e4287e..ecdc218f552 100644 --- a/src/cloudflare/resources/radar/bots/bots.py +++ b/src/cloudflare/resources/radar/bots/bots.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -184,7 +184,7 @@ def get( if not bot_slug: raise ValueError(f"Expected a non-empty value for `bot_slug` but received {bot_slug!r}") return self._get( - f"/radar/bots/{bot_slug}", + path_template("/radar/bots/{bot_slug}", bot_slug=bot_slug), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -298,7 +298,7 @@ def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/bots/summary/{dimension}", + path_template("/radar/bots/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -561,7 +561,7 @@ def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/bots/timeseries_groups/{dimension}", + path_template("/radar/bots/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -733,7 +733,7 @@ async def get( if not bot_slug: raise ValueError(f"Expected a non-empty value for `bot_slug` but received {bot_slug!r}") return await self._get( - f"/radar/bots/{bot_slug}", + path_template("/radar/bots/{bot_slug}", bot_slug=bot_slug), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -847,7 +847,7 @@ async def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/bots/summary/{dimension}", + path_template("/radar/bots/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1110,7 +1110,7 @@ async def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/bots/timeseries_groups/{dimension}", + path_template("/radar/bots/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/bots/web_crawlers.py b/src/cloudflare/resources/radar/bots/web_crawlers.py index e52e11f8699..cabe7b8452d 100644 --- a/src/cloudflare/resources/radar/bots/web_crawlers.py +++ b/src/cloudflare/resources/radar/bots/web_crawlers.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -130,7 +130,7 @@ def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/bots/crawlers/summary/{dimension}", + path_template("/radar/bots/crawlers/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -246,7 +246,7 @@ def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/bots/crawlers/timeseries_groups/{dimension}", + path_template("/radar/bots/crawlers/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -379,7 +379,7 @@ async def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/bots/crawlers/summary/{dimension}", + path_template("/radar/bots/crawlers/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -495,7 +495,7 @@ async def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/bots/crawlers/timeseries_groups/{dimension}", + path_template("/radar/bots/crawlers/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/ct/authorities.py b/src/cloudflare/resources/radar/ct/authorities.py index 580466559d8..b523a44280f 100644 --- a/src/cloudflare/resources/radar/ct/authorities.py +++ b/src/cloudflare/resources/radar/ct/authorities.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -128,7 +128,7 @@ def get( if not ca_slug: raise ValueError(f"Expected a non-empty value for `ca_slug` but received {ca_slug!r}") return self._get( - f"/radar/ct/authorities/{ca_slug}", + path_template("/radar/ct/authorities/{ca_slug}", ca_slug=ca_slug), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -243,7 +243,7 @@ async def get( if not ca_slug: raise ValueError(f"Expected a non-empty value for `ca_slug` but received {ca_slug!r}") return await self._get( - f"/radar/ct/authorities/{ca_slug}", + path_template("/radar/ct/authorities/{ca_slug}", ca_slug=ca_slug), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/ct/ct.py b/src/cloudflare/resources/radar/ct/ct.py index 2102278a793..c6382a7c94f 100644 --- a/src/cloudflare/resources/radar/ct/ct.py +++ b/src/cloudflare/resources/radar/ct/ct.py @@ -17,7 +17,7 @@ AsyncLogsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from .authorities import ( AuthoritiesResource, @@ -219,7 +219,7 @@ def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/ct/summary/{dimension}", + path_template("/radar/ct/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -568,7 +568,7 @@ def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/ct/timeseries_groups/{dimension}", + path_template("/radar/ct/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -783,7 +783,7 @@ async def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/ct/summary/{dimension}", + path_template("/radar/ct/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1132,7 +1132,7 @@ async def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/ct/timeseries_groups/{dimension}", + path_template("/radar/ct/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/ct/logs.py b/src/cloudflare/resources/radar/ct/logs.py index bbd1e8bc52e..28c80918957 100644 --- a/src/cloudflare/resources/radar/ct/logs.py +++ b/src/cloudflare/resources/radar/ct/logs.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -128,7 +128,7 @@ def get( if not log_slug: raise ValueError(f"Expected a non-empty value for `log_slug` but received {log_slug!r}") return self._get( - f"/radar/ct/logs/{log_slug}", + path_template("/radar/ct/logs/{log_slug}", log_slug=log_slug), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -243,7 +243,7 @@ async def get( if not log_slug: raise ValueError(f"Expected a non-empty value for `log_slug` but received {log_slug!r}") return await self._get( - f"/radar/ct/logs/{log_slug}", + path_template("/radar/ct/logs/{log_slug}", log_slug=log_slug), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/datasets.py b/src/cloudflare/resources/radar/datasets.py index 1b387e46fa6..f931ddde776 100644 --- a/src/cloudflare/resources/radar/datasets.py +++ b/src/cloudflare/resources/radar/datasets.py @@ -9,7 +9,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -178,7 +178,7 @@ def get( raise ValueError(f"Expected a non-empty value for `alias` but received {alias!r}") extra_headers = {"Accept": "text/csv", **(extra_headers or {})} return self._get( - f"/radar/datasets/{alias}", + path_template("/radar/datasets/{alias}", alias=alias), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -337,7 +337,7 @@ async def get( raise ValueError(f"Expected a non-empty value for `alias` but received {alias!r}") extra_headers = {"Accept": "text/csv", **(extra_headers or {})} return await self._get( - f"/radar/datasets/{alias}", + path_template("/radar/datasets/{alias}", alias=alias), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/radar/dns/dns.py b/src/cloudflare/resources/radar/dns/dns.py index 539c48177f4..d5dd5c4a307 100644 --- a/src/cloudflare/resources/radar/dns/dns.py +++ b/src/cloudflare/resources/radar/dns/dns.py @@ -25,7 +25,7 @@ AsyncSummaryResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -321,7 +321,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/dns/summary/{dimension}", + path_template("/radar/dns/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -857,7 +857,7 @@ def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/dns/timeseries_groups/{dimension}", + path_template("/radar/dns/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1166,7 +1166,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/dns/summary/{dimension}", + path_template("/radar/dns/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1702,7 +1702,7 @@ async def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/dns/timeseries_groups/{dimension}", + path_template("/radar/dns/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/email/routing/routing.py b/src/cloudflare/resources/radar/email/routing/routing.py index 7a036446f79..38d17062f65 100644 --- a/src/cloudflare/resources/radar/email/routing/routing.py +++ b/src/cloudflare/resources/radar/email/routing/routing.py @@ -17,7 +17,7 @@ AsyncSummaryResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -140,7 +140,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/email/routing/summary/{dimension}", + path_template("/radar/email/routing/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -243,7 +243,7 @@ def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/email/routing/timeseries_groups/{dimension}", + path_template("/radar/email/routing/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -370,7 +370,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/email/routing/summary/{dimension}", + path_template("/radar/email/routing/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -473,7 +473,7 @@ async def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/email/routing/timeseries_groups/{dimension}", + path_template("/radar/email/routing/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/email/security/security.py b/src/cloudflare/resources/radar/email/security/security.py index a83510b60ca..ca2c86b66a5 100644 --- a/src/cloudflare/resources/radar/email/security/security.py +++ b/src/cloudflare/resources/radar/email/security/security.py @@ -25,7 +25,7 @@ AsyncTopResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -151,7 +151,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/email/security/summary/{dimension}", + path_template("/radar/email/security/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -252,7 +252,7 @@ def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/email/security/timeseries_groups/{dimension}", + path_template("/radar/email/security/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -381,7 +381,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/email/security/summary/{dimension}", + path_template("/radar/email/security/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -482,7 +482,7 @@ async def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/email/security/timeseries_groups/{dimension}", + path_template("/radar/email/security/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/email/security/top/tlds/malicious.py b/src/cloudflare/resources/radar/email/security/top/tlds/malicious.py index 7c5e809c1e7..ca9a5dbd29c 100644 --- a/src/cloudflare/resources/radar/email/security/top/tlds/malicious.py +++ b/src/cloudflare/resources/radar/email/security/top/tlds/malicious.py @@ -9,7 +9,7 @@ import httpx from ......._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ......._utils import maybe_transform, async_maybe_transform +from ......._utils import path_template, maybe_transform, async_maybe_transform from ......._compat import cached_property from ......._resource import SyncAPIResource, AsyncAPIResource from ......._response import ( @@ -113,7 +113,7 @@ def get( if not malicious: raise ValueError(f"Expected a non-empty value for `malicious` but received {malicious!r}") return self._get( - f"/radar/email/security/top/tlds/malicious/{malicious}", + path_template("/radar/email/security/top/tlds/malicious/{malicious}", malicious=malicious), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,7 +229,7 @@ async def get( if not malicious: raise ValueError(f"Expected a non-empty value for `malicious` but received {malicious!r}") return await self._get( - f"/radar/email/security/top/tlds/malicious/{malicious}", + path_template("/radar/email/security/top/tlds/malicious/{malicious}", malicious=malicious), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/email/security/top/tlds/spam.py b/src/cloudflare/resources/radar/email/security/top/tlds/spam.py index 1c7d7ed08ec..0f5ab826880 100644 --- a/src/cloudflare/resources/radar/email/security/top/tlds/spam.py +++ b/src/cloudflare/resources/radar/email/security/top/tlds/spam.py @@ -9,7 +9,7 @@ import httpx from ......._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ......._utils import maybe_transform, async_maybe_transform +from ......._utils import path_template, maybe_transform, async_maybe_transform from ......._compat import cached_property from ......._resource import SyncAPIResource, AsyncAPIResource from ......._response import ( @@ -113,7 +113,7 @@ def get( if not spam: raise ValueError(f"Expected a non-empty value for `spam` but received {spam!r}") return self._get( - f"/radar/email/security/top/tlds/spam/{spam}", + path_template("/radar/email/security/top/tlds/spam/{spam}", spam=spam), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,7 +229,7 @@ async def get( if not spam: raise ValueError(f"Expected a non-empty value for `spam` but received {spam!r}") return await self._get( - f"/radar/email/security/top/tlds/spam/{spam}", + path_template("/radar/email/security/top/tlds/spam/{spam}", spam=spam), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/email/security/top/tlds/spoof.py b/src/cloudflare/resources/radar/email/security/top/tlds/spoof.py index 0ff172ed740..07a06fee56e 100644 --- a/src/cloudflare/resources/radar/email/security/top/tlds/spoof.py +++ b/src/cloudflare/resources/radar/email/security/top/tlds/spoof.py @@ -9,7 +9,7 @@ import httpx from ......._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ......._utils import maybe_transform, async_maybe_transform +from ......._utils import path_template, maybe_transform, async_maybe_transform from ......._compat import cached_property from ......._resource import SyncAPIResource, AsyncAPIResource from ......._response import ( @@ -113,7 +113,7 @@ def get( if not spoof: raise ValueError(f"Expected a non-empty value for `spoof` but received {spoof!r}") return self._get( - f"/radar/email/security/top/tlds/spoof/{spoof}", + path_template("/radar/email/security/top/tlds/spoof/{spoof}", spoof=spoof), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,7 +229,7 @@ async def get( if not spoof: raise ValueError(f"Expected a non-empty value for `spoof` but received {spoof!r}") return await self._get( - f"/radar/email/security/top/tlds/spoof/{spoof}", + path_template("/radar/email/security/top/tlds/spoof/{spoof}", spoof=spoof), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/entities/asns.py b/src/cloudflare/resources/radar/entities/asns.py index 8654bd4fadc..a2640a376e6 100644 --- a/src/cloudflare/resources/radar/entities/asns.py +++ b/src/cloudflare/resources/radar/entities/asns.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -151,7 +151,7 @@ def as_set( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - f"/radar/entities/asns/{asn}/as_set", + path_template("/radar/entities/asns/{asn}/as_set", asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -279,7 +279,7 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - f"/radar/entities/asns/{asn}", + path_template("/radar/entities/asns/{asn}", asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -372,7 +372,7 @@ def rel( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - f"/radar/entities/asns/{asn}/rel", + path_template("/radar/entities/asns/{asn}/rel", asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -504,7 +504,7 @@ async def as_set( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - f"/radar/entities/asns/{asn}/as_set", + path_template("/radar/entities/asns/{asn}/as_set", asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -632,7 +632,7 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - f"/radar/entities/asns/{asn}", + path_template("/radar/entities/asns/{asn}", asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -725,7 +725,7 @@ async def rel( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - f"/radar/entities/asns/{asn}/rel", + path_template("/radar/entities/asns/{asn}/rel", asn=asn), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/entities/locations.py b/src/cloudflare/resources/radar/entities/locations.py index 51e63d24533..06e490c0f5c 100644 --- a/src/cloudflare/resources/radar/entities/locations.py +++ b/src/cloudflare/resources/radar/entities/locations.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -148,7 +148,7 @@ def get( if not location: raise ValueError(f"Expected a non-empty value for `location` but received {location!r}") return self._get( - f"/radar/entities/locations/{location}", + path_template("/radar/entities/locations/{location}", location=location), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -283,7 +283,7 @@ async def get( if not location: raise ValueError(f"Expected a non-empty value for `location` but received {location!r}") return await self._get( - f"/radar/entities/locations/{location}", + path_template("/radar/entities/locations/{location}", location=location), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/geolocations.py b/src/cloudflare/resources/radar/geolocations.py index 6ee41ee76c8..ed9610173c7 100644 --- a/src/cloudflare/resources/radar/geolocations.py +++ b/src/cloudflare/resources/radar/geolocations.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -146,7 +146,7 @@ def get( if not geo_id: raise ValueError(f"Expected a non-empty value for `geo_id` but received {geo_id!r}") return self._get( - f"/radar/geolocations/{geo_id}", + path_template("/radar/geolocations/{geo_id}", geo_id=geo_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -279,7 +279,7 @@ async def get( if not geo_id: raise ValueError(f"Expected a non-empty value for `geo_id` but received {geo_id!r}") return await self._get( - f"/radar/geolocations/{geo_id}", + path_template("/radar/geolocations/{geo_id}", geo_id=geo_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/ases/bot_class.py b/src/cloudflare/resources/radar/http/ases/bot_class.py index e383e6b7f98..656005c4b1b 100644 --- a/src/cloudflare/resources/radar/http/ases/bot_class.py +++ b/src/cloudflare/resources/radar/http/ases/bot_class.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not bot_class: raise ValueError(f"Expected a non-empty value for `bot_class` but received {bot_class!r}") return self._get( - f"/radar/http/top/ases/bot_class/{bot_class}", + path_template("/radar/http/top/ases/bot_class/{bot_class}", bot_class=bot_class), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not bot_class: raise ValueError(f"Expected a non-empty value for `bot_class` but received {bot_class!r}") return await self._get( - f"/radar/http/top/ases/bot_class/{bot_class}", + path_template("/radar/http/top/ases/bot_class/{bot_class}", bot_class=bot_class), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/ases/browser_family.py b/src/cloudflare/resources/radar/http/ases/browser_family.py index f00473cde74..5c93dd18d21 100644 --- a/src/cloudflare/resources/radar/http/ases/browser_family.py +++ b/src/cloudflare/resources/radar/http/ases/browser_family.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not browser_family: raise ValueError(f"Expected a non-empty value for `browser_family` but received {browser_family!r}") return self._get( - f"/radar/http/top/ases/browser_family/{browser_family}", + path_template("/radar/http/top/ases/browser_family/{browser_family}", browser_family=browser_family), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not browser_family: raise ValueError(f"Expected a non-empty value for `browser_family` but received {browser_family!r}") return await self._get( - f"/radar/http/top/ases/browser_family/{browser_family}", + path_template("/radar/http/top/ases/browser_family/{browser_family}", browser_family=browser_family), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/ases/device_type.py b/src/cloudflare/resources/radar/http/ases/device_type.py index 85aaf98bcae..a36a34567d1 100644 --- a/src/cloudflare/resources/radar/http/ases/device_type.py +++ b/src/cloudflare/resources/radar/http/ases/device_type.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not device_type: raise ValueError(f"Expected a non-empty value for `device_type` but received {device_type!r}") return self._get( - f"/radar/http/top/ases/device_type/{device_type}", + path_template("/radar/http/top/ases/device_type/{device_type}", device_type=device_type), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not device_type: raise ValueError(f"Expected a non-empty value for `device_type` but received {device_type!r}") return await self._get( - f"/radar/http/top/ases/device_type/{device_type}", + path_template("/radar/http/top/ases/device_type/{device_type}", device_type=device_type), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/ases/http_method.py b/src/cloudflare/resources/radar/http/ases/http_method.py index b6983067121..594174e7622 100644 --- a/src/cloudflare/resources/radar/http/ases/http_method.py +++ b/src/cloudflare/resources/radar/http/ases/http_method.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not http_version: raise ValueError(f"Expected a non-empty value for `http_version` but received {http_version!r}") return self._get( - f"/radar/http/top/ases/http_version/{http_version}", + path_template("/radar/http/top/ases/http_version/{http_version}", http_version=http_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not http_version: raise ValueError(f"Expected a non-empty value for `http_version` but received {http_version!r}") return await self._get( - f"/radar/http/top/ases/http_version/{http_version}", + path_template("/radar/http/top/ases/http_version/{http_version}", http_version=http_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/ases/http_protocol.py b/src/cloudflare/resources/radar/http/ases/http_protocol.py index ab95425cb9d..6eb9a5cfaa6 100644 --- a/src/cloudflare/resources/radar/http/ases/http_protocol.py +++ b/src/cloudflare/resources/radar/http/ases/http_protocol.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not http_protocol: raise ValueError(f"Expected a non-empty value for `http_protocol` but received {http_protocol!r}") return self._get( - f"/radar/http/top/ases/http_protocol/{http_protocol}", + path_template("/radar/http/top/ases/http_protocol/{http_protocol}", http_protocol=http_protocol), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not http_protocol: raise ValueError(f"Expected a non-empty value for `http_protocol` but received {http_protocol!r}") return await self._get( - f"/radar/http/top/ases/http_protocol/{http_protocol}", + path_template("/radar/http/top/ases/http_protocol/{http_protocol}", http_protocol=http_protocol), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/ases/ip_version.py b/src/cloudflare/resources/radar/http/ases/ip_version.py index f70d9e2093b..9c1a2a07f47 100644 --- a/src/cloudflare/resources/radar/http/ases/ip_version.py +++ b/src/cloudflare/resources/radar/http/ases/ip_version.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not ip_version: raise ValueError(f"Expected a non-empty value for `ip_version` but received {ip_version!r}") return self._get( - f"/radar/http/top/ases/ip_version/{ip_version}", + path_template("/radar/http/top/ases/ip_version/{ip_version}", ip_version=ip_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not ip_version: raise ValueError(f"Expected a non-empty value for `ip_version` but received {ip_version!r}") return await self._get( - f"/radar/http/top/ases/ip_version/{ip_version}", + path_template("/radar/http/top/ases/ip_version/{ip_version}", ip_version=ip_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/ases/os.py b/src/cloudflare/resources/radar/http/ases/os.py index b9404151a52..caa082814d3 100644 --- a/src/cloudflare/resources/radar/http/ases/os.py +++ b/src/cloudflare/resources/radar/http/ases/os.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not os: raise ValueError(f"Expected a non-empty value for `os` but received {os!r}") return self._get( - f"/radar/http/top/ases/os/{os}", + path_template("/radar/http/top/ases/os/{os}", os=os), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not os: raise ValueError(f"Expected a non-empty value for `os` but received {os!r}") return await self._get( - f"/radar/http/top/ases/os/{os}", + path_template("/radar/http/top/ases/os/{os}", os=os), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/ases/tls_version.py b/src/cloudflare/resources/radar/http/ases/tls_version.py index bbcb2a7e18f..7ce8e454698 100644 --- a/src/cloudflare/resources/radar/http/ases/tls_version.py +++ b/src/cloudflare/resources/radar/http/ases/tls_version.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not tls_version: raise ValueError(f"Expected a non-empty value for `tls_version` but received {tls_version!r}") return self._get( - f"/radar/http/top/ases/tls_version/{tls_version}", + path_template("/radar/http/top/ases/tls_version/{tls_version}", tls_version=tls_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not tls_version: raise ValueError(f"Expected a non-empty value for `tls_version` but received {tls_version!r}") return await self._get( - f"/radar/http/top/ases/tls_version/{tls_version}", + path_template("/radar/http/top/ases/tls_version/{tls_version}", tls_version=tls_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/http.py b/src/cloudflare/resources/radar/http/http.py index 90dc011257e..3ab807b4471 100644 --- a/src/cloudflare/resources/radar/http/http.py +++ b/src/cloudflare/resources/radar/http/http.py @@ -25,7 +25,7 @@ AsyncSummaryResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from .ases.ases import ( AsesResource, AsyncAsesResource, @@ -216,7 +216,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/http/summary/{dimension}", + path_template("/radar/http/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -497,7 +497,7 @@ def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/http/timeseries_groups/{dimension}", + path_template("/radar/http/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -681,7 +681,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/http/summary/{dimension}", + path_template("/radar/http/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -962,7 +962,7 @@ async def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/http/timeseries_groups/{dimension}", + path_template("/radar/http/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/locations/bot_class.py b/src/cloudflare/resources/radar/http/locations/bot_class.py index 207ffcaa027..428b641ab98 100644 --- a/src/cloudflare/resources/radar/http/locations/bot_class.py +++ b/src/cloudflare/resources/radar/http/locations/bot_class.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -138,7 +138,7 @@ def get( if not bot_class: raise ValueError(f"Expected a non-empty value for `bot_class` but received {bot_class!r}") return self._get( - f"/radar/http/top/locations/bot_class/{bot_class}", + path_template("/radar/http/top/locations/bot_class/{bot_class}", bot_class=bot_class), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -284,7 +284,7 @@ async def get( if not bot_class: raise ValueError(f"Expected a non-empty value for `bot_class` but received {bot_class!r}") return await self._get( - f"/radar/http/top/locations/bot_class/{bot_class}", + path_template("/radar/http/top/locations/bot_class/{bot_class}", bot_class=bot_class), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/locations/browser_family.py b/src/cloudflare/resources/radar/http/locations/browser_family.py index bc5a5db3ea3..d3497659723 100644 --- a/src/cloudflare/resources/radar/http/locations/browser_family.py +++ b/src/cloudflare/resources/radar/http/locations/browser_family.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -138,7 +138,7 @@ def get( if not browser_family: raise ValueError(f"Expected a non-empty value for `browser_family` but received {browser_family!r}") return self._get( - f"/radar/http/top/locations/browser_family/{browser_family}", + path_template("/radar/http/top/locations/browser_family/{browser_family}", browser_family=browser_family), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -284,7 +284,7 @@ async def get( if not browser_family: raise ValueError(f"Expected a non-empty value for `browser_family` but received {browser_family!r}") return await self._get( - f"/radar/http/top/locations/browser_family/{browser_family}", + path_template("/radar/http/top/locations/browser_family/{browser_family}", browser_family=browser_family), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/locations/device_type.py b/src/cloudflare/resources/radar/http/locations/device_type.py index 5300107f97d..f8600053578 100644 --- a/src/cloudflare/resources/radar/http/locations/device_type.py +++ b/src/cloudflare/resources/radar/http/locations/device_type.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -138,7 +138,7 @@ def get( if not device_type: raise ValueError(f"Expected a non-empty value for `device_type` but received {device_type!r}") return self._get( - f"/radar/http/top/locations/device_type/{device_type}", + path_template("/radar/http/top/locations/device_type/{device_type}", device_type=device_type), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -284,7 +284,7 @@ async def get( if not device_type: raise ValueError(f"Expected a non-empty value for `device_type` but received {device_type!r}") return await self._get( - f"/radar/http/top/locations/device_type/{device_type}", + path_template("/radar/http/top/locations/device_type/{device_type}", device_type=device_type), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/locations/http_method.py b/src/cloudflare/resources/radar/http/locations/http_method.py index 639ad34ed89..6d19ee42cd5 100644 --- a/src/cloudflare/resources/radar/http/locations/http_method.py +++ b/src/cloudflare/resources/radar/http/locations/http_method.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -138,7 +138,7 @@ def get( if not http_version: raise ValueError(f"Expected a non-empty value for `http_version` but received {http_version!r}") return self._get( - f"/radar/http/top/locations/http_version/{http_version}", + path_template("/radar/http/top/locations/http_version/{http_version}", http_version=http_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -284,7 +284,7 @@ async def get( if not http_version: raise ValueError(f"Expected a non-empty value for `http_version` but received {http_version!r}") return await self._get( - f"/radar/http/top/locations/http_version/{http_version}", + path_template("/radar/http/top/locations/http_version/{http_version}", http_version=http_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/locations/http_protocol.py b/src/cloudflare/resources/radar/http/locations/http_protocol.py index a4df4deecf5..3a0158e4222 100644 --- a/src/cloudflare/resources/radar/http/locations/http_protocol.py +++ b/src/cloudflare/resources/radar/http/locations/http_protocol.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -138,7 +138,7 @@ def get( if not http_protocol: raise ValueError(f"Expected a non-empty value for `http_protocol` but received {http_protocol!r}") return self._get( - f"/radar/http/top/locations/http_protocol/{http_protocol}", + path_template("/radar/http/top/locations/http_protocol/{http_protocol}", http_protocol=http_protocol), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -284,7 +284,7 @@ async def get( if not http_protocol: raise ValueError(f"Expected a non-empty value for `http_protocol` but received {http_protocol!r}") return await self._get( - f"/radar/http/top/locations/http_protocol/{http_protocol}", + path_template("/radar/http/top/locations/http_protocol/{http_protocol}", http_protocol=http_protocol), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/locations/ip_version.py b/src/cloudflare/resources/radar/http/locations/ip_version.py index c5f62f7a46e..184ae43c04c 100644 --- a/src/cloudflare/resources/radar/http/locations/ip_version.py +++ b/src/cloudflare/resources/radar/http/locations/ip_version.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -138,7 +138,7 @@ def get( if not ip_version: raise ValueError(f"Expected a non-empty value for `ip_version` but received {ip_version!r}") return self._get( - f"/radar/http/top/locations/ip_version/{ip_version}", + path_template("/radar/http/top/locations/ip_version/{ip_version}", ip_version=ip_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -284,7 +284,7 @@ async def get( if not ip_version: raise ValueError(f"Expected a non-empty value for `ip_version` but received {ip_version!r}") return await self._get( - f"/radar/http/top/locations/ip_version/{ip_version}", + path_template("/radar/http/top/locations/ip_version/{ip_version}", ip_version=ip_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/locations/os.py b/src/cloudflare/resources/radar/http/locations/os.py index ab46ba089cf..3ef50776edc 100644 --- a/src/cloudflare/resources/radar/http/locations/os.py +++ b/src/cloudflare/resources/radar/http/locations/os.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not os: raise ValueError(f"Expected a non-empty value for `os` but received {os!r}") return self._get( - f"/radar/http/top/locations/os/{os}", + path_template("/radar/http/top/locations/os/{os}", os=os), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not os: raise ValueError(f"Expected a non-empty value for `os` but received {os!r}") return await self._get( - f"/radar/http/top/locations/os/{os}", + path_template("/radar/http/top/locations/os/{os}", os=os), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/http/locations/tls_version.py b/src/cloudflare/resources/radar/http/locations/tls_version.py index d53cd40360c..a342f294e68 100644 --- a/src/cloudflare/resources/radar/http/locations/tls_version.py +++ b/src/cloudflare/resources/radar/http/locations/tls_version.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -139,7 +139,7 @@ def get( if not tls_version: raise ValueError(f"Expected a non-empty value for `tls_version` but received {tls_version!r}") return self._get( - f"/radar/http/top/locations/tls_version/{tls_version}", + path_template("/radar/http/top/locations/tls_version/{tls_version}", tls_version=tls_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +286,7 @@ async def get( if not tls_version: raise ValueError(f"Expected a non-empty value for `tls_version` but received {tls_version!r}") return await self._get( - f"/radar/http/top/locations/tls_version/{tls_version}", + path_template("/radar/http/top/locations/tls_version/{tls_version}", tls_version=tls_version), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/leaked_credentials/leaked_credentials.py b/src/cloudflare/resources/radar/leaked_credentials/leaked_credentials.py index 565ce6034c7..a8d055ea1f3 100644 --- a/src/cloudflare/resources/radar/leaked_credentials/leaked_credentials.py +++ b/src/cloudflare/resources/radar/leaked_credentials/leaked_credentials.py @@ -17,7 +17,7 @@ AsyncSummaryResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -145,7 +145,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/leaked_credential_checks/summary/{dimension}", + path_template("/radar/leaked_credential_checks/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -267,7 +267,7 @@ def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/leaked_credential_checks/timeseries_groups/{dimension}", + path_template("/radar/leaked_credential_checks/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -403,7 +403,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/leaked_credential_checks/summary/{dimension}", + path_template("/radar/leaked_credential_checks/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -525,7 +525,7 @@ async def timeseries_groups_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/leaked_credential_checks/timeseries_groups/{dimension}", + path_template("/radar/leaked_credential_checks/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/netflows/netflows.py b/src/cloudflare/resources/radar/netflows/netflows.py index 04cfe8a3157..41beb4de06d 100644 --- a/src/cloudflare/resources/radar/netflows/netflows.py +++ b/src/cloudflare/resources/radar/netflows/netflows.py @@ -18,7 +18,7 @@ AsyncTopResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -234,7 +234,7 @@ def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/netflows/summary/{dimension}", + path_template("/radar/netflows/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -448,7 +448,7 @@ def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/netflows/timeseries_groups/{dimension}", + path_template("/radar/netflows/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -669,7 +669,7 @@ async def summary_v2( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/netflows/summary/{dimension}", + path_template("/radar/netflows/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -883,7 +883,7 @@ async def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/netflows/timeseries_groups/{dimension}", + path_template("/radar/netflows/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/post_quantum/origin.py b/src/cloudflare/resources/radar/post_quantum/origin.py index 87f5ad54f8f..9d58de9b4b2 100644 --- a/src/cloudflare/resources/radar/post_quantum/origin.py +++ b/src/cloudflare/resources/radar/post_quantum/origin.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -93,7 +93,7 @@ def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/post_quantum/origin/summary/{dimension}", + path_template("/radar/post_quantum/origin/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -160,7 +160,7 @@ def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return self._get( - f"/radar/post_quantum/origin/timeseries_groups/{dimension}", + path_template("/radar/post_quantum/origin/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -248,7 +248,7 @@ async def summary( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/post_quantum/origin/summary/{dimension}", + path_template("/radar/post_quantum/origin/summary/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -315,7 +315,7 @@ async def timeseries_groups( if not dimension: raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}") return await self._get( - f"/radar/post_quantum/origin/timeseries_groups/{dimension}", + path_template("/radar/post_quantum/origin/timeseries_groups/{dimension}", dimension=dimension), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/radar/radar.py b/src/cloudflare/resources/radar/radar.py index 8663fda883b..aaaa545c036 100644 --- a/src/cloudflare/resources/radar/radar.py +++ b/src/cloudflare/resources/radar/radar.py @@ -92,6 +92,14 @@ GeolocationsResourceWithStreamingResponse, AsyncGeolocationsResourceWithStreamingResponse, ) +from .agent_readiness import ( + AgentReadinessResource, + AsyncAgentReadinessResource, + AgentReadinessResourceWithRawResponse, + AsyncAgentReadinessResourceWithRawResponse, + AgentReadinessResourceWithStreamingResponse, + AsyncAgentReadinessResourceWithStreamingResponse, +) from .attacks.attacks import ( AttacksResource, AsyncAttacksResource, @@ -193,6 +201,10 @@ class RadarResource(SyncAPIResource): + @cached_property + def agent_readiness(self) -> AgentReadinessResource: + return AgentReadinessResource(self._client) + @cached_property def ai(self) -> AIResource: return AIResource(self._client) @@ -306,6 +318,10 @@ def with_streaming_response(self) -> RadarResourceWithStreamingResponse: class AsyncRadarResource(AsyncAPIResource): + @cached_property + def agent_readiness(self) -> AsyncAgentReadinessResource: + return AsyncAgentReadinessResource(self._client) + @cached_property def ai(self) -> AsyncAIResource: return AsyncAIResource(self._client) @@ -422,6 +438,10 @@ class RadarResourceWithRawResponse: def __init__(self, radar: RadarResource) -> None: self._radar = radar + @cached_property + def agent_readiness(self) -> AgentReadinessResourceWithRawResponse: + return AgentReadinessResourceWithRawResponse(self._radar.agent_readiness) + @cached_property def ai(self) -> AIResourceWithRawResponse: return AIResourceWithRawResponse(self._radar.ai) @@ -519,6 +539,10 @@ class AsyncRadarResourceWithRawResponse: def __init__(self, radar: AsyncRadarResource) -> None: self._radar = radar + @cached_property + def agent_readiness(self) -> AsyncAgentReadinessResourceWithRawResponse: + return AsyncAgentReadinessResourceWithRawResponse(self._radar.agent_readiness) + @cached_property def ai(self) -> AsyncAIResourceWithRawResponse: return AsyncAIResourceWithRawResponse(self._radar.ai) @@ -616,6 +640,10 @@ class RadarResourceWithStreamingResponse: def __init__(self, radar: RadarResource) -> None: self._radar = radar + @cached_property + def agent_readiness(self) -> AgentReadinessResourceWithStreamingResponse: + return AgentReadinessResourceWithStreamingResponse(self._radar.agent_readiness) + @cached_property def ai(self) -> AIResourceWithStreamingResponse: return AIResourceWithStreamingResponse(self._radar.ai) @@ -713,6 +741,10 @@ class AsyncRadarResourceWithStreamingResponse: def __init__(self, radar: AsyncRadarResource) -> None: self._radar = radar + @cached_property + def agent_readiness(self) -> AsyncAgentReadinessResourceWithStreamingResponse: + return AsyncAgentReadinessResourceWithStreamingResponse(self._radar.agent_readiness) + @cached_property def ai(self) -> AsyncAIResourceWithStreamingResponse: return AsyncAIResourceWithStreamingResponse(self._radar.ai) diff --git a/src/cloudflare/resources/radar/ranking/domain.py b/src/cloudflare/resources/radar/ranking/domain.py index 7ec008fe5ec..25a22058c30 100644 --- a/src/cloudflare/resources/radar/ranking/domain.py +++ b/src/cloudflare/resources/radar/ranking/domain.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -96,7 +96,7 @@ def get( if not domain: raise ValueError(f"Expected a non-empty value for `domain` but received {domain!r}") return self._get( - f"/radar/ranking/domain/{domain}", + path_template("/radar/ranking/domain/{domain}", domain=domain), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -189,7 +189,7 @@ async def get( if not domain: raise ValueError(f"Expected a non-empty value for `domain` but received {domain!r}") return await self._get( - f"/radar/ranking/domain/{domain}", + path_template("/radar/ranking/domain/{domain}", domain=domain), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/rate_limits/__init__.py b/src/cloudflare/resources/rate_limits/__init__.py new file mode 100644 index 00000000000..76e5a5aee65 --- /dev/null +++ b/src/cloudflare/resources/rate_limits/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .rate_limits import ( + RateLimitsResource, + AsyncRateLimitsResource, + RateLimitsResourceWithRawResponse, + AsyncRateLimitsResourceWithRawResponse, + RateLimitsResourceWithStreamingResponse, + AsyncRateLimitsResourceWithStreamingResponse, +) + +__all__ = [ + "RateLimitsResource", + "AsyncRateLimitsResource", + "RateLimitsResourceWithRawResponse", + "AsyncRateLimitsResourceWithRawResponse", + "RateLimitsResourceWithStreamingResponse", + "AsyncRateLimitsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/rate_limits/api.md b/src/cloudflare/resources/rate_limits/api.md new file mode 100644 index 00000000000..497a722b007 --- /dev/null +++ b/src/cloudflare/resources/rate_limits/api.md @@ -0,0 +1,15 @@ +# RateLimits + +Types: + +```python +from cloudflare.types.rate_limits import Action, RateLimit, RateLimitDeleteResponse +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/rate_limits.py b/src/cloudflare/resources/rate_limits/rate_limits.py similarity index 91% rename from src/cloudflare/resources/rate_limits.py rename to src/cloudflare/resources/rate_limits/rate_limits.py index 31110953cfa..a604abb93f8 100644 --- a/src/cloudflare/resources/rate_limits.py +++ b/src/cloudflare/resources/rate_limits/rate_limits.py @@ -7,22 +7,22 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, 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.rate_limits import rate_limit_edit_params, rate_limit_list_params, rate_limit_create_params -from ..types.rate_limits.rate_limit import RateLimit -from ..types.rate_limits.rate_limit_delete_response import RateLimitDeleteResponse +from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.rate_limits import rate_limit_edit_params, rate_limit_list_params, rate_limit_create_params +from ...types.rate_limits.rate_limit import RateLimit +from ...types.rate_limits.rate_limit_delete_response import RateLimitDeleteResponse __all__ = ["RateLimitsResource", "AsyncRateLimitsResource"] @@ -53,7 +53,7 @@ def with_streaming_response(self) -> RateLimitsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, action: rate_limit_create_params.Action, match: rate_limit_create_params.Match, period: float, @@ -93,10 +93,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/rate_limits", + path_template("/zones/{zone_id}/rate_limits", zone_id=zone_id), body=maybe_transform( { "action": action, @@ -122,7 +124,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -151,10 +153,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/rate_limits", + path_template("/zones/{zone_id}/rate_limits", zone_id=zone_id), page=SyncV4PagePaginationArray[RateLimit], options=make_request_options( extra_headers=extra_headers, @@ -179,7 +183,7 @@ def delete( self, rate_limit_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -203,12 +207,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rate_limit_id: raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") return self._delete( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", + path_template("/zones/{zone_id}/rate_limits/{rate_limit_id}", zone_id=zone_id, rate_limit_id=rate_limit_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -226,7 +232,7 @@ def edit( self, rate_limit_id: str, *, - zone_id: str, + zone_id: str | None = None, action: rate_limit_edit_params.Action, match: rate_limit_edit_params.Match, period: float, @@ -266,12 +272,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rate_limit_id: raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") return self._put( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", + path_template("/zones/{zone_id}/rate_limits/{rate_limit_id}", zone_id=zone_id, rate_limit_id=rate_limit_id), body=maybe_transform( { "action": action, @@ -298,7 +306,7 @@ def get( self, rate_limit_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -322,12 +330,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rate_limit_id: raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") return self._get( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", + path_template("/zones/{zone_id}/rate_limits/{rate_limit_id}", zone_id=zone_id, rate_limit_id=rate_limit_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -365,7 +375,7 @@ def with_streaming_response(self) -> AsyncRateLimitsResourceWithStreamingRespons async def create( self, *, - zone_id: str, + zone_id: str | None = None, action: rate_limit_create_params.Action, match: rate_limit_create_params.Match, period: float, @@ -405,10 +415,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/rate_limits", + path_template("/zones/{zone_id}/rate_limits", zone_id=zone_id), body=await async_maybe_transform( { "action": action, @@ -434,7 +446,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -463,10 +475,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/rate_limits", + path_template("/zones/{zone_id}/rate_limits", zone_id=zone_id), page=AsyncV4PagePaginationArray[RateLimit], options=make_request_options( extra_headers=extra_headers, @@ -491,7 +505,7 @@ async def delete( self, rate_limit_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -515,12 +529,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rate_limit_id: raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") return await self._delete( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", + path_template("/zones/{zone_id}/rate_limits/{rate_limit_id}", zone_id=zone_id, rate_limit_id=rate_limit_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -538,7 +554,7 @@ async def edit( self, rate_limit_id: str, *, - zone_id: str, + zone_id: str | None = None, action: rate_limit_edit_params.Action, match: rate_limit_edit_params.Match, period: float, @@ -578,12 +594,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rate_limit_id: raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") return await self._put( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", + path_template("/zones/{zone_id}/rate_limits/{rate_limit_id}", zone_id=zone_id, rate_limit_id=rate_limit_id), body=await async_maybe_transform( { "action": action, @@ -610,7 +628,7 @@ async def get( self, rate_limit_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -634,12 +652,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rate_limit_id: raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") return await self._get( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", + path_template("/zones/{zone_id}/rate_limits/{rate_limit_id}", zone_id=zone_id, rate_limit_id=rate_limit_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/realtime_kit/active_session.py b/src/cloudflare/resources/realtime_kit/active_session.py index e209bbf510e..2a40dc86148 100644 --- a/src/cloudflare/resources/realtime_kit/active_session.py +++ b/src/cloudflare/resources/realtime_kit/active_session.py @@ -5,7 +5,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def create_poll( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, options: SequenceNotStr[str], question: str, @@ -85,6 +85,8 @@ def create_poll( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -92,7 +94,12 @@ def create_poll( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/poll", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/poll", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=maybe_transform( { "options": options, @@ -112,7 +119,7 @@ def get_active_session( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -137,6 +144,8 @@ def get_active_session( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -144,7 +153,12 @@ def get_active_session( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -155,7 +169,7 @@ def kick_all_participants( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -180,6 +194,8 @@ def kick_all_participants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -187,7 +203,12 @@ def kick_all_participants( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/kick-all", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/kick-all", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -198,7 +219,7 @@ def kick_participants( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, custom_participant_ids: SequenceNotStr[str], participant_ids: SequenceNotStr[str], @@ -226,6 +247,8 @@ def kick_participants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -233,7 +256,12 @@ def kick_participants( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/kick", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/kick", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=maybe_transform( { "custom_participant_ids": custom_participant_ids, @@ -272,7 +300,7 @@ async def create_poll( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, options: SequenceNotStr[str], question: str, @@ -309,6 +337,8 @@ async def create_poll( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -316,7 +346,12 @@ async def create_poll( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/poll", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/poll", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=await async_maybe_transform( { "options": options, @@ -336,7 +371,7 @@ async def get_active_session( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -361,6 +396,8 @@ async def get_active_session( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -368,7 +405,12 @@ async def get_active_session( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -379,7 +421,7 @@ async def kick_all_participants( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -404,6 +446,8 @@ async def kick_all_participants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -411,7 +455,12 @@ async def kick_all_participants( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/kick-all", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/kick-all", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -422,7 +471,7 @@ async def kick_participants( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, custom_participant_ids: SequenceNotStr[str], participant_ids: SequenceNotStr[str], @@ -450,6 +499,8 @@ async def kick_participants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -457,7 +508,12 @@ async def kick_participants( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/kick", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/kick", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=await async_maybe_transform( { "custom_participant_ids": custom_participant_ids, diff --git a/src/cloudflare/resources/realtime_kit/analytics.py b/src/cloudflare/resources/realtime_kit/analytics.py index 7ddd06c737c..ca0c626bb06 100644 --- a/src/cloudflare/resources/realtime_kit/analytics.py +++ b/src/cloudflare/resources/realtime_kit/analytics.py @@ -5,7 +5,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +45,7 @@ def get_org_analytics( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_date: str | Omit = omit, start_date: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,12 +77,16 @@ def get_org_analytics( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/analytics/daywise", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/analytics/daywise", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -124,7 +128,7 @@ async def get_org_analytics( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_date: str | Omit = omit, start_date: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -156,12 +160,16 @@ async def get_org_analytics( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/analytics/daywise", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/analytics/daywise", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/realtime_kit/api.md b/src/cloudflare/resources/realtime_kit/api.md new file mode 100644 index 00000000000..0f7eb303012 --- /dev/null +++ b/src/cloudflare/resources/realtime_kit/api.md @@ -0,0 +1,210 @@ +# RealtimeKit + +## Apps + +Types: + +```python +from cloudflare.types.realtime_kit import AppGetResponse, AppPostResponse +``` + +Methods: + +- client.realtime_kit.apps.get(\*, account_id) -> AppGetResponse +- client.realtime_kit.apps.post(\*, account_id, \*\*params) -> AppPostResponse + +## Meetings + +Types: + +```python +from cloudflare.types.realtime_kit import ( + MeetingCreateResponse, + MeetingAddParticipantResponse, + MeetingDeleteMeetingParticipantResponse, + MeetingEditParticipantResponse, + MeetingGetResponse, + MeetingGetMeetingByIDResponse, + MeetingGetMeetingParticipantResponse, + MeetingGetMeetingParticipantsResponse, + MeetingRefreshParticipantTokenResponse, + MeetingReplaceMeetingByIDResponse, + MeetingUpdateMeetingByIDResponse, +) +``` + +Methods: + +- 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 + +## Presets + +Types: + +```python +from cloudflare.types.realtime_kit import ( + PresetCreateResponse, + PresetUpdateResponse, + PresetDeleteResponse, + PresetGetResponse, + PresetGetPresetByIDResponse, +) +``` + +Methods: + +- 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 + +## Sessions + +Types: + +```python +from cloudflare.types.realtime_kit import ( + SessionGetParticipantDataFromPeerIDResponse, + SessionGetSessionChatResponse, + SessionGetSessionDetailsResponse, + SessionGetSessionParticipantDetailsResponse, + SessionGetSessionParticipantsResponse, + SessionGetSessionSummaryResponse, + SessionGetSessionTranscriptsResponse, + SessionGetSessionsResponse, +) +``` + +Methods: + +- 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 + +## Recordings + +Types: + +```python +from cloudflare.types.realtime_kit import ( + RecordingGetActiveRecordingsResponse, + RecordingGetOneRecordingResponse, + RecordingGetRecordingsResponse, + RecordingPauseResumeStopRecordingResponse, + RecordingStartRecordingsResponse, +) +``` + +Methods: + +- 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 + +## Webhooks + +Types: + +```python +from cloudflare.types.realtime_kit import ( + WebhookCreateWebhookResponse, + WebhookDeleteWebhookResponse, + WebhookEditWebhookResponse, + WebhookGetWebhookByIDResponse, + WebhookGetWebhooksResponse, + WebhookReplaceWebhookResponse, +) +``` + +Methods: + +- 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 + +## ActiveSession + +Types: + +```python +from cloudflare.types.realtime_kit import ( + ActiveSessionCreatePollResponse, + ActiveSessionGetActiveSessionResponse, + ActiveSessionKickAllParticipantsResponse, + ActiveSessionKickParticipantsResponse, +) +``` + +Methods: + +- 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 + +## Livestreams + +Types: + +```python +from cloudflare.types.realtime_kit import ( + LivestreamCreateIndependentLivestreamResponse, + LivestreamGetActiveLivestreamsForLivestreamIDResponse, + LivestreamGetAllLivestreamsResponse, + LivestreamGetLivestreamAnalyticsCompleteResponse, + LivestreamGetLivestreamSessionDetailsForSessionIDResponse, + LivestreamGetLivestreamSessionForLivestreamIDResponse, + LivestreamGetMeetingActiveLivestreamsResponse, + LivestreamGetOrgAnalyticsResponse, + LivestreamStartLivestreamingAMeetingResponse, + LivestreamStopLivestreamingAMeetingResponse, +) +``` + +Methods: + +- 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 + +## Analytics + +Types: + +```python +from cloudflare.types.realtime_kit import AnalyticsGetOrgAnalyticsResponse +``` + +Methods: + +- client.realtime_kit.analytics.get_org_analytics(app_id, \*, account_id, \*\*params) -> AnalyticsGetOrgAnalyticsResponse diff --git a/src/cloudflare/resources/realtime_kit/apps.py b/src/cloudflare/resources/realtime_kit/apps.py index c172fa1992c..9910f332817 100644 --- a/src/cloudflare/resources/realtime_kit/apps.py +++ b/src/cloudflare/resources/realtime_kit/apps.py @@ -5,7 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +45,7 @@ def with_streaming_response(self) -> AppsResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +67,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/realtime/kit/apps", + path_template("/accounts/{account_id}/realtime/kit/apps", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -80,7 +82,7 @@ def get( def post( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -101,10 +103,12 @@ def post( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/realtime/kit/apps", + path_template("/accounts/{account_id}/realtime/kit/apps", account_id=account_id), body=maybe_transform({"name": name}, app_post_params.AppPostParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -136,7 +140,7 @@ def with_streaming_response(self) -> AsyncAppsResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -158,10 +162,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/realtime/kit/apps", + path_template("/accounts/{account_id}/realtime/kit/apps", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -171,7 +177,7 @@ async def get( async def post( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -192,10 +198,12 @@ async def post( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/realtime/kit/apps", + path_template("/accounts/{account_id}/realtime/kit/apps", account_id=account_id), body=await async_maybe_transform({"name": name}, app_post_params.AppPostParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/realtime_kit/livestreams.py b/src/cloudflare/resources/realtime_kit/livestreams.py index 4f1958cff4c..49a1ff212ca 100644 --- a/src/cloudflare/resources/realtime_kit/livestreams.py +++ b/src/cloudflare/resources/realtime_kit/livestreams.py @@ -9,7 +9,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -81,7 +81,7 @@ def create_independent_livestream( self, app_id: str, *, - account_id: str, + account_id: str | None = None, name: 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. @@ -111,12 +111,16 @@ def create_independent_livestream( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams", account_id=account_id, app_id=app_id + ), body=maybe_transform( {"name": name}, livestream_create_independent_livestream_params.LivestreamCreateIndependentLivestreamParams, @@ -131,7 +135,7 @@ def get_active_livestreams_for_livestream_id( self, livestream_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -158,6 +162,8 @@ def get_active_livestreams_for_livestream_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -165,7 +171,12 @@ def get_active_livestreams_for_livestream_id( if not livestream_id: raise ValueError(f"Expected a non-empty value for `livestream_id` but received {livestream_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}/active-livestream-session", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}/active-livestream-session", + account_id=account_id, + app_id=app_id, + livestream_id=livestream_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -176,7 +187,7 @@ def get_all_livestreams( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_time: Union[str, datetime] | Omit = omit, exclude_meetings: bool | Omit = omit, page_no: int | Omit = omit, @@ -225,12 +236,16 @@ def get_all_livestreams( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -256,7 +271,7 @@ def get_livestream_analytics_complete( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_time: Union[str, datetime] | Omit = omit, start_time: 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. @@ -286,12 +301,18 @@ def get_livestream_analytics_complete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/analytics/livestreams/overall", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/analytics/livestreams/overall", + account_id=account_id, + app_id=app_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -312,7 +333,7 @@ def get_livestream_session_details_for_session_id( self, livestream_session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -340,6 +361,8 @@ def get_livestream_session_details_for_session_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -349,7 +372,12 @@ def get_livestream_session_details_for_session_id( f"Expected a non-empty value for `livestream_session_id` but received {livestream_session_id!r}" ) return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams/sessions/{livestream_session_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams/sessions/{livestream_session_id}", + account_id=account_id, + app_id=app_id, + livestream_session_id=livestream_session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -360,7 +388,7 @@ def get_livestream_session_for_livestream_id( self, livestream_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, page_no: int | Omit = omit, per_page: int | Omit = omit, @@ -392,6 +420,8 @@ def get_livestream_session_for_livestream_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -399,7 +429,12 @@ def get_livestream_session_for_livestream_id( if not livestream_id: raise ValueError(f"Expected a non-empty value for `livestream_id` but received {livestream_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}", + account_id=account_id, + app_id=app_id, + livestream_id=livestream_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -420,7 +455,7 @@ def get_meeting_active_livestreams( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -445,6 +480,8 @@ def get_meeting_active_livestreams( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -452,7 +489,12 @@ def get_meeting_active_livestreams( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -463,7 +505,7 @@ def get_org_analytics( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_date: str | Omit = omit, start_date: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -495,12 +537,16 @@ def get_org_analytics( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/analytics/daywise", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/analytics/daywise", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -521,7 +567,7 @@ def start_livestreaming_a_meeting( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, name: Optional[str] | Omit = omit, video_config: livestream_start_livestreaming_a_meeting_params.VideoConfig | Omit = omit, @@ -550,6 +596,8 @@ def start_livestreaming_a_meeting( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -557,7 +605,12 @@ def start_livestreaming_a_meeting( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/livestreams", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/livestreams", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=maybe_transform( { "name": name, @@ -575,7 +628,7 @@ def stop_livestreaming_a_meeting( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -601,6 +654,8 @@ def stop_livestreaming_a_meeting( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -608,7 +663,12 @@ def stop_livestreaming_a_meeting( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream/stop", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream/stop", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -640,7 +700,7 @@ async def create_independent_livestream( self, app_id: str, *, - account_id: str, + account_id: str | None = None, name: 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. @@ -670,12 +730,16 @@ async def create_independent_livestream( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams", account_id=account_id, app_id=app_id + ), body=await async_maybe_transform( {"name": name}, livestream_create_independent_livestream_params.LivestreamCreateIndependentLivestreamParams, @@ -690,7 +754,7 @@ async def get_active_livestreams_for_livestream_id( self, livestream_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -717,6 +781,8 @@ async def get_active_livestreams_for_livestream_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -724,7 +790,12 @@ async def get_active_livestreams_for_livestream_id( if not livestream_id: raise ValueError(f"Expected a non-empty value for `livestream_id` but received {livestream_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}/active-livestream-session", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}/active-livestream-session", + account_id=account_id, + app_id=app_id, + livestream_id=livestream_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -735,7 +806,7 @@ async def get_all_livestreams( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_time: Union[str, datetime] | Omit = omit, exclude_meetings: bool | Omit = omit, page_no: int | Omit = omit, @@ -784,12 +855,16 @@ async def get_all_livestreams( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -815,7 +890,7 @@ async def get_livestream_analytics_complete( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_time: Union[str, datetime] | Omit = omit, start_time: 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. @@ -845,12 +920,18 @@ async def get_livestream_analytics_complete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/analytics/livestreams/overall", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/analytics/livestreams/overall", + account_id=account_id, + app_id=app_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -871,7 +952,7 @@ async def get_livestream_session_details_for_session_id( self, livestream_session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -899,6 +980,8 @@ async def get_livestream_session_details_for_session_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -908,7 +991,12 @@ async def get_livestream_session_details_for_session_id( f"Expected a non-empty value for `livestream_session_id` but received {livestream_session_id!r}" ) return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams/sessions/{livestream_session_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams/sessions/{livestream_session_id}", + account_id=account_id, + app_id=app_id, + livestream_session_id=livestream_session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -919,7 +1007,7 @@ async def get_livestream_session_for_livestream_id( self, livestream_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, page_no: int | Omit = omit, per_page: int | Omit = omit, @@ -951,6 +1039,8 @@ async def get_livestream_session_for_livestream_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -958,7 +1048,12 @@ async def get_livestream_session_for_livestream_id( if not livestream_id: raise ValueError(f"Expected a non-empty value for `livestream_id` but received {livestream_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}", + account_id=account_id, + app_id=app_id, + livestream_id=livestream_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -979,7 +1074,7 @@ async def get_meeting_active_livestreams( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -1004,6 +1099,8 @@ async def get_meeting_active_livestreams( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1011,7 +1108,12 @@ async def get_meeting_active_livestreams( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1022,7 +1124,7 @@ async def get_org_analytics( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_date: str | Omit = omit, start_date: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1054,12 +1156,16 @@ async def get_org_analytics( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/analytics/daywise", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/analytics/daywise", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1080,7 +1186,7 @@ async def start_livestreaming_a_meeting( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, name: Optional[str] | Omit = omit, video_config: livestream_start_livestreaming_a_meeting_params.VideoConfig | Omit = omit, @@ -1109,6 +1215,8 @@ async def start_livestreaming_a_meeting( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1116,7 +1224,12 @@ async def start_livestreaming_a_meeting( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/livestreams", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/livestreams", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=await async_maybe_transform( { "name": name, @@ -1134,7 +1247,7 @@ async def stop_livestreaming_a_meeting( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -1160,6 +1273,8 @@ async def stop_livestreaming_a_meeting( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1167,7 +1282,12 @@ async def stop_livestreaming_a_meeting( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream/stop", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream/stop", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/realtime_kit/meetings.py b/src/cloudflare/resources/realtime_kit/meetings.py index 9e6724443b9..baa0a9e0000 100644 --- a/src/cloudflare/resources/realtime_kit/meetings.py +++ b/src/cloudflare/resources/realtime_kit/meetings.py @@ -9,7 +9,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -68,7 +68,7 @@ def create( self, app_id: str, *, - account_id: str, + account_id: str | None = None, ai_config: meeting_create_params.AIConfig | Omit = omit, live_stream_on_start: Optional[bool] | Omit = omit, persist_chat: bool | Omit = omit, @@ -123,12 +123,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings", account_id=account_id, app_id=app_id + ), body=maybe_transform( { "ai_config": ai_config, @@ -152,7 +156,7 @@ def add_participant( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, custom_participant_id: str, preset_name: str, @@ -190,6 +194,8 @@ def add_participant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -197,7 +203,12 @@ def add_participant( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=maybe_transform( { "custom_participant_id": custom_participant_id, @@ -217,7 +228,7 @@ def delete_meeting_participant( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, meeting_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -243,6 +254,8 @@ def delete_meeting_participant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -252,7 +265,13 @@ def delete_meeting_participant( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return self._delete( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + participant_id=participant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -263,7 +282,7 @@ def edit_participant( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, meeting_id: str, name: Optional[str] | Omit = omit, @@ -298,6 +317,8 @@ def edit_participant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -307,7 +328,13 @@ def edit_participant( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return self._patch( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + participant_id=participant_id, + ), body=maybe_transform( { "name": name, @@ -326,7 +353,7 @@ def get( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_time: Union[str, datetime] | Omit = omit, page_no: float | Omit = omit, per_page: float | Omit = omit, @@ -367,12 +394,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -396,7 +427,7 @@ def get_meeting_by_id( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -422,6 +453,8 @@ def get_meeting_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -429,7 +462,12 @@ def get_meeting_by_id( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -444,7 +482,7 @@ def get_meeting_participant( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, meeting_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -470,6 +508,8 @@ def get_meeting_participant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -479,7 +519,13 @@ def get_meeting_participant( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + participant_id=participant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -490,7 +536,7 @@ def get_meeting_participants( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, page_no: float | Omit = omit, per_page: float | Omit = omit, @@ -521,6 +567,8 @@ def get_meeting_participants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -528,7 +576,12 @@ def get_meeting_participants( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -549,7 +602,7 @@ def refresh_participant_token( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, meeting_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -576,6 +629,8 @@ def refresh_participant_token( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -585,7 +640,13 @@ def refresh_participant_token( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}/token", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}/token", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + participant_id=participant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -596,7 +657,7 @@ def replace_meeting_by_id( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, ai_config: meeting_replace_meeting_by_id_params.AIConfig | Omit = omit, live_stream_on_start: Optional[bool] | Omit = omit, @@ -652,6 +713,8 @@ def replace_meeting_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -659,7 +722,12 @@ def replace_meeting_by_id( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._put( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=maybe_transform( { "ai_config": ai_config, @@ -683,7 +751,7 @@ def update_meeting_by_id( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, ai_config: meeting_update_meeting_by_id_params.AIConfig | Omit = omit, live_stream_on_start: bool | Omit = omit, @@ -738,6 +806,8 @@ def update_meeting_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -745,7 +815,12 @@ def update_meeting_by_id( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._patch( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=maybe_transform( { "ai_config": ai_config, @@ -790,7 +865,7 @@ async def create( self, app_id: str, *, - account_id: str, + account_id: str | None = None, ai_config: meeting_create_params.AIConfig | Omit = omit, live_stream_on_start: Optional[bool] | Omit = omit, persist_chat: bool | Omit = omit, @@ -845,12 +920,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings", account_id=account_id, app_id=app_id + ), body=await async_maybe_transform( { "ai_config": ai_config, @@ -874,7 +953,7 @@ async def add_participant( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, custom_participant_id: str, preset_name: str, @@ -912,6 +991,8 @@ async def add_participant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -919,7 +1000,12 @@ async def add_participant( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=await async_maybe_transform( { "custom_participant_id": custom_participant_id, @@ -939,7 +1025,7 @@ async def delete_meeting_participant( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, meeting_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -965,6 +1051,8 @@ async def delete_meeting_participant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -974,7 +1062,13 @@ async def delete_meeting_participant( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return await self._delete( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + participant_id=participant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -985,7 +1079,7 @@ async def edit_participant( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, meeting_id: str, name: Optional[str] | Omit = omit, @@ -1020,6 +1114,8 @@ async def edit_participant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1029,7 +1125,13 @@ async def edit_participant( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return await self._patch( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + participant_id=participant_id, + ), body=await async_maybe_transform( { "name": name, @@ -1048,7 +1150,7 @@ async def get( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_time: Union[str, datetime] | Omit = omit, page_no: float | Omit = omit, per_page: float | Omit = omit, @@ -1089,12 +1191,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1118,7 +1224,7 @@ async def get_meeting_by_id( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1144,6 +1250,8 @@ async def get_meeting_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1151,7 +1259,12 @@ async def get_meeting_by_id( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1168,7 +1281,7 @@ async def get_meeting_participant( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, meeting_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1194,6 +1307,8 @@ async def get_meeting_participant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1203,7 +1318,13 @@ async def get_meeting_participant( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + participant_id=participant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1214,7 +1335,7 @@ async def get_meeting_participants( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, page_no: float | Omit = omit, per_page: float | Omit = omit, @@ -1245,6 +1366,8 @@ async def get_meeting_participants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1252,7 +1375,12 @@ async def get_meeting_participants( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1273,7 +1401,7 @@ async def refresh_participant_token( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, meeting_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1300,6 +1428,8 @@ async def refresh_participant_token( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1309,7 +1439,13 @@ async def refresh_participant_token( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}/token", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/participants/{participant_id}/token", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + participant_id=participant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1320,7 +1456,7 @@ async def replace_meeting_by_id( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, ai_config: meeting_replace_meeting_by_id_params.AIConfig | Omit = omit, live_stream_on_start: Optional[bool] | Omit = omit, @@ -1376,6 +1512,8 @@ async def replace_meeting_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1383,7 +1521,12 @@ async def replace_meeting_by_id( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._put( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=await async_maybe_transform( { "ai_config": ai_config, @@ -1407,7 +1550,7 @@ async def update_meeting_by_id( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, ai_config: meeting_update_meeting_by_id_params.AIConfig | Omit = omit, live_stream_on_start: bool | Omit = omit, @@ -1462,6 +1605,8 @@ async def update_meeting_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1469,7 +1614,12 @@ async def update_meeting_by_id( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._patch( - f"/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), body=await async_maybe_transform( { "ai_config": ai_config, diff --git a/src/cloudflare/resources/realtime_kit/presets.py b/src/cloudflare/resources/realtime_kit/presets.py index 53937c2e4e9..8a9e4faa2c9 100644 --- a/src/cloudflare/resources/realtime_kit/presets.py +++ b/src/cloudflare/resources/realtime_kit/presets.py @@ -5,7 +5,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def create( self, app_id: str, *, - account_id: str, + account_id: str | None = None, config: preset_create_params.Config, name: str, ui: preset_create_params.UI, @@ -79,12 +79,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets", + path_template("/accounts/{account_id}/realtime/kit/{app_id}/presets", account_id=account_id, app_id=app_id), body=maybe_transform( { "config": config, @@ -104,7 +106,7 @@ def update( self, preset_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, config: preset_update_params.Config | Omit = omit, name: str | Omit = omit, @@ -135,6 +137,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -142,7 +146,12 @@ def update( if not preset_id: raise ValueError(f"Expected a non-empty value for `preset_id` but received {preset_id!r}") return self._patch( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + account_id=account_id, + app_id=app_id, + preset_id=preset_id, + ), body=maybe_transform( { "config": config, @@ -162,7 +171,7 @@ def delete( self, preset_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -187,6 +196,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -194,7 +205,12 @@ def delete( if not preset_id: raise ValueError(f"Expected a non-empty value for `preset_id` but received {preset_id!r}") return self._delete( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + account_id=account_id, + app_id=app_id, + preset_id=preset_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -205,7 +221,7 @@ def get( self, app_id: str, *, - account_id: str, + account_id: str | None = None, page_no: 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. @@ -235,12 +251,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets", + path_template("/accounts/{account_id}/realtime/kit/{app_id}/presets", account_id=account_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -261,7 +279,7 @@ def get_preset_by_id( self, preset_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -286,6 +304,8 @@ def get_preset_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -293,7 +313,12 @@ def get_preset_by_id( if not preset_id: raise ValueError(f"Expected a non-empty value for `preset_id` but received {preset_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + account_id=account_id, + app_id=app_id, + preset_id=preset_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -325,7 +350,7 @@ async def create( self, app_id: str, *, - account_id: str, + account_id: str | None = None, config: preset_create_params.Config, name: str, ui: preset_create_params.UI, @@ -355,12 +380,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets", + path_template("/accounts/{account_id}/realtime/kit/{app_id}/presets", account_id=account_id, app_id=app_id), body=await async_maybe_transform( { "config": config, @@ -380,7 +407,7 @@ async def update( self, preset_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, config: preset_update_params.Config | Omit = omit, name: str | Omit = omit, @@ -411,6 +438,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -418,7 +447,12 @@ async def update( if not preset_id: raise ValueError(f"Expected a non-empty value for `preset_id` but received {preset_id!r}") return await self._patch( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + account_id=account_id, + app_id=app_id, + preset_id=preset_id, + ), body=await async_maybe_transform( { "config": config, @@ -438,7 +472,7 @@ async def delete( self, preset_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -463,6 +497,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -470,7 +506,12 @@ async def delete( if not preset_id: raise ValueError(f"Expected a non-empty value for `preset_id` but received {preset_id!r}") return await self._delete( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + account_id=account_id, + app_id=app_id, + preset_id=preset_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -481,7 +522,7 @@ async def get( self, app_id: str, *, - account_id: str, + account_id: str | None = None, page_no: 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. @@ -511,12 +552,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets", + path_template("/accounts/{account_id}/realtime/kit/{app_id}/presets", account_id=account_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -537,7 +580,7 @@ async def get_preset_by_id( self, preset_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -562,6 +605,8 @@ async def get_preset_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -569,7 +614,12 @@ async def get_preset_by_id( if not preset_id: raise ValueError(f"Expected a non-empty value for `preset_id` but received {preset_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/presets/{preset_id}", + account_id=account_id, + app_id=app_id, + preset_id=preset_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/realtime_kit/recordings.py b/src/cloudflare/resources/realtime_kit/recordings.py index cb8f877b439..1d3ffc6aa6b 100644 --- a/src/cloudflare/resources/realtime_kit/recordings.py +++ b/src/cloudflare/resources/realtime_kit/recordings.py @@ -9,7 +9,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -60,7 +60,7 @@ def get_active_recordings( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -85,6 +85,8 @@ def get_active_recordings( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -92,7 +94,12 @@ def get_active_recordings( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings/active-recording/{meeting_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings/active-recording/{meeting_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -103,7 +110,7 @@ def get_one_recording( self, recording_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -128,6 +135,8 @@ def get_one_recording( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -135,7 +144,12 @@ def get_one_recording( if not recording_id: raise ValueError(f"Expected a non-empty value for `recording_id` but received {recording_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings/{recording_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings/{recording_id}", + account_id=account_id, + app_id=app_id, + recording_id=recording_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -146,7 +160,7 @@ def get_recordings( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_time: Union[str, datetime] | Omit = omit, expired: bool | Omit = omit, meeting_id: str | Omit = omit, @@ -200,12 +214,16 @@ def get_recordings( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -234,7 +252,7 @@ def pause_resume_stop_recording( self, recording_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, action: Literal["stop", "pause", "resume"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -258,6 +276,8 @@ def pause_resume_stop_recording( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -265,7 +285,12 @@ def pause_resume_stop_recording( if not recording_id: raise ValueError(f"Expected a non-empty value for `recording_id` but received {recording_id!r}") return self._put( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings/{recording_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings/{recording_id}", + account_id=account_id, + app_id=app_id, + recording_id=recording_id, + ), body=maybe_transform( {"action": action}, recording_pause_resume_stop_recording_params.RecordingPauseResumeStopRecordingParams ), @@ -279,7 +304,7 @@ def start_recordings( self, app_id: str, *, - account_id: str, + account_id: str | None = None, allow_multiple_recordings: bool | Omit = omit, audio_config: recording_start_recordings_params.AudioConfig | Omit = omit, file_name_prefix: str | Omit = omit, @@ -340,12 +365,16 @@ def start_recordings( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings", account_id=account_id, app_id=app_id + ), body=maybe_transform( { "allow_multiple_recordings": allow_multiple_recordings, @@ -372,7 +401,7 @@ def start_track_recording( self, app_id: str, *, - account_id: str, + account_id: str | None = None, layers: Dict[str, recording_start_track_recording_params.Layers], meeting_id: str, max_seconds: float | Omit = omit, @@ -407,13 +436,17 @@ def start_track_recording( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings/track", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings/track", account_id=account_id, app_id=app_id + ), body=maybe_transform( { "layers": layers, @@ -453,7 +486,7 @@ async def get_active_recordings( self, meeting_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -478,6 +511,8 @@ async def get_active_recordings( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -485,7 +520,12 @@ async def get_active_recordings( if not meeting_id: raise ValueError(f"Expected a non-empty value for `meeting_id` but received {meeting_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings/active-recording/{meeting_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings/active-recording/{meeting_id}", + account_id=account_id, + app_id=app_id, + meeting_id=meeting_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -496,7 +536,7 @@ async def get_one_recording( self, recording_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -521,6 +561,8 @@ async def get_one_recording( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -528,7 +570,12 @@ async def get_one_recording( if not recording_id: raise ValueError(f"Expected a non-empty value for `recording_id` but received {recording_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings/{recording_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings/{recording_id}", + account_id=account_id, + app_id=app_id, + recording_id=recording_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -539,7 +586,7 @@ async def get_recordings( self, app_id: str, *, - account_id: str, + account_id: str | None = None, end_time: Union[str, datetime] | Omit = omit, expired: bool | Omit = omit, meeting_id: str | Omit = omit, @@ -593,12 +640,16 @@ async def get_recordings( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -627,7 +678,7 @@ async def pause_resume_stop_recording( self, recording_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, action: Literal["stop", "pause", "resume"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -651,6 +702,8 @@ async def pause_resume_stop_recording( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -658,7 +711,12 @@ async def pause_resume_stop_recording( if not recording_id: raise ValueError(f"Expected a non-empty value for `recording_id` but received {recording_id!r}") return await self._put( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings/{recording_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings/{recording_id}", + account_id=account_id, + app_id=app_id, + recording_id=recording_id, + ), body=await async_maybe_transform( {"action": action}, recording_pause_resume_stop_recording_params.RecordingPauseResumeStopRecordingParams ), @@ -672,7 +730,7 @@ async def start_recordings( self, app_id: str, *, - account_id: str, + account_id: str | None = None, allow_multiple_recordings: bool | Omit = omit, audio_config: recording_start_recordings_params.AudioConfig | Omit = omit, file_name_prefix: str | Omit = omit, @@ -733,12 +791,16 @@ async def start_recordings( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings", account_id=account_id, app_id=app_id + ), body=await async_maybe_transform( { "allow_multiple_recordings": allow_multiple_recordings, @@ -765,7 +827,7 @@ async def start_track_recording( self, app_id: str, *, - account_id: str, + account_id: str | None = None, layers: Dict[str, recording_start_track_recording_params.Layers], meeting_id: str, max_seconds: float | Omit = omit, @@ -800,13 +862,17 @@ async def start_track_recording( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/recordings/track", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/recordings/track", account_id=account_id, app_id=app_id + ), body=await async_maybe_transform( { "layers": layers, diff --git a/src/cloudflare/resources/realtime_kit/sessions.py b/src/cloudflare/resources/realtime_kit/sessions.py index 7f5aa6da4f7..d4bd6f90710 100644 --- a/src/cloudflare/resources/realtime_kit/sessions.py +++ b/src/cloudflare/resources/realtime_kit/sessions.py @@ -9,7 +9,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -66,7 +66,7 @@ def generate_summary_of_transcripts( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -91,6 +91,8 @@ def generate_summary_of_transcripts( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -99,7 +101,12 @@ def generate_summary_of_transcripts( raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/summary", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/summary", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -110,7 +117,7 @@ def get_participant_data_from_peer_id( self, peer_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, filters: Literal["device_info", "ip_information", "precall_network_information", "events", "quality_stats"] | Omit = omit, @@ -141,6 +148,8 @@ def get_participant_data_from_peer_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -148,7 +157,12 @@ def get_participant_data_from_peer_id( if not peer_id: raise ValueError(f"Expected a non-empty value for `peer_id` but received {peer_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/peer-report/{peer_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/peer-report/{peer_id}", + account_id=account_id, + app_id=app_id, + peer_id=peer_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -166,7 +180,7 @@ def get_session_chat( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -191,6 +205,8 @@ def get_session_chat( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -198,7 +214,12 @@ def get_session_chat( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/chat", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/chat", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -209,7 +230,7 @@ def get_session_details( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, include_breakout_rooms: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -237,6 +258,8 @@ def get_session_details( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -244,7 +267,12 @@ def get_session_details( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -262,7 +290,7 @@ def get_session_participant_details( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, session_id: str, filters: Literal["device_info", "ip_information", "precall_network_information", "events", "quality_stats"] @@ -297,6 +325,8 @@ def get_session_participant_details( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -306,7 +336,13 @@ def get_session_participant_details( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/participants/{participant_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/participants/{participant_id}", + account_id=account_id, + app_id=app_id, + session_id=session_id, + participant_id=participant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -327,7 +363,7 @@ def get_session_participants( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, include_peer_events: bool | Omit = omit, page_no: float | Omit = omit, @@ -371,6 +407,8 @@ def get_session_participants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -378,7 +416,12 @@ def get_session_participants( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/participants", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/participants", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -404,7 +447,7 @@ def get_session_summary( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -430,6 +473,8 @@ def get_session_summary( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -437,7 +482,12 @@ def get_session_summary( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/summary", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/summary", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -448,7 +498,7 @@ def get_session_transcripts( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -473,6 +523,8 @@ def get_session_transcripts( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -480,7 +532,12 @@ def get_session_transcripts( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/transcript", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/transcript", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -491,7 +548,7 @@ def get_sessions( self, app_id: str, *, - account_id: str, + account_id: str | None = None, associated_id: str | Omit = omit, end_time: Union[str, datetime] | Omit = omit, page_no: float | Omit = omit, @@ -540,12 +597,16 @@ def get_sessions( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -595,7 +656,7 @@ async def generate_summary_of_transcripts( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -620,6 +681,8 @@ async def generate_summary_of_transcripts( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -628,7 +691,12 @@ async def generate_summary_of_transcripts( raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/summary", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/summary", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -639,7 +707,7 @@ async def get_participant_data_from_peer_id( self, peer_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, filters: Literal["device_info", "ip_information", "precall_network_information", "events", "quality_stats"] | Omit = omit, @@ -670,6 +738,8 @@ async def get_participant_data_from_peer_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -677,7 +747,12 @@ async def get_participant_data_from_peer_id( if not peer_id: raise ValueError(f"Expected a non-empty value for `peer_id` but received {peer_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/peer-report/{peer_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/peer-report/{peer_id}", + account_id=account_id, + app_id=app_id, + peer_id=peer_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -695,7 +770,7 @@ async def get_session_chat( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -720,6 +795,8 @@ async def get_session_chat( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -727,7 +804,12 @@ async def get_session_chat( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/chat", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/chat", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -738,7 +820,7 @@ async def get_session_details( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, include_breakout_rooms: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -766,6 +848,8 @@ async def get_session_details( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -773,7 +857,12 @@ async def get_session_details( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -791,7 +880,7 @@ async def get_session_participant_details( self, participant_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, session_id: str, filters: Literal["device_info", "ip_information", "precall_network_information", "events", "quality_stats"] @@ -826,6 +915,8 @@ async def get_session_participant_details( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -835,7 +926,13 @@ async def get_session_participant_details( if not participant_id: raise ValueError(f"Expected a non-empty value for `participant_id` but received {participant_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/participants/{participant_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/participants/{participant_id}", + account_id=account_id, + app_id=app_id, + session_id=session_id, + participant_id=participant_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -856,7 +953,7 @@ async def get_session_participants( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, include_peer_events: bool | Omit = omit, page_no: float | Omit = omit, @@ -900,6 +997,8 @@ async def get_session_participants( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -907,7 +1006,12 @@ async def get_session_participants( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/participants", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/participants", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -933,7 +1037,7 @@ async def get_session_summary( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -959,6 +1063,8 @@ async def get_session_summary( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -966,7 +1072,12 @@ async def get_session_summary( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/summary", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/summary", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -977,7 +1088,7 @@ async def get_session_transcripts( self, session_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -1002,6 +1113,8 @@ async def get_session_transcripts( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -1009,7 +1122,12 @@ async def get_session_transcripts( if not session_id: raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/transcript", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions/{session_id}/transcript", + account_id=account_id, + app_id=app_id, + session_id=session_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1020,7 +1138,7 @@ async def get_sessions( self, app_id: str, *, - account_id: str, + account_id: str | None = None, associated_id: str | Omit = omit, end_time: Union[str, datetime] | Omit = omit, page_no: float | Omit = omit, @@ -1069,12 +1187,16 @@ async def get_sessions( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/sessions", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/sessions", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/realtime_kit/webhooks.py b/src/cloudflare/resources/realtime_kit/webhooks.py index c085c1e97b1..fb95970b161 100644 --- a/src/cloudflare/resources/realtime_kit/webhooks.py +++ b/src/cloudflare/resources/realtime_kit/webhooks.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -57,7 +57,7 @@ def create_webhook( self, app_id: str, *, - account_id: str, + account_id: str | None = None, events: List[ Literal[ "meeting.started", @@ -105,12 +105,16 @@ def create_webhook( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks", account_id=account_id, app_id=app_id + ), body=maybe_transform( { "events": events, @@ -130,7 +134,7 @@ def delete_webhook( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -155,6 +159,8 @@ def delete_webhook( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -162,7 +168,12 @@ def delete_webhook( if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return self._delete( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + account_id=account_id, + app_id=app_id, + webhook_id=webhook_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -173,7 +184,7 @@ def edit_webhook( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, enabled: bool | Omit = omit, events: List[ @@ -221,6 +232,8 @@ def edit_webhook( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -228,7 +241,12 @@ def edit_webhook( if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return self._patch( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + account_id=account_id, + app_id=app_id, + webhook_id=webhook_id, + ), body=maybe_transform( { "enabled": enabled, @@ -248,7 +266,7 @@ def get_webhook_by_id( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -273,6 +291,8 @@ def get_webhook_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -280,7 +300,12 @@ def get_webhook_by_id( if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + account_id=account_id, + app_id=app_id, + webhook_id=webhook_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -291,7 +316,7 @@ def get_webhooks( self, app_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -315,12 +340,16 @@ def get_webhooks( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -331,7 +360,7 @@ def replace_webhook( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, events: List[ Literal[ @@ -380,6 +409,8 @@ def replace_webhook( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -387,7 +418,12 @@ def replace_webhook( if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return self._put( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + account_id=account_id, + app_id=app_id, + webhook_id=webhook_id, + ), body=maybe_transform( { "events": events, @@ -428,7 +464,7 @@ async def create_webhook( self, app_id: str, *, - account_id: str, + account_id: str | None = None, events: List[ Literal[ "meeting.started", @@ -476,12 +512,16 @@ async def create_webhook( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._post( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks", account_id=account_id, app_id=app_id + ), body=await async_maybe_transform( { "events": events, @@ -501,7 +541,7 @@ async def delete_webhook( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -526,6 +566,8 @@ async def delete_webhook( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -533,7 +575,12 @@ async def delete_webhook( if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return await self._delete( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + account_id=account_id, + app_id=app_id, + webhook_id=webhook_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -544,7 +591,7 @@ async def edit_webhook( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, enabled: bool | Omit = omit, events: List[ @@ -592,6 +639,8 @@ async def edit_webhook( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -599,7 +648,12 @@ async def edit_webhook( if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return await self._patch( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + account_id=account_id, + app_id=app_id, + webhook_id=webhook_id, + ), body=await async_maybe_transform( { "enabled": enabled, @@ -619,7 +673,7 @@ async def get_webhook_by_id( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, app_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. @@ -644,6 +698,8 @@ async def get_webhook_by_id( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -651,7 +707,12 @@ async def get_webhook_by_id( if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + account_id=account_id, + app_id=app_id, + webhook_id=webhook_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -662,7 +723,7 @@ async def get_webhooks( self, app_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -686,12 +747,16 @@ async def get_webhooks( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._get( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks", account_id=account_id, app_id=app_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -702,7 +767,7 @@ async def replace_webhook( self, webhook_id: str, *, - account_id: str, + account_id: str | None = None, app_id: str, events: List[ Literal[ @@ -751,6 +816,8 @@ async def replace_webhook( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not app_id: @@ -758,7 +825,12 @@ async def replace_webhook( if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") return await self._put( - f"/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + path_template( + "/accounts/{account_id}/realtime/kit/{app_id}/webhooks/{webhook_id}", + account_id=account_id, + app_id=app_id, + webhook_id=webhook_id, + ), body=await async_maybe_transform( { "events": events, diff --git a/src/cloudflare/resources/registrar/api.md b/src/cloudflare/resources/registrar/api.md new file mode 100644 index 00000000000..3f77ba8afed --- /dev/null +++ b/src/cloudflare/resources/registrar/api.md @@ -0,0 +1,52 @@ +# Registrar + +Types: + +```python +from cloudflare.types.registrar import ( + Registration, + WorkflowStatus, + RegistrarCheckResponse, + RegistrarSearchResponse, +) +``` + +Methods: + +- client.registrar.check(\*, account_id, \*\*params) -> RegistrarCheckResponse +- client.registrar.search(\*, account_id, \*\*params) -> RegistrarSearchResponse + +## Domains + +Types: + +```python +from cloudflare.types.registrar import Domain +``` + +Methods: + +- 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 + +## Registrations + +Methods: + +- client.registrar.registrations.create(\*, account_id, \*\*params) -> WorkflowStatus +- client.registrar.registrations.list(\*, account_id, \*\*params) -> SyncCursorPagination[Registration] +- client.registrar.registrations.edit(domain_name, \*, account_id, \*\*params) -> WorkflowStatus +- client.registrar.registrations.get(domain_name, \*, account_id) -> Registration + +## RegistrationStatus + +Methods: + +- client.registrar.registration_status.get(domain_name, \*, account_id) -> WorkflowStatus + +## UpdateStatus + +Methods: + +- client.registrar.update_status.get(domain_name, \*, account_id) -> WorkflowStatus diff --git a/src/cloudflare/resources/registrar/domains.py b/src/cloudflare/resources/registrar/domains.py index a2c17f77951..ce5c9324207 100644 --- a/src/cloudflare/resources/registrar/domains.py +++ b/src/cloudflare/resources/registrar/domains.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -53,7 +53,7 @@ def update( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, auto_renew: bool | Omit = omit, locked: bool | Omit = omit, privacy: bool | Omit = omit, @@ -90,12 +90,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return self._put( - f"/accounts/{account_id}/registrar/domains/{domain_name}", + path_template( + "/accounts/{account_id}/registrar/domains/{domain_name}", account_id=account_id, domain_name=domain_name + ), body=maybe_transform( { "auto_renew": auto_renew, @@ -120,7 +124,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -142,10 +146,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/registrar/domains", + path_template("/accounts/{account_id}/registrar/domains", account_id=account_id), page=SyncSinglePage[Domain], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -160,7 +166,7 @@ def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -187,12 +193,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return self._get( - f"/accounts/{account_id}/registrar/domains/{domain_name}", + path_template( + "/accounts/{account_id}/registrar/domains/{domain_name}", account_id=account_id, domain_name=domain_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -231,7 +241,7 @@ async def update( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, auto_renew: bool | Omit = omit, locked: bool | Omit = omit, privacy: bool | Omit = omit, @@ -268,12 +278,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return await self._put( - f"/accounts/{account_id}/registrar/domains/{domain_name}", + path_template( + "/accounts/{account_id}/registrar/domains/{domain_name}", account_id=account_id, domain_name=domain_name + ), body=await async_maybe_transform( { "auto_renew": auto_renew, @@ -298,7 +312,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -320,10 +334,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/registrar/domains", + path_template("/accounts/{account_id}/registrar/domains", account_id=account_id), page=AsyncSinglePage[Domain], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -338,7 +354,7 @@ async def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -365,12 +381,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return await self._get( - f"/accounts/{account_id}/registrar/domains/{domain_name}", + path_template( + "/accounts/{account_id}/registrar/domains/{domain_name}", account_id=account_id, domain_name=domain_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/registrar/registrar.py b/src/cloudflare/resources/registrar/registrar.py index 23e73fac298..4fd37350fa0 100644 --- a/src/cloudflare/resources/registrar/registrar.py +++ b/src/cloudflare/resources/registrar/registrar.py @@ -15,7 +15,7 @@ AsyncDomainsResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -96,7 +96,7 @@ def with_streaming_response(self) -> RegistrarResourceWithStreamingResponse: def check( self, *, - account_id: str, + account_id: str | None = None, domains: 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. @@ -175,10 +175,12 @@ def check( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/registrar/domain-check", + path_template("/accounts/{account_id}/registrar/domain-check", account_id=account_id), body=maybe_transform({"domains": domains}, registrar_check_params.RegistrarCheckParams), options=make_request_options( extra_headers=extra_headers, @@ -193,7 +195,7 @@ def check( def search( self, *, - account_id: str, + account_id: str | None = None, q: str, extensions: SequenceNotStr[str] | Omit = omit, limit: int | Omit = omit, @@ -215,8 +217,7 @@ def search( Suggestions are scoped to extensions supported for programmatic registration via this API (`POST /registrations`). Domains on unsupported extensions will not - appear in results, even if they are available at the registry level. See the - supported extensions list in `info.description`. + appear in results, even if they are available at the registry level. ### Use cases @@ -262,10 +263,12 @@ def search( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/registrar/domain-search", + path_template("/accounts/{account_id}/registrar/domain-search", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -324,7 +327,7 @@ def with_streaming_response(self) -> AsyncRegistrarResourceWithStreamingResponse async def check( self, *, - account_id: str, + account_id: str | None = None, domains: 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. @@ -403,10 +406,12 @@ async def check( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/registrar/domain-check", + path_template("/accounts/{account_id}/registrar/domain-check", account_id=account_id), body=await async_maybe_transform({"domains": domains}, registrar_check_params.RegistrarCheckParams), options=make_request_options( extra_headers=extra_headers, @@ -421,7 +426,7 @@ async def check( async def search( self, *, - account_id: str, + account_id: str | None = None, q: str, extensions: SequenceNotStr[str] | Omit = omit, limit: int | Omit = omit, @@ -443,8 +448,7 @@ async def search( Suggestions are scoped to extensions supported for programmatic registration via this API (`POST /registrations`). Domains on unsupported extensions will not - appear in results, even if they are available at the registry level. See the - supported extensions list in `info.description`. + appear in results, even if they are available at the registry level. ### Use cases @@ -490,10 +494,12 @@ async def search( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/registrar/domain-search", + path_template("/accounts/{account_id}/registrar/domain-search", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/registrar/registration_status.py b/src/cloudflare/resources/registrar/registration_status.py index dc001c2f59a..d386ee60acb 100644 --- a/src/cloudflare/resources/registrar/registration_status.py +++ b/src/cloudflare/resources/registrar/registration_status.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +47,7 @@ def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -113,12 +114,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return self._get( - f"/accounts/{account_id}/registrar/registrations/{domain_name}/registration-status", + path_template( + "/accounts/{account_id}/registrar/registrations/{domain_name}/registration-status", + account_id=account_id, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -154,7 +161,7 @@ async def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -221,12 +228,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return await self._get( - f"/accounts/{account_id}/registrar/registrations/{domain_name}/registration-status", + path_template( + "/accounts/{account_id}/registrar/registrations/{domain_name}/registration-status", + account_id=account_id, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/registrar/registrations.py b/src/cloudflare/resources/registrar/registrations.py index e22fa1ce3e2..48b0db22b7e 100644 --- a/src/cloudflare/resources/registrar/registrations.py +++ b/src/cloudflare/resources/registrar/registrations.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -18,8 +18,9 @@ async_to_streamed_response_wrapper, ) from ..._wrappers import ResultWrapper -from ..._base_client import make_request_options -from ...types.registrar import registration_edit_params, registration_create_params +from ...pagination import SyncCursorPagination, AsyncCursorPagination +from ..._base_client import AsyncPaginator, make_request_options +from ...types.registrar import registration_edit_params, registration_list_params, registration_create_params from ...types.registrar.registration import Registration from ...types.registrar.workflow_status import WorkflowStatus @@ -49,7 +50,7 @@ def with_streaming_response(self) -> RegistrationsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, domain_name: str, auto_renew: bool | Omit = omit, contacts: registration_create_params.Contacts | Omit = omit, @@ -78,10 +79,27 @@ def create( - The account must not already be at the maximum supported domain limit. A single account may own up to 100 domains in total across registrations created through either the dashboard or this API. - - The domain must be on a supported extension listed in `info.description`. + - The domain must be on a supported extension for programmatic registration. - Use `POST /domain-check` immediately before calling this endpoint to confirm real-time availability and pricing. + ### Supported extensions + + In this API, "extension" means the full registrable suffix after the domain + label. For example, in `example.co.uk`, the extension is `co.uk`. + + Programmatic registration is currently supported for: + + `com`, `org`, `net`, `app`, `dev`, `cc`, `xyz`, `info`, `cloud`, `studio`, + `live`, `link`, `pro`, `tech`, `fyi`, `shop`, `online`, `tools`, `run`, `games`, + `build`, `systems`, `world`, `news`, `site`, `network`, `chat`, `space`, + `family`, `page`, `life`, `group`, `email`, `solutions`, `day`, `blog`, `ing`, + `icu`, `academy`, `today` + + Cloudflare Registrar supports 400+ extensions in the dashboard. Extensions not + listed above can still be registered at + `https://dash.cloudflare.com/{account_id}/domains/registrations`. + ### Express mode The only required field is `domain_name`. If `contacts` is omitted, the system @@ -168,11 +186,13 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"Prefer": prefer}), **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/registrar/registrations", + path_template("/accounts/{account_id}/registrar/registrations", account_id=account_id), body=maybe_transform( { "domain_name": domain_name, @@ -193,11 +213,81 @@ def create( cast_to=cast(Type[WorkflowStatus], ResultWrapper[WorkflowStatus]), ) + def list( + self, + *, + account_id: str | None = None, + cursor: str | Omit = omit, + direction: Literal["asc", "desc"] | Omit = omit, + per_page: int | Omit = omit, + sort_by: Literal["registry_created_at", "registry_expires_at", "name"] | 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, + ) -> SyncCursorPagination[Registration]: + """ + Returns a paginated list of domain registrations owned by the account. + + This endpoint uses cursor-based pagination. Results are ordered by registration + date by default. To fetch the next page, pass the `cursor` value from the + `result_info` object in the response as the `cursor` query parameter in your + next request. An empty `cursor` string indicates there are no more pages. + + Args: + account_id: Identifier + + cursor: Opaque token from a previous response's `result_info.cursor`. Pass this value to + fetch the next page of results. Omit (or pass an empty string) for the first + page. + + direction: Sort direction for results. Defaults to ascending order. + + per_page: Number of items to return per page. + + sort_by: Column to sort results by. Defaults to registration date (`registry_created_at`) + when omitted. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + 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( + path_template("/accounts/{account_id}/registrar/registrations", account_id=account_id), + page=SyncCursorPagination[Registration], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "direction": direction, + "per_page": per_page, + "sort_by": sort_by, + }, + registration_list_params.RegistrationListParams, + ), + ), + model=Registration, + ) + def edit( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, auto_renew: bool | Omit = omit, prefer: Literal["respond-async"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -242,6 +332,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: @@ -251,7 +343,11 @@ def edit( **(extra_headers or {}), } return self._patch( - f"/accounts/{account_id}/registrar/registrations/{domain_name}", + path_template( + "/accounts/{account_id}/registrar/registrations/{domain_name}", + account_id=account_id, + domain_name=domain_name, + ), body=maybe_transform({"auto_renew": auto_renew}, registration_edit_params.RegistrationEditParams), options=make_request_options( extra_headers=extra_headers, @@ -267,7 +363,7 @@ def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -299,12 +395,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return self._get( - f"/accounts/{account_id}/registrar/registrations/{domain_name}", + path_template( + "/accounts/{account_id}/registrar/registrations/{domain_name}", + account_id=account_id, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -339,7 +441,7 @@ def with_streaming_response(self) -> AsyncRegistrationsResourceWithStreamingResp async def create( self, *, - account_id: str, + account_id: str | None = None, domain_name: str, auto_renew: bool | Omit = omit, contacts: registration_create_params.Contacts | Omit = omit, @@ -368,10 +470,27 @@ async def create( - The account must not already be at the maximum supported domain limit. A single account may own up to 100 domains in total across registrations created through either the dashboard or this API. - - The domain must be on a supported extension listed in `info.description`. + - The domain must be on a supported extension for programmatic registration. - Use `POST /domain-check` immediately before calling this endpoint to confirm real-time availability and pricing. + ### Supported extensions + + In this API, "extension" means the full registrable suffix after the domain + label. For example, in `example.co.uk`, the extension is `co.uk`. + + Programmatic registration is currently supported for: + + `com`, `org`, `net`, `app`, `dev`, `cc`, `xyz`, `info`, `cloud`, `studio`, + `live`, `link`, `pro`, `tech`, `fyi`, `shop`, `online`, `tools`, `run`, `games`, + `build`, `systems`, `world`, `news`, `site`, `network`, `chat`, `space`, + `family`, `page`, `life`, `group`, `email`, `solutions`, `day`, `blog`, `ing`, + `icu`, `academy`, `today` + + Cloudflare Registrar supports 400+ extensions in the dashboard. Extensions not + listed above can still be registered at + `https://dash.cloudflare.com/{account_id}/domains/registrations`. + ### Express mode The only required field is `domain_name`. If `contacts` is omitted, the system @@ -458,11 +577,13 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"Prefer": prefer}), **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/registrar/registrations", + path_template("/accounts/{account_id}/registrar/registrations", account_id=account_id), body=await async_maybe_transform( { "domain_name": domain_name, @@ -483,11 +604,81 @@ async def create( cast_to=cast(Type[WorkflowStatus], ResultWrapper[WorkflowStatus]), ) + def list( + self, + *, + account_id: str | None = None, + cursor: str | Omit = omit, + direction: Literal["asc", "desc"] | Omit = omit, + per_page: int | Omit = omit, + sort_by: Literal["registry_created_at", "registry_expires_at", "name"] | 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[Registration, AsyncCursorPagination[Registration]]: + """ + Returns a paginated list of domain registrations owned by the account. + + This endpoint uses cursor-based pagination. Results are ordered by registration + date by default. To fetch the next page, pass the `cursor` value from the + `result_info` object in the response as the `cursor` query parameter in your + next request. An empty `cursor` string indicates there are no more pages. + + Args: + account_id: Identifier + + cursor: Opaque token from a previous response's `result_info.cursor`. Pass this value to + fetch the next page of results. Omit (or pass an empty string) for the first + page. + + direction: Sort direction for results. Defaults to ascending order. + + per_page: Number of items to return per page. + + sort_by: Column to sort results by. Defaults to registration date (`registry_created_at`) + when omitted. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + 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( + path_template("/accounts/{account_id}/registrar/registrations", account_id=account_id), + page=AsyncCursorPagination[Registration], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "direction": direction, + "per_page": per_page, + "sort_by": sort_by, + }, + registration_list_params.RegistrationListParams, + ), + ), + model=Registration, + ) + async def edit( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, auto_renew: bool | Omit = omit, prefer: Literal["respond-async"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -532,6 +723,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: @@ -541,7 +734,11 @@ async def edit( **(extra_headers or {}), } return await self._patch( - f"/accounts/{account_id}/registrar/registrations/{domain_name}", + path_template( + "/accounts/{account_id}/registrar/registrations/{domain_name}", + account_id=account_id, + domain_name=domain_name, + ), body=await async_maybe_transform( {"auto_renew": auto_renew}, registration_edit_params.RegistrationEditParams ), @@ -559,7 +756,7 @@ async def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -591,12 +788,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return await self._get( - f"/accounts/{account_id}/registrar/registrations/{domain_name}", + path_template( + "/accounts/{account_id}/registrar/registrations/{domain_name}", + account_id=account_id, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -615,6 +818,9 @@ def __init__(self, registrations: RegistrationsResource) -> None: self.create = to_raw_response_wrapper( registrations.create, ) + self.list = to_raw_response_wrapper( + registrations.list, + ) self.edit = to_raw_response_wrapper( registrations.edit, ) @@ -630,6 +836,9 @@ def __init__(self, registrations: AsyncRegistrationsResource) -> None: self.create = async_to_raw_response_wrapper( registrations.create, ) + self.list = async_to_raw_response_wrapper( + registrations.list, + ) self.edit = async_to_raw_response_wrapper( registrations.edit, ) @@ -645,6 +854,9 @@ def __init__(self, registrations: RegistrationsResource) -> None: self.create = to_streamed_response_wrapper( registrations.create, ) + self.list = to_streamed_response_wrapper( + registrations.list, + ) self.edit = to_streamed_response_wrapper( registrations.edit, ) @@ -660,6 +872,9 @@ def __init__(self, registrations: AsyncRegistrationsResource) -> None: self.create = async_to_streamed_response_wrapper( registrations.create, ) + self.list = async_to_streamed_response_wrapper( + registrations.list, + ) self.edit = async_to_streamed_response_wrapper( registrations.edit, ) diff --git a/src/cloudflare/resources/registrar/update_status.py b/src/cloudflare/resources/registrar/update_status.py index 693737a8348..089c42b4f32 100644 --- a/src/cloudflare/resources/registrar/update_status.py +++ b/src/cloudflare/resources/registrar/update_status.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +47,7 @@ def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -83,12 +84,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return self._get( - f"/accounts/{account_id}/registrar/registrations/{domain_name}/update-status", + path_template( + "/accounts/{account_id}/registrar/registrations/{domain_name}/update-status", + account_id=account_id, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -124,7 +131,7 @@ async def get( self, domain_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -161,12 +168,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_name: raise ValueError(f"Expected a non-empty value for `domain_name` but received {domain_name!r}") return await self._get( - f"/accounts/{account_id}/registrar/registrations/{domain_name}/update-status", + path_template( + "/accounts/{account_id}/registrar/registrations/{domain_name}/update-status", + account_id=account_id, + domain_name=domain_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/request_tracers/api.md b/src/cloudflare/resources/request_tracers/api.md new file mode 100644 index 00000000000..d8ac2805708 --- /dev/null +++ b/src/cloudflare/resources/request_tracers/api.md @@ -0,0 +1,13 @@ +# RequestTracers + +## Traces + +Types: + +```python +from cloudflare.types.request_tracers import Trace, TraceItem, TraceCreateResponse +``` + +Methods: + +- client.request_tracers.traces.create(\*, account_id, \*\*params) -> Optional[TraceCreateResponse] diff --git a/src/cloudflare/resources/request_tracers/traces.py b/src/cloudflare/resources/request_tracers/traces.py index cd05eafcac4..1fc474f2e4b 100644 --- a/src/cloudflare/resources/request_tracers/traces.py +++ b/src/cloudflare/resources/request_tracers/traces.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> TracesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, method: str, url: str, body: trace_create_params.Body | Omit = omit, @@ -91,10 +91,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/request-tracer/trace", + path_template("/accounts/{account_id}/request-tracer/trace", account_id=account_id), body=maybe_transform( { "method": method, @@ -142,7 +144,7 @@ def with_streaming_response(self) -> AsyncTracesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, method: str, url: str, body: trace_create_params.Body | Omit = omit, @@ -186,10 +188,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/request-tracer/trace", + path_template("/accounts/{account_id}/request-tracer/trace", account_id=account_id), body=await async_maybe_transform( { "method": method, diff --git a/src/cloudflare/resources/resource_sharing/api.md b/src/cloudflare/resources/resource_sharing/api.md new file mode 100644 index 00000000000..ddc0310b9d7 --- /dev/null +++ b/src/cloudflare/resources/resource_sharing/api.md @@ -0,0 +1,63 @@ +# ResourceSharing + +Types: + +```python +from cloudflare.types.resource_sharing import ( + ResourceSharingCreateResponse, + ResourceSharingUpdateResponse, + ResourceSharingListResponse, + ResourceSharingDeleteResponse, + ResourceSharingGetResponse, +) +``` + +Methods: + +- 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] + +## Recipients + +Types: + +```python +from cloudflare.types.resource_sharing import ( + RecipientCreateResponse, + RecipientListResponse, + RecipientDeleteResponse, + RecipientGetResponse, +) +``` + +Methods: + +- 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] + +## Resources + +Types: + +```python +from cloudflare.types.resource_sharing import ( + ResourceCreateResponse, + ResourceUpdateResponse, + ResourceListResponse, + ResourceDeleteResponse, + ResourceGetResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/resource_sharing/recipients.py b/src/cloudflare/resources/resource_sharing/recipients.py index 828a348060a..fedefa77a39 100644 --- a/src/cloudflare/resources/resource_sharing/recipients.py +++ b/src/cloudflare/resources/resource_sharing/recipients.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def create( self, share_id: str, *, - path_account_id: str, + path_account_id: str | None = None, body_account_id: str | Omit = omit, organization_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -83,12 +83,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if path_account_id is None: + path_account_id = self._client._get_account_id_path_param() if not path_account_id: raise ValueError(f"Expected a non-empty value for `path_account_id` but received {path_account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return self._post( - f"/accounts/{path_account_id}/shares/{share_id}/recipients", + path_template( + "/accounts/{path_account_id}/shares/{share_id}/recipients", + path_account_id=path_account_id, + share_id=share_id, + ), body=maybe_transform( { "body_account_id": body_account_id, @@ -110,7 +116,7 @@ def list( self, share_id: str, *, - account_id: str, + account_id: str | None = None, include_resources: bool | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -143,12 +149,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return self._get_api_list( - f"/accounts/{account_id}/shares/{share_id}/recipients", + path_template( + "/accounts/{account_id}/shares/{share_id}/recipients", account_id=account_id, share_id=share_id + ), page=SyncV4PagePaginationArray[RecipientListResponse], options=make_request_options( extra_headers=extra_headers, @@ -171,7 +181,7 @@ def delete( self, recipient_id: str, *, - account_id: str, + account_id: str | None = None, share_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. @@ -199,6 +209,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -206,7 +218,12 @@ def delete( if not recipient_id: raise ValueError(f"Expected a non-empty value for `recipient_id` but received {recipient_id!r}") return self._delete( - f"/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + account_id=account_id, + share_id=share_id, + recipient_id=recipient_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -221,7 +238,7 @@ def get( self, recipient_id: str, *, - account_id: str, + account_id: str | None = None, share_id: str, include_resources: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -251,6 +268,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -258,7 +277,12 @@ def get( if not recipient_id: raise ValueError(f"Expected a non-empty value for `recipient_id` but received {recipient_id!r}") return self._get( - f"/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + account_id=account_id, + share_id=share_id, + recipient_id=recipient_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -297,7 +321,7 @@ async def create( self, share_id: str, *, - path_account_id: str, + path_account_id: str | None = None, body_account_id: str | Omit = omit, organization_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -328,12 +352,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if path_account_id is None: + path_account_id = self._client._get_account_id_path_param() if not path_account_id: raise ValueError(f"Expected a non-empty value for `path_account_id` but received {path_account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return await self._post( - f"/accounts/{path_account_id}/shares/{share_id}/recipients", + path_template( + "/accounts/{path_account_id}/shares/{share_id}/recipients", + path_account_id=path_account_id, + share_id=share_id, + ), body=await async_maybe_transform( { "body_account_id": body_account_id, @@ -355,7 +385,7 @@ def list( self, share_id: str, *, - account_id: str, + account_id: str | None = None, include_resources: bool | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -388,12 +418,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return self._get_api_list( - f"/accounts/{account_id}/shares/{share_id}/recipients", + path_template( + "/accounts/{account_id}/shares/{share_id}/recipients", account_id=account_id, share_id=share_id + ), page=AsyncV4PagePaginationArray[RecipientListResponse], options=make_request_options( extra_headers=extra_headers, @@ -416,7 +450,7 @@ async def delete( self, recipient_id: str, *, - account_id: str, + account_id: str | None = None, share_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. @@ -444,6 +478,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -451,7 +487,12 @@ async def delete( if not recipient_id: raise ValueError(f"Expected a non-empty value for `recipient_id` but received {recipient_id!r}") return await self._delete( - f"/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + account_id=account_id, + share_id=share_id, + recipient_id=recipient_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -466,7 +507,7 @@ async def get( self, recipient_id: str, *, - account_id: str, + account_id: str | None = None, share_id: str, include_resources: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -496,6 +537,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -503,7 +546,12 @@ async def get( if not recipient_id: raise ValueError(f"Expected a non-empty value for `recipient_id` but received {recipient_id!r}") return await self._get( - f"/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/recipients/{recipient_id}", + account_id=account_id, + share_id=share_id, + recipient_id=recipient_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/resource_sharing/resource_sharing.py b/src/cloudflare/resources/resource_sharing/resource_sharing.py index 9de8b13def7..18bdbf9f9b6 100644 --- a/src/cloudflare/resources/resource_sharing/resource_sharing.py +++ b/src/cloudflare/resources/resource_sharing/resource_sharing.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from .resources import ( ResourcesResource, @@ -82,7 +82,7 @@ def with_streaming_response(self) -> ResourceSharingResourceWithStreamingRespons def create( self, *, - account_id: str, + account_id: str | None = None, name: str, recipients: Iterable[resource_sharing_create_params.Recipient], resources: Iterable[resource_sharing_create_params.Resource], @@ -110,10 +110,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/shares", + path_template("/accounts/{account_id}/shares", account_id=account_id), body=maybe_transform( { "name": name, @@ -136,7 +138,7 @@ def update( self, share_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -164,12 +166,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return self._put( - f"/accounts/{account_id}/shares/{share_id}", + path_template("/accounts/{account_id}/shares/{share_id}", account_id=account_id, share_id=share_id), body=maybe_transform({"name": name}, resource_sharing_update_params.ResourceSharingUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -184,7 +188,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, include_recipient_counts: bool | Omit = omit, include_resources: bool | Omit = omit, @@ -245,10 +249,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/shares", + path_template("/accounts/{account_id}/shares", account_id=account_id), page=SyncV4PagePaginationArray[ResourceSharingListResponse], options=make_request_options( extra_headers=extra_headers, @@ -278,7 +284,7 @@ def delete( self, share_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -303,12 +309,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return self._delete( - f"/accounts/{account_id}/shares/{share_id}", + path_template("/accounts/{account_id}/shares/{share_id}", account_id=account_id, share_id=share_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -323,7 +331,7 @@ def get( self, share_id: str, *, - account_id: str, + account_id: str | None = None, include_recipient_counts: bool | Omit = omit, include_resources: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -353,12 +361,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return self._get( - f"/accounts/{account_id}/shares/{share_id}", + path_template("/accounts/{account_id}/shares/{share_id}", account_id=account_id, share_id=share_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -408,7 +418,7 @@ def with_streaming_response(self) -> AsyncResourceSharingResourceWithStreamingRe async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, recipients: Iterable[resource_sharing_create_params.Recipient], resources: Iterable[resource_sharing_create_params.Resource], @@ -436,10 +446,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/shares", + path_template("/accounts/{account_id}/shares", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -462,7 +474,7 @@ async def update( self, share_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -490,12 +502,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return await self._put( - f"/accounts/{account_id}/shares/{share_id}", + path_template("/accounts/{account_id}/shares/{share_id}", account_id=account_id, share_id=share_id), body=await async_maybe_transform( {"name": name}, resource_sharing_update_params.ResourceSharingUpdateParams ), @@ -512,7 +526,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, include_recipient_counts: bool | Omit = omit, include_resources: bool | Omit = omit, @@ -573,10 +587,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/shares", + path_template("/accounts/{account_id}/shares", account_id=account_id), page=AsyncV4PagePaginationArray[ResourceSharingListResponse], options=make_request_options( extra_headers=extra_headers, @@ -606,7 +622,7 @@ async def delete( self, share_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -631,12 +647,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return await self._delete( - f"/accounts/{account_id}/shares/{share_id}", + path_template("/accounts/{account_id}/shares/{share_id}", account_id=account_id, share_id=share_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -651,7 +669,7 @@ async def get( self, share_id: str, *, - account_id: str, + account_id: str | None = None, include_recipient_counts: bool | Omit = omit, include_resources: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -681,12 +699,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return await self._get( - f"/accounts/{account_id}/shares/{share_id}", + path_template("/accounts/{account_id}/shares/{share_id}", account_id=account_id, share_id=share_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/resource_sharing/resources.py b/src/cloudflare/resources/resource_sharing/resources.py index b8609ba1b6b..894b47d51bf 100644 --- a/src/cloudflare/resources/resource_sharing/resources.py +++ b/src/cloudflare/resources/resource_sharing/resources.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -54,7 +54,7 @@ def create( self, share_id: str, *, - account_id: str, + account_id: str | None = None, meta: object, resource_account_id: str, resource_id: str, @@ -96,12 +96,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return self._post( - f"/accounts/{account_id}/shares/{share_id}/resources", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources", account_id=account_id, share_id=share_id + ), body=maybe_transform( { "meta": meta, @@ -125,7 +129,7 @@ def update( self, resource_id: str, *, - account_id: str, + account_id: str | None = None, share_id: str, meta: object, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -156,6 +160,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -163,7 +169,12 @@ def update( if not resource_id: raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") return self._put( - f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + account_id=account_id, + share_id=share_id, + resource_id=resource_id, + ), body=maybe_transform({"meta": meta}, resource_update_params.ResourceUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -179,7 +190,7 @@ def list( self, share_id: str, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, resource_type: Literal[ @@ -222,12 +233,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return self._get_api_list( - f"/accounts/{account_id}/shares/{share_id}/resources", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources", account_id=account_id, share_id=share_id + ), page=SyncV4PagePaginationArray[ResourceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -251,7 +266,7 @@ def delete( self, resource_id: str, *, - account_id: str, + account_id: str | None = None, share_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. @@ -279,6 +294,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -286,7 +303,12 @@ def delete( if not resource_id: raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") return self._delete( - f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + account_id=account_id, + share_id=share_id, + resource_id=resource_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -301,7 +323,7 @@ def get( self, resource_id: str, *, - account_id: str, + account_id: str | None = None, share_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. @@ -328,6 +350,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -335,7 +359,12 @@ def get( if not resource_id: raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") return self._get( - f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + account_id=account_id, + share_id=share_id, + resource_id=resource_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -371,7 +400,7 @@ async def create( self, share_id: str, *, - account_id: str, + account_id: str | None = None, meta: object, resource_account_id: str, resource_id: str, @@ -413,12 +442,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return await self._post( - f"/accounts/{account_id}/shares/{share_id}/resources", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources", account_id=account_id, share_id=share_id + ), body=await async_maybe_transform( { "meta": meta, @@ -442,7 +475,7 @@ async def update( self, resource_id: str, *, - account_id: str, + account_id: str | None = None, share_id: str, meta: object, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -473,6 +506,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -480,7 +515,12 @@ async def update( if not resource_id: raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") return await self._put( - f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + account_id=account_id, + share_id=share_id, + resource_id=resource_id, + ), body=await async_maybe_transform({"meta": meta}, resource_update_params.ResourceUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -496,7 +536,7 @@ def list( self, share_id: str, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, resource_type: Literal[ @@ -539,12 +579,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: raise ValueError(f"Expected a non-empty value for `share_id` but received {share_id!r}") return self._get_api_list( - f"/accounts/{account_id}/shares/{share_id}/resources", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources", account_id=account_id, share_id=share_id + ), page=AsyncV4PagePaginationArray[ResourceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -568,7 +612,7 @@ async def delete( self, resource_id: str, *, - account_id: str, + account_id: str | None = None, share_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. @@ -596,6 +640,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -603,7 +649,12 @@ async def delete( if not resource_id: raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") return await self._delete( - f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + account_id=account_id, + share_id=share_id, + resource_id=resource_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -618,7 +669,7 @@ async def get( self, resource_id: str, *, - account_id: str, + account_id: str | None = None, share_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. @@ -645,6 +696,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not share_id: @@ -652,7 +705,12 @@ async def get( if not resource_id: raise ValueError(f"Expected a non-empty value for `resource_id` but received {resource_id!r}") return await self._get( - f"/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + path_template( + "/accounts/{account_id}/shares/{share_id}/resources/{resource_id}", + account_id=account_id, + share_id=share_id, + resource_id=resource_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/resource_tagging/account_tags.py b/src/cloudflare/resources/resource_tagging/account_tags.py index 64017813a3b..2038f1dfbc4 100644 --- a/src/cloudflare/resources/resource_tagging/account_tags.py +++ b/src/cloudflare/resources/resource_tagging/account_tags.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import required_args, maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import path_template, required_args, maybe_transform, strip_not_given, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> AccountTagsResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application", @@ -113,7 +113,7 @@ def update( def update( self, *, - account_id: str, + account_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application", @@ -168,13 +168,11 @@ def update( """ ... - @required_args( - ["account_id", "resource_id", "resource_type", "worker_id"], ["account_id", "resource_id", "resource_type"] - ) + @required_args(["resource_id", "resource_type", "worker_id"], ["resource_id", "resource_type"]) def update( self, *, - account_id: str, + account_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application", @@ -229,13 +227,15 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AccountTagUpdateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} return cast( Optional[AccountTagUpdateResponse], self._put( - f"/accounts/{account_id}/tags", + path_template("/accounts/{account_id}/tags", account_id=account_id), body=maybe_transform( { "resource_id": resource_id, @@ -261,7 +261,7 @@ def update( def delete( self, *, - account_id: str, + account_id: str | None = None, if_match: 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. @@ -284,12 +284,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 {})} extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/tags", + path_template("/accounts/{account_id}/tags", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -299,7 +301,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application", @@ -351,12 +353,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[AccountTagGetResponse], self._get( - f"/accounts/{account_id}/tags", + path_template("/accounts/{account_id}/tags", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -403,7 +407,7 @@ def with_streaming_response(self) -> AsyncAccountTagsResourceWithStreamingRespon async def update( self, *, - account_id: str, + account_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application", @@ -466,7 +470,7 @@ async def update( async def update( self, *, - account_id: str, + account_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application", @@ -521,13 +525,11 @@ async def update( """ ... - @required_args( - ["account_id", "resource_id", "resource_type", "worker_id"], ["account_id", "resource_id", "resource_type"] - ) + @required_args(["resource_id", "resource_type", "worker_id"], ["resource_id", "resource_type"]) async def update( self, *, - account_id: str, + account_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application", @@ -582,13 +584,15 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AccountTagUpdateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} return cast( Optional[AccountTagUpdateResponse], await self._put( - f"/accounts/{account_id}/tags", + path_template("/accounts/{account_id}/tags", account_id=account_id), body=await async_maybe_transform( { "resource_id": resource_id, @@ -614,7 +618,7 @@ async def update( async def delete( self, *, - account_id: str, + account_id: str | None = None, if_match: 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. @@ -637,12 +641,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 {})} extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/tags", + path_template("/accounts/{account_id}/tags", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -652,7 +658,7 @@ async def delete( async def get( self, *, - account_id: str, + account_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application", @@ -704,12 +710,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[AccountTagGetResponse], await self._get( - f"/accounts/{account_id}/tags", + path_template("/accounts/{account_id}/tags", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/resource_tagging/api.md b/src/cloudflare/resources/resource_tagging/api.md new file mode 100644 index 00000000000..7a02eb20ad4 --- /dev/null +++ b/src/cloudflare/resources/resource_tagging/api.md @@ -0,0 +1,63 @@ +# ResourceTagging + +Types: + +```python +from cloudflare.types.resource_tagging import ResourceTaggingListResponse +``` + +Methods: + +- client.resource_tagging.list(\*, account_id, \*\*params) -> SyncCursorPaginationAfter[ResourceTaggingListResponse] + +## AccountTags + +Types: + +```python +from cloudflare.types.resource_tagging import AccountTagUpdateResponse, AccountTagGetResponse +``` + +Methods: + +- client.resource_tagging.account_tags.update(\*, account_id, \*\*params) -> Optional[AccountTagUpdateResponse] +- client.resource_tagging.account_tags.delete(\*, account_id) -> None +- client.resource_tagging.account_tags.get(\*, account_id, \*\*params) -> Optional[AccountTagGetResponse] + +## ZoneTags + +Types: + +```python +from cloudflare.types.resource_tagging import ZoneTagUpdateResponse, ZoneTagGetResponse +``` + +Methods: + +- client.resource_tagging.zone_tags.update(\*, zone_id, \*\*params) -> Optional[ZoneTagUpdateResponse] +- client.resource_tagging.zone_tags.delete(\*, zone_id) -> None +- client.resource_tagging.zone_tags.get(\*, zone_id, \*\*params) -> Optional[ZoneTagGetResponse] + +## Keys + +Types: + +```python +from cloudflare.types.resource_tagging import KeyListResponse +``` + +Methods: + +- client.resource_tagging.keys.list(\*, account_id, \*\*params) -> SyncCursorPaginationAfter[KeyListResponse] + +## Values + +Types: + +```python +from cloudflare.types.resource_tagging import ValueListResponse +``` + +Methods: + +- client.resource_tagging.values.list(tag_key, \*, account_id, \*\*params) -> SyncCursorPaginationAfter[ValueListResponse] diff --git a/src/cloudflare/resources/resource_tagging/keys.py b/src/cloudflare/resources/resource_tagging/keys.py index 4a106e55917..9cb2f316cf7 100644 --- a/src/cloudflare/resources/resource_tagging/keys.py +++ b/src/cloudflare/resources/resource_tagging/keys.py @@ -5,7 +5,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +45,7 @@ def with_streaming_response(self) -> KeysResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, cursor: 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. @@ -70,10 +70,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/tags/keys", + path_template("/accounts/{account_id}/tags/keys", account_id=account_id), page=SyncCursorPaginationAfter[KeyListResponse], options=make_request_options( extra_headers=extra_headers, @@ -109,7 +111,7 @@ def with_streaming_response(self) -> AsyncKeysResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, cursor: 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. @@ -134,10 +136,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/tags/keys", + path_template("/accounts/{account_id}/tags/keys", account_id=account_id), page=AsyncCursorPaginationAfter[KeyListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/resource_tagging/resource_tagging.py b/src/cloudflare/resources/resource_tagging/resource_tagging.py index 56a27620fc6..7cbdfbf5683 100644 --- a/src/cloudflare/resources/resource_tagging/resource_tagging.py +++ b/src/cloudflare/resources/resource_tagging/resource_tagging.py @@ -24,7 +24,7 @@ AsyncValuesResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from .zone_tags import ( ZoneTagsResource, @@ -96,7 +96,7 @@ def with_streaming_response(self) -> ResourceTaggingResourceWithStreamingRespons def list( self, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, tag: SequenceNotStr[str] | Omit = omit, type: List[ @@ -175,10 +175,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/tags/resources", + path_template("/accounts/{account_id}/tags/resources", account_id=account_id), page=SyncCursorPaginationAfter[ResourceTaggingListResponse], options=make_request_options( extra_headers=extra_headers, @@ -239,7 +241,7 @@ def with_streaming_response(self) -> AsyncResourceTaggingResourceWithStreamingRe def list( self, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, tag: SequenceNotStr[str] | Omit = omit, type: List[ @@ -318,10 +320,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/tags/resources", + path_template("/accounts/{account_id}/tags/resources", account_id=account_id), page=AsyncCursorPaginationAfter[ResourceTaggingListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/resource_tagging/values.py b/src/cloudflare/resources/resource_tagging/values.py index b2b278b99f4..94b2e260534 100644 --- a/src/cloudflare/resources/resource_tagging/values.py +++ b/src/cloudflare/resources/resource_tagging/values.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def list( self, tag_key: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, type: Literal[ "access_application", @@ -106,12 +106,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tag_key: raise ValueError(f"Expected a non-empty value for `tag_key` but received {tag_key!r}") return self._get_api_list( - f"/accounts/{account_id}/tags/values/{tag_key}", + path_template("/accounts/{account_id}/tags/values/{tag_key}", account_id=account_id, tag_key=tag_key), page=SyncCursorPaginationAfter[ValueListResponse], options=make_request_options( extra_headers=extra_headers, @@ -154,7 +156,7 @@ def list( self, tag_key: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, type: Literal[ "access_application", @@ -212,12 +214,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tag_key: raise ValueError(f"Expected a non-empty value for `tag_key` but received {tag_key!r}") return self._get_api_list( - f"/accounts/{account_id}/tags/values/{tag_key}", + path_template("/accounts/{account_id}/tags/values/{tag_key}", account_id=account_id, tag_key=tag_key), page=AsyncCursorPaginationAfter[ValueListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/resource_tagging/zone_tags.py b/src/cloudflare/resources/resource_tagging/zone_tags.py index 8b5224337f1..1b02c0f38ea 100644 --- a/src/cloudflare/resources/resource_tagging/zone_tags.py +++ b/src/cloudflare/resources/resource_tagging/zone_tags.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ..._utils import required_args, maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import path_template, required_args, maybe_transform, strip_not_given, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> ZoneTagsResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, resource_id: str, resource_type: Literal[ "api_gateway_operation", @@ -97,7 +97,7 @@ def update( def update( self, *, - zone_id: str, + zone_id: str | None = None, access_application_id: str, resource_id: str, resource_type: Literal[ @@ -144,14 +144,11 @@ def update( """ ... - @required_args( - ["zone_id", "resource_id", "resource_type"], - ["zone_id", "access_application_id", "resource_id", "resource_type"], - ) + @required_args(["resource_id", "resource_type"], ["access_application_id", "resource_id", "resource_type"]) def update( self, *, - zone_id: str, + zone_id: str | None = None, resource_id: str, resource_type: Literal[ "api_gateway_operation", @@ -180,13 +177,15 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ZoneTagUpdateResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} return cast( Optional[ZoneTagUpdateResponse], self._put( - f"/zones/{zone_id}/tags", + path_template("/zones/{zone_id}/tags", zone_id=zone_id), body=maybe_transform( { "resource_id": resource_id, @@ -212,7 +211,7 @@ def update( def delete( self, *, - zone_id: str, + zone_id: str | None = None, if_match: 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. @@ -235,12 +234,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} return self._delete( - f"/zones/{zone_id}/tags", + path_template("/zones/{zone_id}/tags", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -250,7 +251,7 @@ def delete( def get( self, *, - zone_id: str, + zone_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application_policy", @@ -290,12 +291,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[ZoneTagGetResponse], self._get( - f"/zones/{zone_id}/tags", + path_template("/zones/{zone_id}/tags", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -342,7 +345,7 @@ def with_streaming_response(self) -> AsyncZoneTagsResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, resource_id: str, resource_type: Literal[ "api_gateway_operation", @@ -389,7 +392,7 @@ async def update( async def update( self, *, - zone_id: str, + zone_id: str | None = None, access_application_id: str, resource_id: str, resource_type: Literal[ @@ -436,14 +439,11 @@ async def update( """ ... - @required_args( - ["zone_id", "resource_id", "resource_type"], - ["zone_id", "access_application_id", "resource_id", "resource_type"], - ) + @required_args(["resource_id", "resource_type"], ["access_application_id", "resource_id", "resource_type"]) async def update( self, *, - zone_id: str, + zone_id: str | None = None, resource_id: str, resource_type: Literal[ "api_gateway_operation", @@ -472,13 +472,15 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ZoneTagUpdateResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} return cast( Optional[ZoneTagUpdateResponse], await self._put( - f"/zones/{zone_id}/tags", + path_template("/zones/{zone_id}/tags", zone_id=zone_id), body=await async_maybe_transform( { "resource_id": resource_id, @@ -504,7 +506,7 @@ async def update( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, if_match: 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. @@ -527,12 +529,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} return await self._delete( - f"/zones/{zone_id}/tags", + path_template("/zones/{zone_id}/tags", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -542,7 +546,7 @@ async def delete( async def get( self, *, - zone_id: str, + zone_id: str | None = None, resource_id: str, resource_type: Literal[ "access_application_policy", @@ -582,12 +586,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[ZoneTagGetResponse], await self._get( - f"/zones/{zone_id}/tags", + path_template("/zones/{zone_id}/tags", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/rules/api.md b/src/cloudflare/resources/rules/api.md new file mode 100644 index 00000000000..411635bbf15 --- /dev/null +++ b/src/cloudflare/resources/rules/api.md @@ -0,0 +1,61 @@ +# Rules + +## Lists + +Types: + +```python +from cloudflare.types.rules import ( + Hostname, + ListsList, + Redirect, + ListCreateResponse, + ListUpdateResponse, + ListDeleteResponse, + ListGetResponse, +) +``` + +Methods: + +- 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 + +### BulkOperations + +Types: + +```python +from cloudflare.types.rules.lists import BulkOperationGetResponse +``` + +Methods: + +- client.rules.lists.bulk_operations.get(operation_id, \*, account_id) -> BulkOperationGetResponse + +### Items + +Types: + +```python +from cloudflare.types.rules.lists import ( + ListCursor, + ListItem, + ItemCreateResponse, + ItemUpdateResponse, + ItemListResponse, + ItemDeleteResponse, + ItemGetResponse, +) +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/rules/lists/bulk_operations.py b/src/cloudflare/resources/rules/lists/bulk_operations.py index 57edc28f206..60fe6e088d4 100644 --- a/src/cloudflare/resources/rules/lists/bulk_operations.py +++ b/src/cloudflare/resources/rules/lists/bulk_operations.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +47,7 @@ def get( self, operation_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -74,6 +75,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not operation_id: @@ -81,7 +84,11 @@ def get( return cast( BulkOperationGetResponse, self._get( - f"/accounts/{account_id}/rules/lists/bulk_operations/{operation_id}", + path_template( + "/accounts/{account_id}/rules/lists/bulk_operations/{operation_id}", + account_id=account_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -120,7 +127,7 @@ async def get( self, operation_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -148,6 +155,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not operation_id: @@ -155,7 +164,11 @@ async def get( return cast( BulkOperationGetResponse, await self._get( - f"/accounts/{account_id}/rules/lists/bulk_operations/{operation_id}", + path_template( + "/accounts/{account_id}/rules/lists/bulk_operations/{operation_id}", + account_id=account_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/rules/lists/items.py b/src/cloudflare/resources/rules/lists/items.py index c25f615936c..dfa11d97ca4 100644 --- a/src/cloudflare/resources/rules/lists/items.py +++ b/src/cloudflare/resources/rules/lists/items.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -53,7 +53,7 @@ def create( self, list_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[item_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. @@ -85,12 +85,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._post( - f"/accounts/{account_id}/rules/lists/{list_id}/items", + path_template("/accounts/{account_id}/rules/lists/{list_id}/items", account_id=account_id, list_id=list_id), body=maybe_transform(body, Iterable[item_create_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -106,7 +108,7 @@ def update( self, list_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[item_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. @@ -138,12 +140,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._put( - f"/accounts/{account_id}/rules/lists/{list_id}/items", + path_template("/accounts/{account_id}/rules/lists/{list_id}/items", account_id=account_id, list_id=list_id), body=maybe_transform(body, Iterable[item_update_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -159,7 +163,7 @@ def list( self, list_id: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -199,12 +203,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._get_api_list( - f"/accounts/{account_id}/rules/lists/{list_id}/items", + path_template("/accounts/{account_id}/rules/lists/{list_id}/items", account_id=account_id, list_id=list_id), page=SyncCursorPaginationAfter[ItemListResponse], options=make_request_options( extra_headers=extra_headers, @@ -227,7 +233,7 @@ def delete( self, list_id: str, *, - account_id: str, + account_id: str | None = None, items: Iterable[item_delete_params.Item] | 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. @@ -259,12 +265,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._delete( - f"/accounts/{account_id}/rules/lists/{list_id}/items", + path_template("/accounts/{account_id}/rules/lists/{list_id}/items", account_id=account_id, list_id=list_id), body=maybe_transform({"items": items}, item_delete_params.ItemDeleteParams), options=make_request_options( extra_headers=extra_headers, @@ -280,7 +288,7 @@ def get( self, item_id: str, *, - account_id: str, + account_id: str | None = None, list_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. @@ -307,6 +315,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: @@ -316,7 +326,12 @@ def get( return cast( ItemGetResponse, self._get( - f"/accounts/{account_id}/rules/lists/{list_id}/items/{item_id}", + path_template( + "/accounts/{account_id}/rules/lists/{list_id}/items/{item_id}", + account_id=account_id, + list_id=list_id, + item_id=item_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -355,7 +370,7 @@ async def create( self, list_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[item_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. @@ -387,12 +402,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._post( - f"/accounts/{account_id}/rules/lists/{list_id}/items", + path_template("/accounts/{account_id}/rules/lists/{list_id}/items", account_id=account_id, list_id=list_id), body=await async_maybe_transform(body, Iterable[item_create_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -408,7 +425,7 @@ async def update( self, list_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[item_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. @@ -440,12 +457,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._put( - f"/accounts/{account_id}/rules/lists/{list_id}/items", + path_template("/accounts/{account_id}/rules/lists/{list_id}/items", account_id=account_id, list_id=list_id), body=await async_maybe_transform(body, Iterable[item_update_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -461,7 +480,7 @@ def list( self, list_id: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -501,12 +520,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._get_api_list( - f"/accounts/{account_id}/rules/lists/{list_id}/items", + path_template("/accounts/{account_id}/rules/lists/{list_id}/items", account_id=account_id, list_id=list_id), page=AsyncCursorPaginationAfter[ItemListResponse], options=make_request_options( extra_headers=extra_headers, @@ -529,7 +550,7 @@ async def delete( self, list_id: str, *, - account_id: str, + account_id: str | None = None, items: Iterable[item_delete_params.Item] | 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. @@ -561,12 +582,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._delete( - f"/accounts/{account_id}/rules/lists/{list_id}/items", + path_template("/accounts/{account_id}/rules/lists/{list_id}/items", account_id=account_id, list_id=list_id), body=await async_maybe_transform({"items": items}, item_delete_params.ItemDeleteParams), options=make_request_options( extra_headers=extra_headers, @@ -582,7 +605,7 @@ async def get( self, item_id: str, *, - account_id: str, + account_id: str | None = None, list_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. @@ -609,6 +632,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: @@ -618,7 +643,12 @@ async def get( return cast( ItemGetResponse, await self._get( - f"/accounts/{account_id}/rules/lists/{list_id}/items/{item_id}", + path_template( + "/accounts/{account_id}/rules/lists/{list_id}/items/{item_id}", + account_id=account_id, + list_id=list_id, + item_id=item_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/rules/lists/lists.py b/src/cloudflare/resources/rules/lists/lists.py index a9acf30d14d..f3e00b8f378 100644 --- a/src/cloudflare/resources/rules/lists/lists.py +++ b/src/cloudflare/resources/rules/lists/lists.py @@ -16,7 +16,7 @@ AsyncItemsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -77,7 +77,7 @@ def with_streaming_response(self) -> ListsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, kind: Literal["ip", "redirect", "hostname", "asn"], name: str, description: str | Omit = omit, @@ -109,10 +109,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/rules/lists", + path_template("/accounts/{account_id}/rules/lists", account_id=account_id), body=maybe_transform( { "kind": kind, @@ -135,7 +137,7 @@ def update( self, list_id: str, *, - account_id: str, + account_id: str | None = None, description: 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. @@ -162,12 +164,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._put( - f"/accounts/{account_id}/rules/lists/{list_id}", + path_template("/accounts/{account_id}/rules/lists/{list_id}", account_id=account_id, list_id=list_id), body=maybe_transform({"description": description}, list_update_params.ListUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -182,7 +186,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -204,10 +208,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/rules/lists", + path_template("/accounts/{account_id}/rules/lists", account_id=account_id), page=SyncSinglePage[ListsList], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -219,7 +225,7 @@ def delete( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -243,12 +249,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._delete( - f"/accounts/{account_id}/rules/lists/{list_id}", + path_template("/accounts/{account_id}/rules/lists/{list_id}", account_id=account_id, list_id=list_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -263,7 +271,7 @@ def get( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -287,12 +295,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._get( - f"/accounts/{account_id}/rules/lists/{list_id}", + path_template("/accounts/{account_id}/rules/lists/{list_id}", account_id=account_id, list_id=list_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -335,7 +345,7 @@ def with_streaming_response(self) -> AsyncListsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, kind: Literal["ip", "redirect", "hostname", "asn"], name: str, description: str | Omit = omit, @@ -367,10 +377,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/rules/lists", + path_template("/accounts/{account_id}/rules/lists", account_id=account_id), body=await async_maybe_transform( { "kind": kind, @@ -393,7 +405,7 @@ async def update( self, list_id: str, *, - account_id: str, + account_id: str | None = None, description: 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. @@ -420,12 +432,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._put( - f"/accounts/{account_id}/rules/lists/{list_id}", + path_template("/accounts/{account_id}/rules/lists/{list_id}", account_id=account_id, list_id=list_id), body=await async_maybe_transform({"description": description}, list_update_params.ListUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -440,7 +454,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -462,10 +476,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/rules/lists", + path_template("/accounts/{account_id}/rules/lists", account_id=account_id), page=AsyncSinglePage[ListsList], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -477,7 +493,7 @@ async def delete( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -501,12 +517,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._delete( - f"/accounts/{account_id}/rules/lists/{list_id}", + path_template("/accounts/{account_id}/rules/lists/{list_id}", account_id=account_id, list_id=list_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -521,7 +539,7 @@ async def get( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -545,12 +563,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._get( - f"/accounts/{account_id}/rules/lists/{list_id}", + path_template("/accounts/{account_id}/rules/lists/{list_id}", account_id=account_id, list_id=list_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/rulesets/__init__.py b/src/cloudflare/resources/rulesets/__init__.py new file mode 100644 index 00000000000..3770eeded7d --- /dev/null +++ b/src/cloudflare/resources/rulesets/__init__.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .rules import ( + RulesResource, + AsyncRulesResource, + RulesResourceWithRawResponse, + AsyncRulesResourceWithRawResponse, + RulesResourceWithStreamingResponse, + AsyncRulesResourceWithStreamingResponse, +) +from .phases import ( + PhasesResource, + AsyncPhasesResource, + PhasesResourceWithRawResponse, + AsyncPhasesResourceWithRawResponse, + PhasesResourceWithStreamingResponse, + AsyncPhasesResourceWithStreamingResponse, +) +from .rulesets import ( + RulesetsResource, + AsyncRulesetsResource, + RulesetsResourceWithRawResponse, + AsyncRulesetsResourceWithRawResponse, + RulesetsResourceWithStreamingResponse, + AsyncRulesetsResourceWithStreamingResponse, +) +from .versions import ( + VersionsResource, + AsyncVersionsResource, + VersionsResourceWithRawResponse, + AsyncVersionsResourceWithRawResponse, + VersionsResourceWithStreamingResponse, + AsyncVersionsResourceWithStreamingResponse, +) + +__all__ = [ + "PhasesResource", + "AsyncPhasesResource", + "PhasesResourceWithRawResponse", + "AsyncPhasesResourceWithRawResponse", + "PhasesResourceWithStreamingResponse", + "AsyncPhasesResourceWithStreamingResponse", + "RulesResource", + "AsyncRulesResource", + "RulesResourceWithRawResponse", + "AsyncRulesResourceWithRawResponse", + "RulesResourceWithStreamingResponse", + "AsyncRulesResourceWithStreamingResponse", + "VersionsResource", + "AsyncVersionsResource", + "VersionsResourceWithRawResponse", + "AsyncVersionsResourceWithRawResponse", + "VersionsResourceWithStreamingResponse", + "AsyncVersionsResourceWithStreamingResponse", + "RulesetsResource", + "AsyncRulesetsResource", + "RulesetsResourceWithRawResponse", + "AsyncRulesetsResourceWithRawResponse", + "RulesetsResourceWithStreamingResponse", + "AsyncRulesetsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/rulesets/api.md b/src/cloudflare/resources/rulesets/api.md new file mode 100644 index 00000000000..f7ca2e84e24 --- /dev/null +++ b/src/cloudflare/resources/rulesets/api.md @@ -0,0 +1,99 @@ +# Rulesets + +Types: + +```python +from cloudflare.types.rulesets import ( + Kind, + Phase, + Ruleset, + RulesetCreateResponse, + RulesetUpdateResponse, + RulesetListResponse, + RulesetGetResponse, +) +``` + +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, \*\*params) -> SyncCursorPagination[RulesetListResponse] +- client.rulesets.delete(ruleset_id, \*, account_id, zone_id) -> None +- client.rulesets.get(ruleset_id, \*, account_id, zone_id) -> RulesetGetResponse + +## Phases + +Types: + +```python +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 + +### Versions + +Types: + +```python +from cloudflare.types.rulesets.phases import VersionListResponse, VersionGetResponse +``` + +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 + +## Rules + +Types: + +```python +from cloudflare.types.rulesets import ( + BlockRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + LogCustomFieldRule, + LogRule, + Logging, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + RulesetRule, + ScoreRule, + ServeErrorRule, + SetCacheSettingsRule, + SetConfigRule, + SkipRule, + RuleCreateResponse, + RuleDeleteResponse, + RuleEditResponse, +) +``` + +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 + +## Versions + +Types: + +```python +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 diff --git a/src/cloudflare/resources/rulesets/phases/__init__.py b/src/cloudflare/resources/rulesets/phases/__init__.py new file mode 100644 index 00000000000..c8ad5c9ffd6 --- /dev/null +++ b/src/cloudflare/resources/rulesets/phases/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .phases import ( + PhasesResource, + AsyncPhasesResource, + PhasesResourceWithRawResponse, + AsyncPhasesResourceWithRawResponse, + PhasesResourceWithStreamingResponse, + AsyncPhasesResourceWithStreamingResponse, +) +from .versions import ( + VersionsResource, + AsyncVersionsResource, + VersionsResourceWithRawResponse, + AsyncVersionsResourceWithRawResponse, + VersionsResourceWithStreamingResponse, + AsyncVersionsResourceWithStreamingResponse, +) + +__all__ = [ + "VersionsResource", + "AsyncVersionsResource", + "VersionsResourceWithRawResponse", + "AsyncVersionsResourceWithRawResponse", + "VersionsResourceWithStreamingResponse", + "AsyncVersionsResourceWithStreamingResponse", + "PhasesResource", + "AsyncPhasesResource", + "PhasesResourceWithRawResponse", + "AsyncPhasesResourceWithRawResponse", + "PhasesResourceWithStreamingResponse", + "AsyncPhasesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/rulesets/phases/phases.py b/src/cloudflare/resources/rulesets/phases/phases.py new file mode 100644 index 00000000000..0bf0455ba5b --- /dev/null +++ b/src/cloudflare/resources/rulesets/phases/phases.py @@ -0,0 +1,448 @@ +# 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 .versions import ( + VersionsResource, + AsyncVersionsResource, + VersionsResourceWithRawResponse, + AsyncVersionsResourceWithRawResponse, + VersionsResourceWithStreamingResponse, + AsyncVersionsResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import path_template, 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.rulesets import Phase, phase_update_params +from ....types.rulesets.phase import Phase +from ....types.rulesets.phase_get_response import PhaseGetResponse +from ....types.rulesets.phase_update_response import PhaseUpdateResponse + +__all__ = ["PhasesResource", "AsyncPhasesResource"] + + +class PhasesResource(SyncAPIResource): + @cached_property + def versions(self) -> VersionsResource: + return VersionsResource(self._client) + + @cached_property + def with_raw_response(self) -> PhasesResourceWithRawResponse: + """ + 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 PhasesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PhasesResourceWithStreamingResponse: + """ + 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 PhasesResourceWithStreamingResponse(self) + + def update( + self, + ruleset_phase: Phase, + *, + account_id: str | None = None, + zone_id: str | None = None, + description: str | Omit = omit, + name: str | Omit = omit, + rules: Iterable[phase_update_params.Rule] | 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, + ) -> PhaseUpdateResponse: + """ + Updates an account or zone entry point ruleset, creating a new version. + + Args: + ruleset_phase: The phase of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + description: An informative description of the ruleset. + + name: The human-readable name of the ruleset. + + rules: The list of rules in the ruleset. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 ruleset_phase: + raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._put( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint", + ruleset_phase=ruleset_phase, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=maybe_transform( + { + "description": description, + "name": name, + "rules": rules, + }, + phase_update_params.PhaseUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PhaseUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[PhaseUpdateResponse], ResultWrapper[PhaseUpdateResponse]), + ) + + def get( + self, + ruleset_phase: Phase, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> PhaseGetResponse: + """ + Fetches the latest version of the account or zone entry point ruleset for a + given phase. + + Args: + ruleset_phase: The phase of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_phase: + raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint", + ruleset_phase=ruleset_phase, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PhaseGetResponse]._unwrapper, + ), + cast_to=cast(Type[PhaseGetResponse], ResultWrapper[PhaseGetResponse]), + ) + + +class AsyncPhasesResource(AsyncAPIResource): + @cached_property + def versions(self) -> AsyncVersionsResource: + return AsyncVersionsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncPhasesResourceWithRawResponse: + """ + 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 AsyncPhasesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPhasesResourceWithStreamingResponse: + """ + 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 AsyncPhasesResourceWithStreamingResponse(self) + + async def update( + self, + ruleset_phase: Phase, + *, + account_id: str | None = None, + zone_id: str | None = None, + description: str | Omit = omit, + name: str | Omit = omit, + rules: Iterable[phase_update_params.Rule] | 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, + ) -> PhaseUpdateResponse: + """ + Updates an account or zone entry point ruleset, creating a new version. + + Args: + ruleset_phase: The phase of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + description: An informative description of the ruleset. + + name: The human-readable name of the ruleset. + + rules: The list of rules in the ruleset. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 ruleset_phase: + raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._put( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint", + ruleset_phase=ruleset_phase, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=await async_maybe_transform( + { + "description": description, + "name": name, + "rules": rules, + }, + phase_update_params.PhaseUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PhaseUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[PhaseUpdateResponse], ResultWrapper[PhaseUpdateResponse]), + ) + + async def get( + self, + ruleset_phase: Phase, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> PhaseGetResponse: + """ + Fetches the latest version of the account or zone entry point ruleset for a + given phase. + + Args: + ruleset_phase: The phase of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_phase: + raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint", + ruleset_phase=ruleset_phase, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PhaseGetResponse]._unwrapper, + ), + cast_to=cast(Type[PhaseGetResponse], ResultWrapper[PhaseGetResponse]), + ) + + +class PhasesResourceWithRawResponse: + def __init__(self, phases: PhasesResource) -> None: + self._phases = phases + + self.update = to_raw_response_wrapper( + phases.update, + ) + self.get = to_raw_response_wrapper( + phases.get, + ) + + @cached_property + def versions(self) -> VersionsResourceWithRawResponse: + return VersionsResourceWithRawResponse(self._phases.versions) + + +class AsyncPhasesResourceWithRawResponse: + def __init__(self, phases: AsyncPhasesResource) -> None: + self._phases = phases + + self.update = async_to_raw_response_wrapper( + phases.update, + ) + self.get = async_to_raw_response_wrapper( + phases.get, + ) + + @cached_property + def versions(self) -> AsyncVersionsResourceWithRawResponse: + return AsyncVersionsResourceWithRawResponse(self._phases.versions) + + +class PhasesResourceWithStreamingResponse: + def __init__(self, phases: PhasesResource) -> None: + self._phases = phases + + self.update = to_streamed_response_wrapper( + phases.update, + ) + self.get = to_streamed_response_wrapper( + phases.get, + ) + + @cached_property + def versions(self) -> VersionsResourceWithStreamingResponse: + return VersionsResourceWithStreamingResponse(self._phases.versions) + + +class AsyncPhasesResourceWithStreamingResponse: + def __init__(self, phases: AsyncPhasesResource) -> None: + self._phases = phases + + self.update = async_to_streamed_response_wrapper( + phases.update, + ) + self.get = async_to_streamed_response_wrapper( + phases.get, + ) + + @cached_property + def versions(self) -> AsyncVersionsResourceWithStreamingResponse: + return AsyncVersionsResourceWithStreamingResponse(self._phases.versions) diff --git a/src/cloudflare/resources/rulesets/phases/versions.py b/src/cloudflare/resources/rulesets/phases/versions.py new file mode 100644 index 00000000000..1e5109c9027 --- /dev/null +++ b/src/cloudflare/resources/rulesets/phases/versions.py @@ -0,0 +1,387 @@ +# 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 path_template +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.rulesets import Phase +from ....types.rulesets.phase import Phase +from ....types.rulesets.phases.version_get_response import VersionGetResponse +from ....types.rulesets.phases.version_list_response import VersionListResponse + +__all__ = ["VersionsResource", "AsyncVersionsResource"] + + +class VersionsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> VersionsResourceWithRawResponse: + """ + 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 VersionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> VersionsResourceWithStreamingResponse: + """ + 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 VersionsResourceWithStreamingResponse(self) + + def list( + self, + ruleset_phase: Phase, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[VersionListResponse]: + """ + Fetches the versions of an account or zone entry point ruleset. + + Args: + ruleset_phase: The phase of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_phase: + raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint/versions", + ruleset_phase=ruleset_phase, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=SyncSinglePage[VersionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=VersionListResponse, + ) + + def get( + self, + ruleset_version: str, + *, + ruleset_phase: Phase, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VersionGetResponse: + """ + Fetches a specific version of an account or zone entry point ruleset. + + Args: + ruleset_phase: The phase of the ruleset. + + ruleset_version: The version of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_phase: + raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") + if not ruleset_version: + raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint/versions/{ruleset_version}", + ruleset_phase=ruleset_phase, + ruleset_version=ruleset_version, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[VersionGetResponse]._unwrapper, + ), + cast_to=cast(Type[VersionGetResponse], ResultWrapper[VersionGetResponse]), + ) + + +class AsyncVersionsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncVersionsResourceWithRawResponse: + """ + 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 AsyncVersionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncVersionsResourceWithStreamingResponse: + """ + 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 AsyncVersionsResourceWithStreamingResponse(self) + + def list( + self, + ruleset_phase: Phase, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[VersionListResponse, AsyncSinglePage[VersionListResponse]]: + """ + Fetches the versions of an account or zone entry point ruleset. + + Args: + ruleset_phase: The phase of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_phase: + raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint/versions", + ruleset_phase=ruleset_phase, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=AsyncSinglePage[VersionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=VersionListResponse, + ) + + async def get( + self, + ruleset_version: str, + *, + ruleset_phase: Phase, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VersionGetResponse: + """ + Fetches a specific version of an account or zone entry point ruleset. + + Args: + ruleset_phase: The phase of the ruleset. + + ruleset_version: The version of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_phase: + raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") + if not ruleset_version: + raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint/versions/{ruleset_version}", + ruleset_phase=ruleset_phase, + ruleset_version=ruleset_version, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[VersionGetResponse]._unwrapper, + ), + cast_to=cast(Type[VersionGetResponse], ResultWrapper[VersionGetResponse]), + ) + + +class VersionsResourceWithRawResponse: + def __init__(self, versions: VersionsResource) -> None: + self._versions = versions + + self.list = to_raw_response_wrapper( + versions.list, + ) + self.get = to_raw_response_wrapper( + versions.get, + ) + + +class AsyncVersionsResourceWithRawResponse: + def __init__(self, versions: AsyncVersionsResource) -> None: + self._versions = versions + + self.list = async_to_raw_response_wrapper( + versions.list, + ) + self.get = async_to_raw_response_wrapper( + versions.get, + ) + + +class VersionsResourceWithStreamingResponse: + def __init__(self, versions: VersionsResource) -> None: + self._versions = versions + + self.list = to_streamed_response_wrapper( + versions.list, + ) + self.get = to_streamed_response_wrapper( + versions.get, + ) + + +class AsyncVersionsResourceWithStreamingResponse: + def __init__(self, versions: AsyncVersionsResource) -> None: + self._versions = versions + + self.list = async_to_streamed_response_wrapper( + versions.list, + ) + self.get = async_to_streamed_response_wrapper( + versions.get, + ) diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py new file mode 100644 index 00000000000..8dd53abab70 --- /dev/null +++ b/src/cloudflare/resources/rulesets/rules.py @@ -0,0 +1,6524 @@ +# 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, overload + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, 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.rulesets import rule_edit_params, rule_create_params +from ...types.rulesets.logging_param import LoggingParam +from ...types.rulesets.rule_edit_response import RuleEditResponse +from ...types.rulesets.rule_create_response import RuleCreateResponse +from ...types.rulesets.rule_delete_response import RuleDeleteResponse + +__all__ = ["RulesResource", "AsyncRulesResource"] + + +class RulesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> RulesResourceWithRawResponse: + """ + 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 RulesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RulesResourceWithStreamingResponse: + """ + 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 RulesResourceWithStreamingResponse(self) + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["block"] | Omit = omit, + action_parameters: rule_create_params.BlockRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.BlockRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.BlockRulePosition | Omit = omit, + ratelimit: rule_create_params.BlockRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ChallengeRulePosition | Omit = omit, + ratelimit: rule_create_params.ChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["compress_response"] | Omit = omit, + action_parameters: rule_create_params.ResponseCompressionRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ResponseCompressionRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ResponseCompressionRulePosition | Omit = omit, + ratelimit: rule_create_params.ResponseCompressionRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["ddos_dynamic"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.DDoSDynamicRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.DDoSDynamicRulePosition | Omit = omit, + ratelimit: rule_create_params.DDoSDynamicRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["execute"] | Omit = omit, + action_parameters: rule_create_params.ExecuteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ExecuteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ExecuteRulePosition | Omit = omit, + ratelimit: rule_create_params.ExecuteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["force_connection_close"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ForceConnectionCloseRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ForceConnectionCloseRulePosition | Omit = omit, + ratelimit: rule_create_params.ForceConnectionCloseRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["js_challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.JavaScriptChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.JavaScriptChallengeRulePosition | Omit = omit, + ratelimit: rule_create_params.JavaScriptChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["log"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.LogRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.LogRulePosition | Omit = omit, + ratelimit: rule_create_params.LogRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["log_custom_field"] | Omit = omit, + action_parameters: rule_create_params.LogCustomFieldRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.LogCustomFieldRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.LogCustomFieldRulePosition | Omit = omit, + ratelimit: rule_create_params.LogCustomFieldRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["managed_challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ManagedChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ManagedChallengeRulePosition | Omit = omit, + ratelimit: rule_create_params.ManagedChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["redirect"] | Omit = omit, + action_parameters: rule_create_params.RedirectRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.RedirectRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.RedirectRulePosition | Omit = omit, + ratelimit: rule_create_params.RedirectRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["rewrite"] | Omit = omit, + action_parameters: rule_create_params.RewriteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.RewriteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.RewriteRulePosition | Omit = omit, + ratelimit: rule_create_params.RewriteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["route"] | Omit = omit, + action_parameters: rule_create_params.RouteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.RouteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.RouteRulePosition | Omit = omit, + ratelimit: rule_create_params.RouteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["score"] | Omit = omit, + action_parameters: rule_create_params.ScoreRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ScoreRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ScoreRulePosition | Omit = omit, + ratelimit: rule_create_params.ScoreRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["serve_error"] | Omit = omit, + action_parameters: rule_create_params.ServeErrorRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ServeErrorRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ServeErrorRulePosition | Omit = omit, + ratelimit: rule_create_params.ServeErrorRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_control"] | Omit = omit, + action_parameters: rule_create_params.SetCacheControlRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheControlRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetCacheControlRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheControlRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_settings"] | Omit = omit, + action_parameters: rule_create_params.SetCacheSettingsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheSettingsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetCacheSettingsRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheSettingsRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_tags"] | Omit = omit, + action_parameters: rule_create_params.SetCacheTagsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheTagsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetCacheTagsRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheTagsRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_config"] | Omit = omit, + action_parameters: rule_create_params.SetConfigurationRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetConfigurationRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetConfigurationRulePosition | Omit = omit, + ratelimit: rule_create_params.SetConfigurationRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["skip"] | Omit = omit, + action_parameters: rule_create_params.SkipRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SkipRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SkipRulePosition | Omit = omit, + ratelimit: rule_create_params.SkipRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + def create( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["block"] + | Literal["challenge"] + | Literal["compress_response"] + | Literal["ddos_dynamic"] + | Literal["execute"] + | Literal["force_connection_close"] + | Literal["js_challenge"] + | Literal["log"] + | Literal["log_custom_field"] + | Literal["managed_challenge"] + | Literal["redirect"] + | Literal["rewrite"] + | Literal["route"] + | Literal["score"] + | Literal["serve_error"] + | Literal["set_cache_control"] + | Literal["set_cache_settings"] + | Literal["set_cache_tags"] + | Literal["set_config"] + | Literal["skip"] + | Omit = omit, + action_parameters: rule_create_params.BlockRuleActionParameters + | object + | rule_create_params.ResponseCompressionRuleActionParameters + | rule_create_params.ExecuteRuleActionParameters + | rule_create_params.LogCustomFieldRuleActionParameters + | rule_create_params.RedirectRuleActionParameters + | rule_create_params.RewriteRuleActionParameters + | rule_create_params.RouteRuleActionParameters + | rule_create_params.ScoreRuleActionParameters + | rule_create_params.ServeErrorRuleActionParameters + | rule_create_params.SetCacheControlRuleActionParameters + | rule_create_params.SetCacheSettingsRuleActionParameters + | rule_create_params.SetCacheTagsRuleActionParameters + | rule_create_params.SetConfigurationRuleActionParameters + | rule_create_params.SkipRuleActionParameters + | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.BlockRuleExposedCredentialCheck + | rule_create_params.ChallengeRuleExposedCredentialCheck + | rule_create_params.ResponseCompressionRuleExposedCredentialCheck + | rule_create_params.DDoSDynamicRuleExposedCredentialCheck + | rule_create_params.ExecuteRuleExposedCredentialCheck + | rule_create_params.ForceConnectionCloseRuleExposedCredentialCheck + | rule_create_params.JavaScriptChallengeRuleExposedCredentialCheck + | rule_create_params.LogRuleExposedCredentialCheck + | rule_create_params.LogCustomFieldRuleExposedCredentialCheck + | rule_create_params.ManagedChallengeRuleExposedCredentialCheck + | rule_create_params.RedirectRuleExposedCredentialCheck + | rule_create_params.RewriteRuleExposedCredentialCheck + | rule_create_params.RouteRuleExposedCredentialCheck + | rule_create_params.ScoreRuleExposedCredentialCheck + | rule_create_params.ServeErrorRuleExposedCredentialCheck + | rule_create_params.SetCacheControlRuleExposedCredentialCheck + | rule_create_params.SetCacheSettingsRuleExposedCredentialCheck + | rule_create_params.SetCacheTagsRuleExposedCredentialCheck + | rule_create_params.SetConfigurationRuleExposedCredentialCheck + | rule_create_params.SkipRuleExposedCredentialCheck + | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.BlockRulePosition + | rule_create_params.ChallengeRulePosition + | rule_create_params.ResponseCompressionRulePosition + | rule_create_params.DDoSDynamicRulePosition + | rule_create_params.ExecuteRulePosition + | rule_create_params.ForceConnectionCloseRulePosition + | rule_create_params.JavaScriptChallengeRulePosition + | rule_create_params.LogRulePosition + | rule_create_params.LogCustomFieldRulePosition + | rule_create_params.ManagedChallengeRulePosition + | rule_create_params.RedirectRulePosition + | rule_create_params.RewriteRulePosition + | rule_create_params.RouteRulePosition + | rule_create_params.ScoreRulePosition + | rule_create_params.ServeErrorRulePosition + | rule_create_params.SetCacheControlRulePosition + | rule_create_params.SetCacheSettingsRulePosition + | rule_create_params.SetCacheTagsRulePosition + | rule_create_params.SetConfigurationRulePosition + | rule_create_params.SkipRulePosition + | Omit = omit, + ratelimit: rule_create_params.BlockRuleRatelimit + | rule_create_params.ChallengeRuleRatelimit + | rule_create_params.ResponseCompressionRuleRatelimit + | rule_create_params.DDoSDynamicRuleRatelimit + | rule_create_params.ExecuteRuleRatelimit + | rule_create_params.ForceConnectionCloseRuleRatelimit + | rule_create_params.JavaScriptChallengeRuleRatelimit + | rule_create_params.LogRuleRatelimit + | rule_create_params.LogCustomFieldRuleRatelimit + | rule_create_params.ManagedChallengeRuleRatelimit + | rule_create_params.RedirectRuleRatelimit + | rule_create_params.RewriteRuleRatelimit + | rule_create_params.RouteRuleRatelimit + | rule_create_params.ScoreRuleRatelimit + | rule_create_params.ServeErrorRuleRatelimit + | rule_create_params.SetCacheControlRuleRatelimit + | rule_create_params.SetCacheSettingsRuleRatelimit + | rule_create_params.SetCacheTagsRuleRatelimit + | rule_create_params.SetConfigurationRuleRatelimit + | rule_create_params.SkipRuleRatelimit + | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + if not ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._post( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=maybe_transform( + { + "id": id, + "action": action, + "action_parameters": action_parameters, + "description": description, + "enabled": enabled, + "exposed_credential_check": exposed_credential_check, + "expression": expression, + "logging": logging, + "position": position, + "ratelimit": ratelimit, + "ref": ref, + }, + rule_create_params.RuleCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RuleCreateResponse]._unwrapper, + ), + cast_to=cast(Type[RuleCreateResponse], ResultWrapper[RuleCreateResponse]), + ) + + def delete( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> RuleDeleteResponse: + """ + Deletes an existing rule from an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not rule_id: + raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._delete( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}", + ruleset_id=ruleset_id, + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RuleDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[RuleDeleteResponse], ResultWrapper[RuleDeleteResponse]), + ) + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["block"] | Omit = omit, + action_parameters: rule_edit_params.BlockRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.BlockRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.BlockRulePosition | Omit = omit, + ratelimit: rule_edit_params.BlockRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ChallengeRulePosition | Omit = omit, + ratelimit: rule_edit_params.ChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["compress_response"] | Omit = omit, + action_parameters: rule_edit_params.ResponseCompressionRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ResponseCompressionRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ResponseCompressionRulePosition | Omit = omit, + ratelimit: rule_edit_params.ResponseCompressionRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["ddos_dynamic"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.DDoSDynamicRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.DDoSDynamicRulePosition | Omit = omit, + ratelimit: rule_edit_params.DDoSDynamicRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["execute"] | Omit = omit, + action_parameters: rule_edit_params.ExecuteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ExecuteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ExecuteRulePosition | Omit = omit, + ratelimit: rule_edit_params.ExecuteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["force_connection_close"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ForceConnectionCloseRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ForceConnectionCloseRulePosition | Omit = omit, + ratelimit: rule_edit_params.ForceConnectionCloseRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["js_challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.JavaScriptChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.JavaScriptChallengeRulePosition | Omit = omit, + ratelimit: rule_edit_params.JavaScriptChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["log"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.LogRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.LogRulePosition | Omit = omit, + ratelimit: rule_edit_params.LogRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["log_custom_field"] | Omit = omit, + action_parameters: rule_edit_params.LogCustomFieldRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.LogCustomFieldRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.LogCustomFieldRulePosition | Omit = omit, + ratelimit: rule_edit_params.LogCustomFieldRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["managed_challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ManagedChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ManagedChallengeRulePosition | Omit = omit, + ratelimit: rule_edit_params.ManagedChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["redirect"] | Omit = omit, + action_parameters: rule_edit_params.RedirectRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.RedirectRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.RedirectRulePosition | Omit = omit, + ratelimit: rule_edit_params.RedirectRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["rewrite"] | Omit = omit, + action_parameters: rule_edit_params.RewriteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.RewriteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.RewriteRulePosition | Omit = omit, + ratelimit: rule_edit_params.RewriteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["route"] | Omit = omit, + action_parameters: rule_edit_params.RouteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.RouteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.RouteRulePosition | Omit = omit, + ratelimit: rule_edit_params.RouteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["score"] | Omit = omit, + action_parameters: rule_edit_params.ScoreRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ScoreRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ScoreRulePosition | Omit = omit, + ratelimit: rule_edit_params.ScoreRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["serve_error"] | Omit = omit, + action_parameters: rule_edit_params.ServeErrorRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ServeErrorRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ServeErrorRulePosition | Omit = omit, + ratelimit: rule_edit_params.ServeErrorRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_control"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheControlRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheControlRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheControlRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheControlRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_settings"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheSettingsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheSettingsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheSettingsRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheSettingsRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_tags"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheTagsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheTagsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheTagsRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheTagsRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_config"] | Omit = omit, + action_parameters: rule_edit_params.SetConfigurationRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetConfigurationRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetConfigurationRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetConfigurationRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["skip"] | Omit = omit, + action_parameters: rule_edit_params.SkipRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SkipRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SkipRulePosition | Omit = omit, + ratelimit: rule_edit_params.SkipRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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(["ruleset_id"]) + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["block"] + | Literal["challenge"] + | Literal["compress_response"] + | Literal["ddos_dynamic"] + | Literal["execute"] + | Literal["force_connection_close"] + | Literal["js_challenge"] + | Literal["log"] + | Literal["log_custom_field"] + | Literal["managed_challenge"] + | Literal["redirect"] + | Literal["rewrite"] + | Literal["route"] + | Literal["score"] + | Literal["serve_error"] + | Literal["set_cache_control"] + | Literal["set_cache_settings"] + | Literal["set_cache_tags"] + | Literal["set_config"] + | Literal["skip"] + | Omit = omit, + action_parameters: rule_edit_params.BlockRuleActionParameters + | object + | rule_edit_params.ResponseCompressionRuleActionParameters + | rule_edit_params.ExecuteRuleActionParameters + | rule_edit_params.LogCustomFieldRuleActionParameters + | rule_edit_params.RedirectRuleActionParameters + | rule_edit_params.RewriteRuleActionParameters + | rule_edit_params.RouteRuleActionParameters + | rule_edit_params.ScoreRuleActionParameters + | rule_edit_params.ServeErrorRuleActionParameters + | rule_edit_params.SetCacheControlRuleActionParameters + | rule_edit_params.SetCacheSettingsRuleActionParameters + | rule_edit_params.SetCacheTagsRuleActionParameters + | rule_edit_params.SetConfigurationRuleActionParameters + | rule_edit_params.SkipRuleActionParameters + | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.BlockRuleExposedCredentialCheck + | rule_edit_params.ChallengeRuleExposedCredentialCheck + | rule_edit_params.ResponseCompressionRuleExposedCredentialCheck + | rule_edit_params.DDoSDynamicRuleExposedCredentialCheck + | rule_edit_params.ExecuteRuleExposedCredentialCheck + | rule_edit_params.ForceConnectionCloseRuleExposedCredentialCheck + | rule_edit_params.JavaScriptChallengeRuleExposedCredentialCheck + | rule_edit_params.LogRuleExposedCredentialCheck + | rule_edit_params.LogCustomFieldRuleExposedCredentialCheck + | rule_edit_params.ManagedChallengeRuleExposedCredentialCheck + | rule_edit_params.RedirectRuleExposedCredentialCheck + | rule_edit_params.RewriteRuleExposedCredentialCheck + | rule_edit_params.RouteRuleExposedCredentialCheck + | rule_edit_params.ScoreRuleExposedCredentialCheck + | rule_edit_params.ServeErrorRuleExposedCredentialCheck + | rule_edit_params.SetCacheControlRuleExposedCredentialCheck + | rule_edit_params.SetCacheSettingsRuleExposedCredentialCheck + | rule_edit_params.SetCacheTagsRuleExposedCredentialCheck + | rule_edit_params.SetConfigurationRuleExposedCredentialCheck + | rule_edit_params.SkipRuleExposedCredentialCheck + | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.BlockRulePosition + | rule_edit_params.ChallengeRulePosition + | rule_edit_params.ResponseCompressionRulePosition + | rule_edit_params.DDoSDynamicRulePosition + | rule_edit_params.ExecuteRulePosition + | rule_edit_params.ForceConnectionCloseRulePosition + | rule_edit_params.JavaScriptChallengeRulePosition + | rule_edit_params.LogRulePosition + | rule_edit_params.LogCustomFieldRulePosition + | rule_edit_params.ManagedChallengeRulePosition + | rule_edit_params.RedirectRulePosition + | rule_edit_params.RewriteRulePosition + | rule_edit_params.RouteRulePosition + | rule_edit_params.ScoreRulePosition + | rule_edit_params.ServeErrorRulePosition + | rule_edit_params.SetCacheControlRulePosition + | rule_edit_params.SetCacheSettingsRulePosition + | rule_edit_params.SetCacheTagsRulePosition + | rule_edit_params.SetConfigurationRulePosition + | rule_edit_params.SkipRulePosition + | Omit = omit, + ratelimit: rule_edit_params.BlockRuleRatelimit + | rule_edit_params.ChallengeRuleRatelimit + | rule_edit_params.ResponseCompressionRuleRatelimit + | rule_edit_params.DDoSDynamicRuleRatelimit + | rule_edit_params.ExecuteRuleRatelimit + | rule_edit_params.ForceConnectionCloseRuleRatelimit + | rule_edit_params.JavaScriptChallengeRuleRatelimit + | rule_edit_params.LogRuleRatelimit + | rule_edit_params.LogCustomFieldRuleRatelimit + | rule_edit_params.ManagedChallengeRuleRatelimit + | rule_edit_params.RedirectRuleRatelimit + | rule_edit_params.RewriteRuleRatelimit + | rule_edit_params.RouteRuleRatelimit + | rule_edit_params.ScoreRuleRatelimit + | rule_edit_params.ServeErrorRuleRatelimit + | rule_edit_params.SetCacheControlRuleRatelimit + | rule_edit_params.SetCacheSettingsRuleRatelimit + | rule_edit_params.SetCacheTagsRuleRatelimit + | rule_edit_params.SetConfigurationRuleRatelimit + | rule_edit_params.SkipRuleRatelimit + | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + if not ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not rule_id: + raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._patch( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}", + ruleset_id=ruleset_id, + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=maybe_transform( + { + "id": id, + "action": action, + "action_parameters": action_parameters, + "description": description, + "enabled": enabled, + "exposed_credential_check": exposed_credential_check, + "expression": expression, + "logging": logging, + "position": position, + "ratelimit": ratelimit, + "ref": ref, + }, + rule_edit_params.RuleEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RuleEditResponse]._unwrapper, + ), + cast_to=cast(Type[RuleEditResponse], ResultWrapper[RuleEditResponse]), + ) + + +class AsyncRulesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRulesResourceWithRawResponse: + """ + 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 AsyncRulesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: + """ + 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 AsyncRulesResourceWithStreamingResponse(self) + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["block"] | Omit = omit, + action_parameters: rule_create_params.BlockRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.BlockRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.BlockRulePosition | Omit = omit, + ratelimit: rule_create_params.BlockRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ChallengeRulePosition | Omit = omit, + ratelimit: rule_create_params.ChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["compress_response"] | Omit = omit, + action_parameters: rule_create_params.ResponseCompressionRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ResponseCompressionRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ResponseCompressionRulePosition | Omit = omit, + ratelimit: rule_create_params.ResponseCompressionRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["ddos_dynamic"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.DDoSDynamicRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.DDoSDynamicRulePosition | Omit = omit, + ratelimit: rule_create_params.DDoSDynamicRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["execute"] | Omit = omit, + action_parameters: rule_create_params.ExecuteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ExecuteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ExecuteRulePosition | Omit = omit, + ratelimit: rule_create_params.ExecuteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["force_connection_close"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ForceConnectionCloseRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ForceConnectionCloseRulePosition | Omit = omit, + ratelimit: rule_create_params.ForceConnectionCloseRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["js_challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.JavaScriptChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.JavaScriptChallengeRulePosition | Omit = omit, + ratelimit: rule_create_params.JavaScriptChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["log"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.LogRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.LogRulePosition | Omit = omit, + ratelimit: rule_create_params.LogRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["log_custom_field"] | Omit = omit, + action_parameters: rule_create_params.LogCustomFieldRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.LogCustomFieldRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.LogCustomFieldRulePosition | Omit = omit, + ratelimit: rule_create_params.LogCustomFieldRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["managed_challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ManagedChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ManagedChallengeRulePosition | Omit = omit, + ratelimit: rule_create_params.ManagedChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["redirect"] | Omit = omit, + action_parameters: rule_create_params.RedirectRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.RedirectRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.RedirectRulePosition | Omit = omit, + ratelimit: rule_create_params.RedirectRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["rewrite"] | Omit = omit, + action_parameters: rule_create_params.RewriteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.RewriteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.RewriteRulePosition | Omit = omit, + ratelimit: rule_create_params.RewriteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["route"] | Omit = omit, + action_parameters: rule_create_params.RouteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.RouteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.RouteRulePosition | Omit = omit, + ratelimit: rule_create_params.RouteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["score"] | Omit = omit, + action_parameters: rule_create_params.ScoreRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ScoreRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ScoreRulePosition | Omit = omit, + ratelimit: rule_create_params.ScoreRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["serve_error"] | Omit = omit, + action_parameters: rule_create_params.ServeErrorRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ServeErrorRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ServeErrorRulePosition | Omit = omit, + ratelimit: rule_create_params.ServeErrorRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_control"] | Omit = omit, + action_parameters: rule_create_params.SetCacheControlRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheControlRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetCacheControlRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheControlRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_settings"] | Omit = omit, + action_parameters: rule_create_params.SetCacheSettingsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheSettingsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetCacheSettingsRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheSettingsRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_tags"] | Omit = omit, + action_parameters: rule_create_params.SetCacheTagsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheTagsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetCacheTagsRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheTagsRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_config"] | Omit = omit, + action_parameters: rule_create_params.SetConfigurationRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetConfigurationRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetConfigurationRulePosition | Omit = omit, + ratelimit: rule_create_params.SetConfigurationRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["skip"] | Omit = omit, + action_parameters: rule_create_params.SkipRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SkipRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SkipRulePosition | Omit = omit, + ratelimit: rule_create_params.SkipRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + async def create( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["block"] + | Literal["challenge"] + | Literal["compress_response"] + | Literal["ddos_dynamic"] + | Literal["execute"] + | Literal["force_connection_close"] + | Literal["js_challenge"] + | Literal["log"] + | Literal["log_custom_field"] + | Literal["managed_challenge"] + | Literal["redirect"] + | Literal["rewrite"] + | Literal["route"] + | Literal["score"] + | Literal["serve_error"] + | Literal["set_cache_control"] + | Literal["set_cache_settings"] + | Literal["set_cache_tags"] + | Literal["set_config"] + | Literal["skip"] + | Omit = omit, + action_parameters: rule_create_params.BlockRuleActionParameters + | object + | rule_create_params.ResponseCompressionRuleActionParameters + | rule_create_params.ExecuteRuleActionParameters + | rule_create_params.LogCustomFieldRuleActionParameters + | rule_create_params.RedirectRuleActionParameters + | rule_create_params.RewriteRuleActionParameters + | rule_create_params.RouteRuleActionParameters + | rule_create_params.ScoreRuleActionParameters + | rule_create_params.ServeErrorRuleActionParameters + | rule_create_params.SetCacheControlRuleActionParameters + | rule_create_params.SetCacheSettingsRuleActionParameters + | rule_create_params.SetCacheTagsRuleActionParameters + | rule_create_params.SetConfigurationRuleActionParameters + | rule_create_params.SkipRuleActionParameters + | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.BlockRuleExposedCredentialCheck + | rule_create_params.ChallengeRuleExposedCredentialCheck + | rule_create_params.ResponseCompressionRuleExposedCredentialCheck + | rule_create_params.DDoSDynamicRuleExposedCredentialCheck + | rule_create_params.ExecuteRuleExposedCredentialCheck + | rule_create_params.ForceConnectionCloseRuleExposedCredentialCheck + | rule_create_params.JavaScriptChallengeRuleExposedCredentialCheck + | rule_create_params.LogRuleExposedCredentialCheck + | rule_create_params.LogCustomFieldRuleExposedCredentialCheck + | rule_create_params.ManagedChallengeRuleExposedCredentialCheck + | rule_create_params.RedirectRuleExposedCredentialCheck + | rule_create_params.RewriteRuleExposedCredentialCheck + | rule_create_params.RouteRuleExposedCredentialCheck + | rule_create_params.ScoreRuleExposedCredentialCheck + | rule_create_params.ServeErrorRuleExposedCredentialCheck + | rule_create_params.SetCacheControlRuleExposedCredentialCheck + | rule_create_params.SetCacheSettingsRuleExposedCredentialCheck + | rule_create_params.SetCacheTagsRuleExposedCredentialCheck + | rule_create_params.SetConfigurationRuleExposedCredentialCheck + | rule_create_params.SkipRuleExposedCredentialCheck + | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.BlockRulePosition + | rule_create_params.ChallengeRulePosition + | rule_create_params.ResponseCompressionRulePosition + | rule_create_params.DDoSDynamicRulePosition + | rule_create_params.ExecuteRulePosition + | rule_create_params.ForceConnectionCloseRulePosition + | rule_create_params.JavaScriptChallengeRulePosition + | rule_create_params.LogRulePosition + | rule_create_params.LogCustomFieldRulePosition + | rule_create_params.ManagedChallengeRulePosition + | rule_create_params.RedirectRulePosition + | rule_create_params.RewriteRulePosition + | rule_create_params.RouteRulePosition + | rule_create_params.ScoreRulePosition + | rule_create_params.ServeErrorRulePosition + | rule_create_params.SetCacheControlRulePosition + | rule_create_params.SetCacheSettingsRulePosition + | rule_create_params.SetCacheTagsRulePosition + | rule_create_params.SetConfigurationRulePosition + | rule_create_params.SkipRulePosition + | Omit = omit, + ratelimit: rule_create_params.BlockRuleRatelimit + | rule_create_params.ChallengeRuleRatelimit + | rule_create_params.ResponseCompressionRuleRatelimit + | rule_create_params.DDoSDynamicRuleRatelimit + | rule_create_params.ExecuteRuleRatelimit + | rule_create_params.ForceConnectionCloseRuleRatelimit + | rule_create_params.JavaScriptChallengeRuleRatelimit + | rule_create_params.LogRuleRatelimit + | rule_create_params.LogCustomFieldRuleRatelimit + | rule_create_params.ManagedChallengeRuleRatelimit + | rule_create_params.RedirectRuleRatelimit + | rule_create_params.RewriteRuleRatelimit + | rule_create_params.RouteRuleRatelimit + | rule_create_params.ScoreRuleRatelimit + | rule_create_params.ServeErrorRuleRatelimit + | rule_create_params.SetCacheControlRuleRatelimit + | rule_create_params.SetCacheSettingsRuleRatelimit + | rule_create_params.SetCacheTagsRuleRatelimit + | rule_create_params.SetConfigurationRuleRatelimit + | rule_create_params.SkipRuleRatelimit + | Omit = omit, + ref: 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, + ) -> RuleCreateResponse: + if not ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._post( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=await async_maybe_transform( + { + "id": id, + "action": action, + "action_parameters": action_parameters, + "description": description, + "enabled": enabled, + "exposed_credential_check": exposed_credential_check, + "expression": expression, + "logging": logging, + "position": position, + "ratelimit": ratelimit, + "ref": ref, + }, + rule_create_params.RuleCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RuleCreateResponse]._unwrapper, + ), + cast_to=cast(Type[RuleCreateResponse], ResultWrapper[RuleCreateResponse]), + ) + + async def delete( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> RuleDeleteResponse: + """ + Deletes an existing rule from an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not rule_id: + raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._delete( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}", + ruleset_id=ruleset_id, + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RuleDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[RuleDeleteResponse], ResultWrapper[RuleDeleteResponse]), + ) + + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["block"] | Omit = omit, + action_parameters: rule_edit_params.BlockRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.BlockRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.BlockRulePosition | Omit = omit, + ratelimit: rule_edit_params.BlockRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ChallengeRulePosition | Omit = omit, + ratelimit: rule_edit_params.ChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["compress_response"] | Omit = omit, + action_parameters: rule_edit_params.ResponseCompressionRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ResponseCompressionRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ResponseCompressionRulePosition | Omit = omit, + ratelimit: rule_edit_params.ResponseCompressionRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["ddos_dynamic"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.DDoSDynamicRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.DDoSDynamicRulePosition | Omit = omit, + ratelimit: rule_edit_params.DDoSDynamicRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["execute"] | Omit = omit, + action_parameters: rule_edit_params.ExecuteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ExecuteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ExecuteRulePosition | Omit = omit, + ratelimit: rule_edit_params.ExecuteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["force_connection_close"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ForceConnectionCloseRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ForceConnectionCloseRulePosition | Omit = omit, + ratelimit: rule_edit_params.ForceConnectionCloseRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["js_challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.JavaScriptChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.JavaScriptChallengeRulePosition | Omit = omit, + ratelimit: rule_edit_params.JavaScriptChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["log"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.LogRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.LogRulePosition | Omit = omit, + ratelimit: rule_edit_params.LogRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["log_custom_field"] | Omit = omit, + action_parameters: rule_edit_params.LogCustomFieldRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.LogCustomFieldRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.LogCustomFieldRulePosition | Omit = omit, + ratelimit: rule_edit_params.LogCustomFieldRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["managed_challenge"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ManagedChallengeRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ManagedChallengeRulePosition | Omit = omit, + ratelimit: rule_edit_params.ManagedChallengeRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["redirect"] | Omit = omit, + action_parameters: rule_edit_params.RedirectRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.RedirectRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.RedirectRulePosition | Omit = omit, + ratelimit: rule_edit_params.RedirectRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["rewrite"] | Omit = omit, + action_parameters: rule_edit_params.RewriteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.RewriteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.RewriteRulePosition | Omit = omit, + ratelimit: rule_edit_params.RewriteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["route"] | Omit = omit, + action_parameters: rule_edit_params.RouteRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.RouteRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.RouteRulePosition | Omit = omit, + ratelimit: rule_edit_params.RouteRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["score"] | Omit = omit, + action_parameters: rule_edit_params.ScoreRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ScoreRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ScoreRulePosition | Omit = omit, + ratelimit: rule_edit_params.ScoreRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["serve_error"] | Omit = omit, + action_parameters: rule_edit_params.ServeErrorRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.ServeErrorRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.ServeErrorRulePosition | Omit = omit, + ratelimit: rule_edit_params.ServeErrorRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_control"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheControlRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheControlRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheControlRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheControlRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_settings"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheSettingsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheSettingsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheSettingsRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheSettingsRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_cache_tags"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheTagsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheTagsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheTagsRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheTagsRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["set_config"] | Omit = omit, + action_parameters: rule_edit_params.SetConfigurationRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetConfigurationRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetConfigurationRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetConfigurationRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["skip"] | Omit = omit, + action_parameters: rule_edit_params.SkipRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SkipRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SkipRulePosition | Omit = omit, + ratelimit: rule_edit_params.SkipRuleRatelimit | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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(["ruleset_id"]) + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + id: str | Omit = omit, + action: Literal["block"] + | Literal["challenge"] + | Literal["compress_response"] + | Literal["ddos_dynamic"] + | Literal["execute"] + | Literal["force_connection_close"] + | Literal["js_challenge"] + | Literal["log"] + | Literal["log_custom_field"] + | Literal["managed_challenge"] + | Literal["redirect"] + | Literal["rewrite"] + | Literal["route"] + | Literal["score"] + | Literal["serve_error"] + | Literal["set_cache_control"] + | Literal["set_cache_settings"] + | Literal["set_cache_tags"] + | Literal["set_config"] + | Literal["skip"] + | Omit = omit, + action_parameters: rule_edit_params.BlockRuleActionParameters + | object + | rule_edit_params.ResponseCompressionRuleActionParameters + | rule_edit_params.ExecuteRuleActionParameters + | rule_edit_params.LogCustomFieldRuleActionParameters + | rule_edit_params.RedirectRuleActionParameters + | rule_edit_params.RewriteRuleActionParameters + | rule_edit_params.RouteRuleActionParameters + | rule_edit_params.ScoreRuleActionParameters + | rule_edit_params.ServeErrorRuleActionParameters + | rule_edit_params.SetCacheControlRuleActionParameters + | rule_edit_params.SetCacheSettingsRuleActionParameters + | rule_edit_params.SetCacheTagsRuleActionParameters + | rule_edit_params.SetConfigurationRuleActionParameters + | rule_edit_params.SkipRuleActionParameters + | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.BlockRuleExposedCredentialCheck + | rule_edit_params.ChallengeRuleExposedCredentialCheck + | rule_edit_params.ResponseCompressionRuleExposedCredentialCheck + | rule_edit_params.DDoSDynamicRuleExposedCredentialCheck + | rule_edit_params.ExecuteRuleExposedCredentialCheck + | rule_edit_params.ForceConnectionCloseRuleExposedCredentialCheck + | rule_edit_params.JavaScriptChallengeRuleExposedCredentialCheck + | rule_edit_params.LogRuleExposedCredentialCheck + | rule_edit_params.LogCustomFieldRuleExposedCredentialCheck + | rule_edit_params.ManagedChallengeRuleExposedCredentialCheck + | rule_edit_params.RedirectRuleExposedCredentialCheck + | rule_edit_params.RewriteRuleExposedCredentialCheck + | rule_edit_params.RouteRuleExposedCredentialCheck + | rule_edit_params.ScoreRuleExposedCredentialCheck + | rule_edit_params.ServeErrorRuleExposedCredentialCheck + | rule_edit_params.SetCacheControlRuleExposedCredentialCheck + | rule_edit_params.SetCacheSettingsRuleExposedCredentialCheck + | rule_edit_params.SetCacheTagsRuleExposedCredentialCheck + | rule_edit_params.SetConfigurationRuleExposedCredentialCheck + | rule_edit_params.SkipRuleExposedCredentialCheck + | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.BlockRulePosition + | rule_edit_params.ChallengeRulePosition + | rule_edit_params.ResponseCompressionRulePosition + | rule_edit_params.DDoSDynamicRulePosition + | rule_edit_params.ExecuteRulePosition + | rule_edit_params.ForceConnectionCloseRulePosition + | rule_edit_params.JavaScriptChallengeRulePosition + | rule_edit_params.LogRulePosition + | rule_edit_params.LogCustomFieldRulePosition + | rule_edit_params.ManagedChallengeRulePosition + | rule_edit_params.RedirectRulePosition + | rule_edit_params.RewriteRulePosition + | rule_edit_params.RouteRulePosition + | rule_edit_params.ScoreRulePosition + | rule_edit_params.ServeErrorRulePosition + | rule_edit_params.SetCacheControlRulePosition + | rule_edit_params.SetCacheSettingsRulePosition + | rule_edit_params.SetCacheTagsRulePosition + | rule_edit_params.SetConfigurationRulePosition + | rule_edit_params.SkipRulePosition + | Omit = omit, + ratelimit: rule_edit_params.BlockRuleRatelimit + | rule_edit_params.ChallengeRuleRatelimit + | rule_edit_params.ResponseCompressionRuleRatelimit + | rule_edit_params.DDoSDynamicRuleRatelimit + | rule_edit_params.ExecuteRuleRatelimit + | rule_edit_params.ForceConnectionCloseRuleRatelimit + | rule_edit_params.JavaScriptChallengeRuleRatelimit + | rule_edit_params.LogRuleRatelimit + | rule_edit_params.LogCustomFieldRuleRatelimit + | rule_edit_params.ManagedChallengeRuleRatelimit + | rule_edit_params.RedirectRuleRatelimit + | rule_edit_params.RewriteRuleRatelimit + | rule_edit_params.RouteRuleRatelimit + | rule_edit_params.ScoreRuleRatelimit + | rule_edit_params.ServeErrorRuleRatelimit + | rule_edit_params.SetCacheControlRuleRatelimit + | rule_edit_params.SetCacheSettingsRuleRatelimit + | rule_edit_params.SetCacheTagsRuleRatelimit + | rule_edit_params.SetConfigurationRuleRatelimit + | rule_edit_params.SkipRuleRatelimit + | Omit = omit, + ref: 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, + ) -> RuleEditResponse: + if not ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not rule_id: + raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._patch( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}", + ruleset_id=ruleset_id, + rule_id=rule_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=await async_maybe_transform( + { + "id": id, + "action": action, + "action_parameters": action_parameters, + "description": description, + "enabled": enabled, + "exposed_credential_check": exposed_credential_check, + "expression": expression, + "logging": logging, + "position": position, + "ratelimit": ratelimit, + "ref": ref, + }, + rule_edit_params.RuleEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RuleEditResponse]._unwrapper, + ), + cast_to=cast(Type[RuleEditResponse], ResultWrapper[RuleEditResponse]), + ) + + +class RulesResourceWithRawResponse: + def __init__(self, rules: RulesResource) -> None: + self._rules = rules + + self.create = to_raw_response_wrapper( + rules.create, + ) + self.delete = to_raw_response_wrapper( + rules.delete, + ) + self.edit = to_raw_response_wrapper( + rules.edit, + ) + + +class AsyncRulesResourceWithRawResponse: + def __init__(self, rules: AsyncRulesResource) -> None: + self._rules = rules + + self.create = async_to_raw_response_wrapper( + rules.create, + ) + self.delete = async_to_raw_response_wrapper( + rules.delete, + ) + self.edit = async_to_raw_response_wrapper( + rules.edit, + ) + + +class RulesResourceWithStreamingResponse: + def __init__(self, rules: RulesResource) -> None: + self._rules = rules + + self.create = to_streamed_response_wrapper( + rules.create, + ) + self.delete = to_streamed_response_wrapper( + rules.delete, + ) + self.edit = to_streamed_response_wrapper( + rules.edit, + ) + + +class AsyncRulesResourceWithStreamingResponse: + def __init__(self, rules: AsyncRulesResource) -> None: + self._rules = rules + + self.create = async_to_streamed_response_wrapper( + rules.create, + ) + self.delete = async_to_streamed_response_wrapper( + rules.delete, + ) + self.edit = async_to_streamed_response_wrapper( + rules.edit, + ) diff --git a/src/cloudflare/resources/rulesets/rulesets.py b/src/cloudflare/resources/rulesets/rulesets.py new file mode 100644 index 00000000000..9f35e97ba41 --- /dev/null +++ b/src/cloudflare/resources/rulesets/rulesets.py @@ -0,0 +1,1008 @@ +# 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 .rules import ( + RulesResource, + AsyncRulesResource, + RulesResourceWithRawResponse, + AsyncRulesResourceWithRawResponse, + RulesResourceWithStreamingResponse, + AsyncRulesResourceWithStreamingResponse, +) +from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given +from ..._utils import path_template, maybe_transform, async_maybe_transform +from .versions import ( + VersionsResource, + AsyncVersionsResource, + VersionsResourceWithRawResponse, + AsyncVersionsResourceWithRawResponse, + VersionsResourceWithStreamingResponse, + AsyncVersionsResourceWithStreamingResponse, +) +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 SyncCursorPagination, AsyncCursorPagination +from .phases.phases import ( + PhasesResource, + AsyncPhasesResource, + PhasesResourceWithRawResponse, + AsyncPhasesResourceWithRawResponse, + PhasesResourceWithStreamingResponse, + AsyncPhasesResourceWithStreamingResponse, +) +from ..._base_client import AsyncPaginator, make_request_options +from ...types.rulesets import Kind, Phase, ruleset_list_params, ruleset_create_params, ruleset_update_params +from ...types.rulesets.kind import Kind +from ...types.rulesets.phase import Phase +from ...types.rulesets.ruleset_get_response import RulesetGetResponse +from ...types.rulesets.ruleset_list_response import RulesetListResponse +from ...types.rulesets.ruleset_create_response import RulesetCreateResponse +from ...types.rulesets.ruleset_update_response import RulesetUpdateResponse + +__all__ = ["RulesetsResource", "AsyncRulesetsResource"] + + +class RulesetsResource(SyncAPIResource): + @cached_property + def phases(self) -> PhasesResource: + return PhasesResource(self._client) + + @cached_property + def rules(self) -> RulesResource: + return RulesResource(self._client) + + @cached_property + def versions(self) -> VersionsResource: + return VersionsResource(self._client) + + @cached_property + def with_raw_response(self) -> RulesetsResourceWithRawResponse: + """ + 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 RulesetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RulesetsResourceWithStreamingResponse: + """ + 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 RulesetsResourceWithStreamingResponse(self) + + def create( + self, + *, + kind: Kind, + name: str, + phase: Phase, + account_id: str | None = None, + zone_id: str | None = None, + description: str | Omit = omit, + rules: Iterable[ruleset_create_params.Rule] | 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, + ) -> RulesetCreateResponse: + """ + Creates a ruleset. + + Args: + kind: The kind of the ruleset. + + name: The human-readable name of the ruleset. + + phase: The phase of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + description: An informative description of the ruleset. + + rules: The list of rules in the ruleset. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._post( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=maybe_transform( + { + "kind": kind, + "name": name, + "phase": phase, + "description": description, + "rules": rules, + }, + ruleset_create_params.RulesetCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RulesetCreateResponse]._unwrapper, + ), + cast_to=cast(Type[RulesetCreateResponse], ResultWrapper[RulesetCreateResponse]), + ) + + def update( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + description: str | Omit = omit, + kind: Kind | Omit = omit, + name: str | Omit = omit, + phase: Phase | Omit = omit, + rules: Iterable[ruleset_update_params.Rule] | 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, + ) -> RulesetUpdateResponse: + """ + Updates an account or zone ruleset, creating a new version. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + description: An informative description of the ruleset. + + kind: The kind of the ruleset. + + name: The human-readable name of the ruleset. + + phase: The phase of the ruleset. + + rules: The list of rules in the ruleset. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._put( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=maybe_transform( + { + "description": description, + "kind": kind, + "name": name, + "phase": phase, + "rules": rules, + }, + ruleset_update_params.RulesetUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RulesetUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[RulesetUpdateResponse], ResultWrapper[RulesetUpdateResponse]), + ) + + def list( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + cursor: str | 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, + ) -> SyncCursorPagination[RulesetListResponse]: + """ + Fetches all rulesets. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + cursor: The cursor to use for the next page. + + per_page: The number of rulesets to return 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=SyncCursorPagination[RulesetListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "per_page": per_page, + }, + ruleset_list_params.RulesetListParams, + ), + ), + model=RulesetListResponse, + ) + + def delete( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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: + """ + Deletes all versions of an existing account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + def get( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> RulesetGetResponse: + """ + Fetches the latest version of an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RulesetGetResponse]._unwrapper, + ), + cast_to=cast(Type[RulesetGetResponse], ResultWrapper[RulesetGetResponse]), + ) + + +class AsyncRulesetsResource(AsyncAPIResource): + @cached_property + def phases(self) -> AsyncPhasesResource: + return AsyncPhasesResource(self._client) + + @cached_property + def rules(self) -> AsyncRulesResource: + return AsyncRulesResource(self._client) + + @cached_property + def versions(self) -> AsyncVersionsResource: + return AsyncVersionsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncRulesetsResourceWithRawResponse: + """ + 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 AsyncRulesetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRulesetsResourceWithStreamingResponse: + """ + 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 AsyncRulesetsResourceWithStreamingResponse(self) + + async def create( + self, + *, + kind: Kind, + name: str, + phase: Phase, + account_id: str | None = None, + zone_id: str | None = None, + description: str | Omit = omit, + rules: Iterable[ruleset_create_params.Rule] | 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, + ) -> RulesetCreateResponse: + """ + Creates a ruleset. + + Args: + kind: The kind of the ruleset. + + name: The human-readable name of the ruleset. + + phase: The phase of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + description: An informative description of the ruleset. + + rules: The list of rules in the ruleset. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._post( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=await async_maybe_transform( + { + "kind": kind, + "name": name, + "phase": phase, + "description": description, + "rules": rules, + }, + ruleset_create_params.RulesetCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RulesetCreateResponse]._unwrapper, + ), + cast_to=cast(Type[RulesetCreateResponse], ResultWrapper[RulesetCreateResponse]), + ) + + async def update( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + description: str | Omit = omit, + kind: Kind | Omit = omit, + name: str | Omit = omit, + phase: Phase | Omit = omit, + rules: Iterable[ruleset_update_params.Rule] | 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, + ) -> RulesetUpdateResponse: + """ + Updates an account or zone ruleset, creating a new version. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + description: An informative description of the ruleset. + + kind: The kind of the ruleset. + + name: The human-readable name of the ruleset. + + phase: The phase of the ruleset. + + rules: The list of rules in the ruleset. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._put( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=await async_maybe_transform( + { + "description": description, + "kind": kind, + "name": name, + "phase": phase, + "rules": rules, + }, + ruleset_update_params.RulesetUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RulesetUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[RulesetUpdateResponse], ResultWrapper[RulesetUpdateResponse]), + ) + + def list( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + cursor: str | 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[RulesetListResponse, AsyncCursorPagination[RulesetListResponse]]: + """ + Fetches all rulesets. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + cursor: The cursor to use for the next page. + + per_page: The number of rulesets to return 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=AsyncCursorPagination[RulesetListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "per_page": per_page, + }, + ruleset_list_params.RulesetListParams, + ), + ), + model=RulesetListResponse, + ) + + async def delete( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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: + """ + Deletes all versions of an existing account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + async def get( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> RulesetGetResponse: + """ + Fetches the latest version of an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RulesetGetResponse]._unwrapper, + ), + cast_to=cast(Type[RulesetGetResponse], ResultWrapper[RulesetGetResponse]), + ) + + +class RulesetsResourceWithRawResponse: + def __init__(self, rulesets: RulesetsResource) -> None: + self._rulesets = rulesets + + self.create = to_raw_response_wrapper( + rulesets.create, + ) + self.update = to_raw_response_wrapper( + rulesets.update, + ) + self.list = to_raw_response_wrapper( + rulesets.list, + ) + self.delete = to_raw_response_wrapper( + rulesets.delete, + ) + self.get = to_raw_response_wrapper( + rulesets.get, + ) + + @cached_property + def phases(self) -> PhasesResourceWithRawResponse: + return PhasesResourceWithRawResponse(self._rulesets.phases) + + @cached_property + def rules(self) -> RulesResourceWithRawResponse: + return RulesResourceWithRawResponse(self._rulesets.rules) + + @cached_property + def versions(self) -> VersionsResourceWithRawResponse: + return VersionsResourceWithRawResponse(self._rulesets.versions) + + +class AsyncRulesetsResourceWithRawResponse: + def __init__(self, rulesets: AsyncRulesetsResource) -> None: + self._rulesets = rulesets + + self.create = async_to_raw_response_wrapper( + rulesets.create, + ) + self.update = async_to_raw_response_wrapper( + rulesets.update, + ) + self.list = async_to_raw_response_wrapper( + rulesets.list, + ) + self.delete = async_to_raw_response_wrapper( + rulesets.delete, + ) + self.get = async_to_raw_response_wrapper( + rulesets.get, + ) + + @cached_property + def phases(self) -> AsyncPhasesResourceWithRawResponse: + return AsyncPhasesResourceWithRawResponse(self._rulesets.phases) + + @cached_property + def rules(self) -> AsyncRulesResourceWithRawResponse: + return AsyncRulesResourceWithRawResponse(self._rulesets.rules) + + @cached_property + def versions(self) -> AsyncVersionsResourceWithRawResponse: + return AsyncVersionsResourceWithRawResponse(self._rulesets.versions) + + +class RulesetsResourceWithStreamingResponse: + def __init__(self, rulesets: RulesetsResource) -> None: + self._rulesets = rulesets + + self.create = to_streamed_response_wrapper( + rulesets.create, + ) + self.update = to_streamed_response_wrapper( + rulesets.update, + ) + self.list = to_streamed_response_wrapper( + rulesets.list, + ) + self.delete = to_streamed_response_wrapper( + rulesets.delete, + ) + self.get = to_streamed_response_wrapper( + rulesets.get, + ) + + @cached_property + def phases(self) -> PhasesResourceWithStreamingResponse: + return PhasesResourceWithStreamingResponse(self._rulesets.phases) + + @cached_property + def rules(self) -> RulesResourceWithStreamingResponse: + return RulesResourceWithStreamingResponse(self._rulesets.rules) + + @cached_property + def versions(self) -> VersionsResourceWithStreamingResponse: + return VersionsResourceWithStreamingResponse(self._rulesets.versions) + + +class AsyncRulesetsResourceWithStreamingResponse: + def __init__(self, rulesets: AsyncRulesetsResource) -> None: + self._rulesets = rulesets + + self.create = async_to_streamed_response_wrapper( + rulesets.create, + ) + self.update = async_to_streamed_response_wrapper( + rulesets.update, + ) + self.list = async_to_streamed_response_wrapper( + rulesets.list, + ) + self.delete = async_to_streamed_response_wrapper( + rulesets.delete, + ) + self.get = async_to_streamed_response_wrapper( + rulesets.get, + ) + + @cached_property + def phases(self) -> AsyncPhasesResourceWithStreamingResponse: + return AsyncPhasesResourceWithStreamingResponse(self._rulesets.phases) + + @cached_property + def rules(self) -> AsyncRulesResourceWithStreamingResponse: + return AsyncRulesResourceWithStreamingResponse(self._rulesets.rules) + + @cached_property + def versions(self) -> AsyncVersionsResourceWithStreamingResponse: + return AsyncVersionsResourceWithStreamingResponse(self._rulesets.versions) diff --git a/src/cloudflare/resources/rulesets/versions.py b/src/cloudflare/resources/rulesets/versions.py new file mode 100644 index 00000000000..d3833f2fe66 --- /dev/null +++ b/src/cloudflare/resources/rulesets/versions.py @@ -0,0 +1,535 @@ +# 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, NoneType, NotGiven, not_given +from ..._utils import path_template +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.rulesets.version_get_response import VersionGetResponse +from ...types.rulesets.version_list_response import VersionListResponse + +__all__ = ["VersionsResource", "AsyncVersionsResource"] + + +class VersionsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> VersionsResourceWithRawResponse: + """ + 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 VersionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> VersionsResourceWithStreamingResponse: + """ + 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 VersionsResourceWithStreamingResponse(self) + + def list( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[VersionListResponse]: + """ + Fetches the versions of an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/versions", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=SyncSinglePage[VersionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=VersionListResponse, + ) + + def delete( + self, + ruleset_version: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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: + """ + Deletes an existing version of an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + ruleset_version: The version of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not ruleset_version: + raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/versions/{ruleset_version}", + ruleset_id=ruleset_id, + ruleset_version=ruleset_version, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + def get( + self, + ruleset_version: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VersionGetResponse: + """ + Fetches a specific version of an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + ruleset_version: The version of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not ruleset_version: + raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/versions/{ruleset_version}", + ruleset_id=ruleset_id, + ruleset_version=ruleset_version, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[VersionGetResponse]._unwrapper, + ), + cast_to=cast(Type[VersionGetResponse], ResultWrapper[VersionGetResponse]), + ) + + +class AsyncVersionsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncVersionsResourceWithRawResponse: + """ + 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 AsyncVersionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncVersionsResourceWithStreamingResponse: + """ + 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 AsyncVersionsResourceWithStreamingResponse(self) + + def list( + self, + ruleset_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[VersionListResponse, AsyncSinglePage[VersionListResponse]]: + """ + Fetches the versions of an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/versions", + ruleset_id=ruleset_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=AsyncSinglePage[VersionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=VersionListResponse, + ) + + async def delete( + self, + ruleset_version: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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: + """ + Deletes an existing version of an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + ruleset_version: The version of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not ruleset_version: + raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/versions/{ruleset_version}", + ruleset_id=ruleset_id, + ruleset_version=ruleset_version, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + async def get( + self, + ruleset_version: str, + *, + ruleset_id: str, + account_id: str | None = None, + zone_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VersionGetResponse: + """ + Fetches a specific version of an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + ruleset_version: The version of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not ruleset_version: + raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/versions/{ruleset_version}", + ruleset_id=ruleset_id, + ruleset_version=ruleset_version, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[VersionGetResponse]._unwrapper, + ), + cast_to=cast(Type[VersionGetResponse], ResultWrapper[VersionGetResponse]), + ) + + +class VersionsResourceWithRawResponse: + def __init__(self, versions: VersionsResource) -> None: + self._versions = versions + + self.list = to_raw_response_wrapper( + versions.list, + ) + self.delete = to_raw_response_wrapper( + versions.delete, + ) + self.get = to_raw_response_wrapper( + versions.get, + ) + + +class AsyncVersionsResourceWithRawResponse: + def __init__(self, versions: AsyncVersionsResource) -> None: + self._versions = versions + + self.list = async_to_raw_response_wrapper( + versions.list, + ) + self.delete = async_to_raw_response_wrapper( + versions.delete, + ) + self.get = async_to_raw_response_wrapper( + versions.get, + ) + + +class VersionsResourceWithStreamingResponse: + def __init__(self, versions: VersionsResource) -> None: + self._versions = versions + + self.list = to_streamed_response_wrapper( + versions.list, + ) + self.delete = to_streamed_response_wrapper( + versions.delete, + ) + self.get = to_streamed_response_wrapper( + versions.get, + ) + + +class AsyncVersionsResourceWithStreamingResponse: + def __init__(self, versions: AsyncVersionsResource) -> None: + self._versions = versions + + self.list = async_to_streamed_response_wrapper( + versions.list, + ) + self.delete = async_to_streamed_response_wrapper( + versions.delete, + ) + self.get = async_to_streamed_response_wrapper( + versions.get, + ) diff --git a/src/cloudflare/resources/rum/api.md b/src/cloudflare/resources/rum/api.md new file mode 100644 index 00000000000..108e74c1038 --- /dev/null +++ b/src/cloudflare/resources/rum/api.md @@ -0,0 +1,38 @@ +# 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] diff --git a/src/cloudflare/resources/rum/rules.py b/src/cloudflare/resources/rum/rules.py index d46b2bf9f63..7d2975dd554 100644 --- a/src/cloudflare/resources/rum/rules.py +++ b/src/cloudflare/resources/rum/rules.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def create( self, ruleset_id: str, *, - account_id: str, + account_id: str | None = None, host: str | Omit = omit, inclusive: bool | Omit = omit, is_paused: bool | Omit = omit, @@ -83,12 +83,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") return self._post( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rule", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rule", account_id=account_id, ruleset_id=ruleset_id + ), body=maybe_transform( { "host": host, @@ -112,7 +116,7 @@ def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, ruleset_id: str, host: str | Omit = omit, inclusive: bool | Omit = omit, @@ -147,6 +151,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: @@ -154,7 +160,12 @@ def update( if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._put( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}", + account_id=account_id, + ruleset_id=ruleset_id, + rule_id=rule_id, + ), body=maybe_transform( { "host": host, @@ -178,7 +189,7 @@ def list( self, ruleset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -202,12 +213,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") return self._get( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rules", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rules", account_id=account_id, ruleset_id=ruleset_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -222,7 +237,7 @@ def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, ruleset_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. @@ -249,6 +264,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: @@ -256,7 +273,12 @@ def delete( if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._delete( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}", + account_id=account_id, + ruleset_id=ruleset_id, + rule_id=rule_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -271,7 +293,7 @@ def bulk_create( self, ruleset_id: str, *, - account_id: str, + account_id: str | None = None, delete_rules: SequenceNotStr[str] | Omit = omit, rules: Iterable[rule_bulk_create_params.Rule] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -301,12 +323,16 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") return self._post( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rules", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rules", account_id=account_id, ruleset_id=ruleset_id + ), body=maybe_transform( { "delete_rules": delete_rules, @@ -349,7 +375,7 @@ async def create( self, ruleset_id: str, *, - account_id: str, + account_id: str | None = None, host: str | Omit = omit, inclusive: bool | Omit = omit, is_paused: bool | Omit = omit, @@ -381,12 +407,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") return await self._post( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rule", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rule", account_id=account_id, ruleset_id=ruleset_id + ), body=await async_maybe_transform( { "host": host, @@ -410,7 +440,7 @@ async def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, ruleset_id: str, host: str | Omit = omit, inclusive: bool | Omit = omit, @@ -445,6 +475,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: @@ -452,7 +484,12 @@ async def update( if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._put( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}", + account_id=account_id, + ruleset_id=ruleset_id, + rule_id=rule_id, + ), body=await async_maybe_transform( { "host": host, @@ -476,7 +513,7 @@ async def list( self, ruleset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -500,12 +537,16 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") return await self._get( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rules", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rules", account_id=account_id, ruleset_id=ruleset_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -520,7 +561,7 @@ async def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, ruleset_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. @@ -547,6 +588,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: @@ -554,7 +597,12 @@ async def delete( if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._delete( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}", + account_id=account_id, + ruleset_id=ruleset_id, + rule_id=rule_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -569,7 +617,7 @@ async def bulk_create( self, ruleset_id: str, *, - account_id: str, + account_id: str | None = None, delete_rules: SequenceNotStr[str] | Omit = omit, rules: Iterable[rule_bulk_create_params.Rule] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -599,12 +647,16 @@ async def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") return await self._post( - f"/accounts/{account_id}/rum/v2/{ruleset_id}/rules", + path_template( + "/accounts/{account_id}/rum/v2/{ruleset_id}/rules", account_id=account_id, ruleset_id=ruleset_id + ), body=await async_maybe_transform( { "delete_rules": delete_rules, diff --git a/src/cloudflare/resources/rum/site_info.py b/src/cloudflare/resources/rum/site_info.py index 0f4ca671a88..84cb9b95fd6 100644 --- a/src/cloudflare/resources/rum/site_info.py +++ b/src/cloudflare/resources/rum/site_info.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> SiteInfoResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, auto_install: bool | Omit = omit, host: str | Omit = omit, zone_tag: str | Omit = omit, @@ -82,10 +82,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/rum/site_info", + path_template("/accounts/{account_id}/rum/site_info", account_id=account_id), body=maybe_transform( { "auto_install": auto_install, @@ -108,7 +110,7 @@ def update( self, site_id: str, *, - account_id: str, + account_id: str | None = None, auto_install: bool | Omit = omit, enabled: bool | Omit = omit, host: str | Omit = omit, @@ -150,12 +152,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._put( - f"/accounts/{account_id}/rum/site_info/{site_id}", + path_template("/accounts/{account_id}/rum/site_info/{site_id}", account_id=account_id, site_id=site_id), body=maybe_transform( { "auto_install": auto_install, @@ -179,7 +183,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, order_by: Literal["host", "created"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -210,10 +214,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/rum/site_info/list", + path_template("/accounts/{account_id}/rum/site_info/list", account_id=account_id), page=SyncV4PagePaginationArray[Site], options=make_request_options( extra_headers=extra_headers, @@ -236,7 +242,7 @@ def delete( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -260,12 +266,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._delete( - f"/accounts/{account_id}/rum/site_info/{site_id}", + path_template("/accounts/{account_id}/rum/site_info/{site_id}", account_id=account_id, site_id=site_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -280,7 +288,7 @@ def get( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -304,12 +312,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return self._get( - f"/accounts/{account_id}/rum/site_info/{site_id}", + path_template("/accounts/{account_id}/rum/site_info/{site_id}", account_id=account_id, site_id=site_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -344,7 +354,7 @@ def with_streaming_response(self) -> AsyncSiteInfoResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, auto_install: bool | Omit = omit, host: str | Omit = omit, zone_tag: str | Omit = omit, @@ -376,10 +386,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/rum/site_info", + path_template("/accounts/{account_id}/rum/site_info", account_id=account_id), body=await async_maybe_transform( { "auto_install": auto_install, @@ -402,7 +414,7 @@ async def update( self, site_id: str, *, - account_id: str, + account_id: str | None = None, auto_install: bool | Omit = omit, enabled: bool | Omit = omit, host: str | Omit = omit, @@ -444,12 +456,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return await self._put( - f"/accounts/{account_id}/rum/site_info/{site_id}", + path_template("/accounts/{account_id}/rum/site_info/{site_id}", account_id=account_id, site_id=site_id), body=await async_maybe_transform( { "auto_install": auto_install, @@ -473,7 +487,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, order_by: Literal["host", "created"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -504,10 +518,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/rum/site_info/list", + path_template("/accounts/{account_id}/rum/site_info/list", account_id=account_id), page=AsyncV4PagePaginationArray[Site], options=make_request_options( extra_headers=extra_headers, @@ -530,7 +546,7 @@ async def delete( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -554,12 +570,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return await self._delete( - f"/accounts/{account_id}/rum/site_info/{site_id}", + path_template("/accounts/{account_id}/rum/site_info/{site_id}", account_id=account_id, site_id=site_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -574,7 +592,7 @@ async def get( self, site_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -598,12 +616,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not site_id: raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") return await self._get( - f"/accounts/{account_id}/rum/site_info/{site_id}", + path_template("/accounts/{account_id}/rum/site_info/{site_id}", account_id=account_id, site_id=site_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/schema_validation/api.md b/src/cloudflare/resources/schema_validation/api.md new file mode 100644 index 00000000000..504671ccca8 --- /dev/null +++ b/src/cloudflare/resources/schema_validation/api.md @@ -0,0 +1,57 @@ +# SchemaValidation + +## Schemas + +Types: + +```python +from cloudflare.types.schema_validation import PublicSchema, SchemaDeleteResponse +``` + +Methods: + +- 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 + +## Settings + +Types: + +```python +from cloudflare.types.schema_validation import ( + SettingUpdateResponse, + SettingEditResponse, + SettingGetResponse, +) +``` + +Methods: + +- 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 + +### Operations + +Types: + +```python +from cloudflare.types.schema_validation.settings import ( + OperationUpdateResponse, + OperationListResponse, + OperationDeleteResponse, + OperationBulkEditResponse, + OperationGetResponse, +) +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/schema_validation/schemas.py b/src/cloudflare/resources/schema_validation/schemas.py index 22ed24d85c9..704927a03b9 100644 --- a/src/cloudflare/resources/schema_validation/schemas.py +++ b/src/cloudflare/resources/schema_validation/schemas.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> SchemasResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, kind: Literal["openapi_v3"], name: str, source: str, @@ -86,10 +86,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/schemas", + path_template("/zones/{zone_id}/schema_validation/schemas", zone_id=zone_id), body=maybe_transform( { "kind": kind, @@ -112,7 +114,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, omit_source: bool | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -146,10 +148,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/schemas", + path_template("/zones/{zone_id}/schema_validation/schemas", zone_id=zone_id), page=SyncV4PagePaginationArray[PublicSchema], options=make_request_options( extra_headers=extra_headers, @@ -173,7 +177,7 @@ def delete( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -199,12 +203,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 self._delete( - f"/zones/{zone_id}/schema_validation/schemas/{schema_id}", + path_template( + "/zones/{zone_id}/schema_validation/schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -219,7 +227,7 @@ def edit( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -247,12 +255,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 self._patch( - f"/zones/{zone_id}/schema_validation/schemas/{schema_id}", + path_template( + "/zones/{zone_id}/schema_validation/schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), body=maybe_transform({"validation_enabled": validation_enabled}, schema_edit_params.SchemaEditParams), options=make_request_options( extra_headers=extra_headers, @@ -268,7 +280,7 @@ def get( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -296,12 +308,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 self._get( - f"/zones/{zone_id}/schema_validation/schemas/{schema_id}", + path_template( + "/zones/{zone_id}/schema_validation/schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -337,7 +353,7 @@ def with_streaming_response(self) -> AsyncSchemasResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, kind: Literal["openapi_v3"], name: str, source: str, @@ -373,10 +389,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/schemas", + path_template("/zones/{zone_id}/schema_validation/schemas", zone_id=zone_id), body=await async_maybe_transform( { "kind": kind, @@ -399,7 +417,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, omit_source: bool | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -433,10 +451,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/schemas", + path_template("/zones/{zone_id}/schema_validation/schemas", zone_id=zone_id), page=AsyncV4PagePaginationArray[PublicSchema], options=make_request_options( extra_headers=extra_headers, @@ -460,7 +480,7 @@ async def delete( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -486,12 +506,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 await self._delete( - f"/zones/{zone_id}/schema_validation/schemas/{schema_id}", + path_template( + "/zones/{zone_id}/schema_validation/schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -506,7 +530,7 @@ async def edit( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -534,12 +558,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 await self._patch( - f"/zones/{zone_id}/schema_validation/schemas/{schema_id}", + path_template( + "/zones/{zone_id}/schema_validation/schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), body=await async_maybe_transform( {"validation_enabled": validation_enabled}, schema_edit_params.SchemaEditParams ), @@ -557,7 +585,7 @@ async def get( self, schema_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -585,12 +613,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: 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 await self._get( - f"/zones/{zone_id}/schema_validation/schemas/{schema_id}", + path_template( + "/zones/{zone_id}/schema_validation/schemas/{schema_id}", zone_id=zone_id, schema_id=schema_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/schema_validation/settings/operations.py b/src/cloudflare/resources/schema_validation/settings/operations.py index 7d0f9568591..36a6d67922b 100644 --- a/src/cloudflare/resources/schema_validation/settings/operations.py +++ b/src/cloudflare/resources/schema_validation/settings/operations.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -58,7 +58,7 @@ def update( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, mitigation_action: Optional[Literal["log", "block", "none"]], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -92,12 +92,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._put( - f"/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + path_template( + "/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + zone_id=zone_id, + operation_id=operation_id, + ), body=maybe_transform( {"mitigation_action": mitigation_action}, operation_update_params.OperationUpdateParams ), @@ -114,7 +120,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -142,10 +148,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/settings/operations", + path_template("/zones/{zone_id}/schema_validation/settings/operations", zone_id=zone_id), page=SyncV4PagePaginationArray[OperationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -167,7 +175,7 @@ def delete( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -192,12 +200,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._delete( - f"/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + path_template( + "/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + zone_id=zone_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -211,7 +225,7 @@ def delete( def bulk_edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -235,10 +249,12 @@ def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/settings/operations", + path_template("/zones/{zone_id}/schema_validation/settings/operations", zone_id=zone_id), body=maybe_transform(body, operation_bulk_edit_params.OperationBulkEditParams), options=make_request_options( extra_headers=extra_headers, @@ -254,7 +270,7 @@ def get( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -279,12 +295,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return self._get( - f"/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + path_template( + "/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + zone_id=zone_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -320,7 +342,7 @@ async def update( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, mitigation_action: Optional[Literal["log", "block", "none"]], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -354,12 +376,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._put( - f"/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + path_template( + "/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + zone_id=zone_id, + operation_id=operation_id, + ), body=await async_maybe_transform( {"mitigation_action": mitigation_action}, operation_update_params.OperationUpdateParams ), @@ -376,7 +404,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -404,10 +432,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/settings/operations", + path_template("/zones/{zone_id}/schema_validation/settings/operations", zone_id=zone_id), page=AsyncV4PagePaginationArray[OperationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -429,7 +459,7 @@ async def delete( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -454,12 +484,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._delete( - f"/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + path_template( + "/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + zone_id=zone_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -473,7 +509,7 @@ async def delete( async def bulk_edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -497,10 +533,12 @@ async def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/settings/operations", + path_template("/zones/{zone_id}/schema_validation/settings/operations", zone_id=zone_id), body=await async_maybe_transform(body, operation_bulk_edit_params.OperationBulkEditParams), options=make_request_options( extra_headers=extra_headers, @@ -516,7 +554,7 @@ async def get( self, operation_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -541,12 +579,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not operation_id: raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") return await self._get( - f"/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + path_template( + "/zones/{zone_id}/schema_validation/settings/operations/{operation_id}", + zone_id=zone_id, + operation_id=operation_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/schema_validation/settings/settings.py b/src/cloudflare/resources/schema_validation/settings/settings.py index fad14610c3a..ac44cf14e98 100644 --- a/src/cloudflare/resources/schema_validation/settings/settings.py +++ b/src/cloudflare/resources/schema_validation/settings/settings.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from .operations import ( OperationsResource, @@ -62,7 +62,7 @@ def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, validation_default_mitigation_action: Literal["none", "log", "block"], validation_override_mitigation_action: Optional[Literal["none"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -99,10 +99,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/schema_validation/settings", + path_template("/zones/{zone_id}/schema_validation/settings", zone_id=zone_id), body=maybe_transform( { "validation_default_mitigation_action": validation_default_mitigation_action, @@ -123,7 +125,7 @@ def update( def edit( self, *, - zone_id: str, + zone_id: str | None = None, validation_default_mitigation_action: Literal["none", "log", "block"] | Omit = omit, validation_override_mitigation_action: Optional[Literal["none"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -160,10 +162,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/settings", + path_template("/zones/{zone_id}/schema_validation/settings", zone_id=zone_id), body=maybe_transform( { "validation_default_mitigation_action": validation_default_mitigation_action, @@ -184,7 +188,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -206,10 +210,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/schema_validation/settings", + path_template("/zones/{zone_id}/schema_validation/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -248,7 +254,7 @@ def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, validation_default_mitigation_action: Literal["none", "log", "block"], validation_override_mitigation_action: Optional[Literal["none"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -285,10 +291,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/schema_validation/settings", + path_template("/zones/{zone_id}/schema_validation/settings", zone_id=zone_id), body=await async_maybe_transform( { "validation_default_mitigation_action": validation_default_mitigation_action, @@ -309,7 +317,7 @@ async def update( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, validation_default_mitigation_action: Literal["none", "log", "block"] | Omit = omit, validation_override_mitigation_action: Optional[Literal["none"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -346,10 +354,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/schema_validation/settings", + path_template("/zones/{zone_id}/schema_validation/settings", zone_id=zone_id), body=await async_maybe_transform( { "validation_default_mitigation_action": validation_default_mitigation_action, @@ -370,7 +380,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -392,10 +402,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/schema_validation/settings", + path_template("/zones/{zone_id}/schema_validation/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/secrets_store/api.md b/src/cloudflare/resources/secrets_store/api.md new file mode 100644 index 00000000000..ed50510966c --- /dev/null +++ b/src/cloudflare/resources/secrets_store/api.md @@ -0,0 +1,51 @@ +# SecretsStore + +## Stores + +Types: + +```python +from cloudflare.types.secrets_store import StoreCreateResponse, StoreListResponse +``` + +Methods: + +- client.secrets_store.stores.create(\*, account_id, \*\*params) -> Optional[StoreCreateResponse] +- client.secrets_store.stores.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[StoreListResponse] +- client.secrets_store.stores.delete(store_id, \*, account_id) -> object + +### Secrets + +Types: + +```python +from cloudflare.types.secrets_store.stores import ( + SecretCreateResponse, + SecretListResponse, + SecretDuplicateResponse, + SecretEditResponse, + SecretGetResponse, +) +``` + +Methods: + +- 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) -> object +- client.secrets_store.stores.secrets.bulk_delete(store_id, \*, account_id) -> object +- 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] + +## Quota + +Types: + +```python +from cloudflare.types.secrets_store import QuotaGetResponse +``` + +Methods: + +- client.secrets_store.quota.get(\*, account_id) -> Optional[QuotaGetResponse] diff --git a/src/cloudflare/resources/secrets_store/quota.py b/src/cloudflare/resources/secrets_store/quota.py index 65a7a0eff5a..a513d4791f2 100644 --- a/src/cloudflare/resources/secrets_store/quota.py +++ b/src/cloudflare/resources/secrets_store/quota.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> QuotaResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secrets_store/quota", + path_template("/accounts/{account_id}/secrets_store/quota", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -105,7 +108,7 @@ def with_streaming_response(self) -> AsyncQuotaResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,10 +130,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secrets_store/quota", + path_template("/accounts/{account_id}/secrets_store/quota", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/secrets_store/stores/secrets.py b/src/cloudflare/resources/secrets_store/stores/secrets.py index 863a66f6b90..4e1b470eb45 100644 --- a/src/cloudflare/resources/secrets_store/stores/secrets.py +++ b/src/cloudflare/resources/secrets_store/stores/secrets.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -59,7 +59,7 @@ def create( self, store_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[secret_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. @@ -84,12 +84,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") return self._get_api_list( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + account_id=account_id, + store_id=store_id, + ), page=SyncSinglePage[SecretCreateResponse], body=maybe_transform(body, Iterable[secret_create_params.Body]), options=make_request_options( @@ -103,7 +109,7 @@ def list( self, store_id: str, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["name", "comment", "created", "modified", "status"] | Omit = omit, page: int | Omit = omit, @@ -145,12 +151,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") return self._get_api_list( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + account_id=account_id, + store_id=store_id, + ), page=SyncV4PagePaginationArray[SecretListResponse], options=make_request_options( extra_headers=extra_headers, @@ -176,7 +188,7 @@ def delete( self, secret_id: str, *, - account_id: str, + account_id: str | None = None, store_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. @@ -203,6 +215,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: @@ -210,7 +224,12 @@ def delete( if not secret_id: raise ValueError(f"Expected a non-empty value for `secret_id` but received {secret_id!r}") return self._delete( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + account_id=account_id, + store_id=store_id, + secret_id=secret_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -225,7 +244,7 @@ def bulk_delete( self, store_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -249,12 +268,18 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") return self._delete( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + account_id=account_id, + store_id=store_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -269,7 +294,7 @@ def duplicate( self, secret_id: str, *, - account_id: str, + account_id: str | None = None, store_id: str, name: str, scopes: SequenceNotStr[str], @@ -305,6 +330,8 @@ def duplicate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: @@ -312,7 +339,12 @@ def duplicate( if not secret_id: raise ValueError(f"Expected a non-empty value for `secret_id` but received {secret_id!r}") return self._post( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}/duplicate", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}/duplicate", + account_id=account_id, + store_id=store_id, + secret_id=secret_id, + ), body=maybe_transform( { "name": name, @@ -335,7 +367,7 @@ def edit( self, secret_id: str, *, - account_id: str, + account_id: str | None = None, store_id: str, comment: str | Omit = omit, scopes: SequenceNotStr[str] | Omit = omit, @@ -372,6 +404,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: @@ -379,7 +413,12 @@ def edit( if not secret_id: raise ValueError(f"Expected a non-empty value for `secret_id` but received {secret_id!r}") return self._patch( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + account_id=account_id, + store_id=store_id, + secret_id=secret_id, + ), body=maybe_transform( { "comment": comment, @@ -402,7 +441,7 @@ def get( self, secret_id: str, *, - account_id: str, + account_id: str | None = None, store_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. @@ -429,6 +468,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: @@ -436,7 +477,12 @@ def get( if not secret_id: raise ValueError(f"Expected a non-empty value for `secret_id` but received {secret_id!r}") return self._get( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + account_id=account_id, + store_id=store_id, + secret_id=secret_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -472,7 +518,7 @@ def create( self, store_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[secret_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. @@ -497,12 +543,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") return self._get_api_list( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + account_id=account_id, + store_id=store_id, + ), page=AsyncSinglePage[SecretCreateResponse], body=maybe_transform(body, Iterable[secret_create_params.Body]), options=make_request_options( @@ -516,7 +568,7 @@ def list( self, store_id: str, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["name", "comment", "created", "modified", "status"] | Omit = omit, page: int | Omit = omit, @@ -558,12 +610,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") return self._get_api_list( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + account_id=account_id, + store_id=store_id, + ), page=AsyncV4PagePaginationArray[SecretListResponse], options=make_request_options( extra_headers=extra_headers, @@ -589,7 +647,7 @@ async def delete( self, secret_id: str, *, - account_id: str, + account_id: str | None = None, store_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. @@ -616,6 +674,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: @@ -623,7 +683,12 @@ async def delete( if not secret_id: raise ValueError(f"Expected a non-empty value for `secret_id` but received {secret_id!r}") return await self._delete( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + account_id=account_id, + store_id=store_id, + secret_id=secret_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -638,7 +703,7 @@ async def bulk_delete( self, store_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -662,12 +727,18 @@ async def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") return await self._delete( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets", + account_id=account_id, + store_id=store_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -682,7 +753,7 @@ async def duplicate( self, secret_id: str, *, - account_id: str, + account_id: str | None = None, store_id: str, name: str, scopes: SequenceNotStr[str], @@ -718,6 +789,8 @@ async def duplicate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: @@ -725,7 +798,12 @@ async def duplicate( if not secret_id: raise ValueError(f"Expected a non-empty value for `secret_id` but received {secret_id!r}") return await self._post( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}/duplicate", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}/duplicate", + account_id=account_id, + store_id=store_id, + secret_id=secret_id, + ), body=await async_maybe_transform( { "name": name, @@ -748,7 +826,7 @@ async def edit( self, secret_id: str, *, - account_id: str, + account_id: str | None = None, store_id: str, comment: str | Omit = omit, scopes: SequenceNotStr[str] | Omit = omit, @@ -785,6 +863,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: @@ -792,7 +872,12 @@ async def edit( if not secret_id: raise ValueError(f"Expected a non-empty value for `secret_id` but received {secret_id!r}") return await self._patch( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + account_id=account_id, + store_id=store_id, + secret_id=secret_id, + ), body=await async_maybe_transform( { "comment": comment, @@ -815,7 +900,7 @@ async def get( self, secret_id: str, *, - account_id: str, + account_id: str | None = None, store_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. @@ -842,6 +927,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: @@ -849,7 +936,12 @@ async def get( if not secret_id: raise ValueError(f"Expected a non-empty value for `secret_id` but received {secret_id!r}") return await self._get( - f"/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}", + account_id=account_id, + store_id=store_id, + secret_id=secret_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/secrets_store/stores/stores.py b/src/cloudflare/resources/secrets_store/stores/stores.py index 6c297bd7ff9..2e4edb25523 100644 --- a/src/cloudflare/resources/secrets_store/stores/stores.py +++ b/src/cloudflare/resources/secrets_store/stores/stores.py @@ -16,7 +16,7 @@ AsyncSecretsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -62,7 +62,7 @@ def with_streaming_response(self) -> StoresResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -87,10 +87,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secrets_store/stores", + path_template("/accounts/{account_id}/secrets_store/stores", account_id=account_id), body=maybe_transform({"name": name}, store_create_params.StoreCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -105,7 +107,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["name", "comment", "created", "modified", "status"] | Omit = omit, page: int | Omit = omit, @@ -139,10 +141,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secrets_store/stores", + path_template("/accounts/{account_id}/secrets_store/stores", account_id=account_id), page=SyncV4PagePaginationArray[StoreListResponse], options=make_request_options( extra_headers=extra_headers, @@ -166,7 +170,7 @@ def delete( self, store_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -190,12 +194,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") return self._delete( - f"/accounts/{account_id}/secrets_store/stores/{store_id}", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}", account_id=account_id, store_id=store_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -234,7 +242,7 @@ def with_streaming_response(self) -> AsyncStoresResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -259,10 +267,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secrets_store/stores", + path_template("/accounts/{account_id}/secrets_store/stores", account_id=account_id), body=await async_maybe_transform({"name": name}, store_create_params.StoreCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -277,7 +287,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["name", "comment", "created", "modified", "status"] | Omit = omit, page: int | Omit = omit, @@ -311,10 +321,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/secrets_store/stores", + path_template("/accounts/{account_id}/secrets_store/stores", account_id=account_id), page=AsyncV4PagePaginationArray[StoreListResponse], options=make_request_options( extra_headers=extra_headers, @@ -338,7 +350,7 @@ async def delete( self, store_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -362,12 +374,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not store_id: raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") return await self._delete( - f"/accounts/{account_id}/secrets_store/stores/{store_id}", + path_template( + "/accounts/{account_id}/secrets_store/stores/{store_id}", account_id=account_id, store_id=store_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/security_center/__init__.py b/src/cloudflare/resources/security_center/__init__.py new file mode 100644 index 00000000000..aced2f74c07 --- /dev/null +++ b/src/cloudflare/resources/security_center/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .insights import ( + InsightsResource, + AsyncInsightsResource, + InsightsResourceWithRawResponse, + AsyncInsightsResourceWithRawResponse, + InsightsResourceWithStreamingResponse, + AsyncInsightsResourceWithStreamingResponse, +) +from .security_center import ( + SecurityCenterResource, + AsyncSecurityCenterResource, + SecurityCenterResourceWithRawResponse, + AsyncSecurityCenterResourceWithRawResponse, + SecurityCenterResourceWithStreamingResponse, + AsyncSecurityCenterResourceWithStreamingResponse, +) + +__all__ = [ + "InsightsResource", + "AsyncInsightsResource", + "InsightsResourceWithRawResponse", + "AsyncInsightsResourceWithRawResponse", + "InsightsResourceWithStreamingResponse", + "AsyncInsightsResourceWithStreamingResponse", + "SecurityCenterResource", + "AsyncSecurityCenterResource", + "SecurityCenterResourceWithRawResponse", + "AsyncSecurityCenterResourceWithRawResponse", + "SecurityCenterResourceWithStreamingResponse", + "AsyncSecurityCenterResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/security_center/api.md b/src/cloudflare/resources/security_center/api.md new file mode 100644 index 00000000000..5ba93b613e2 --- /dev/null +++ b/src/cloudflare/resources/security_center/api.md @@ -0,0 +1,50 @@ +# SecurityCenter + +## Insights + +Types: + +```python +from cloudflare.types.security_center import InsightListResponse, InsightDismissResponse +``` + +Methods: + +- 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 + +### Class + +Types: + +```python +from cloudflare.types.security_center.insights import ClassGetResponse +``` + +Methods: + +- client.security*center.insights.class*.get(\*, account_id, zone_id, \*\*params) -> Optional[ClassGetResponse] + +### Severity + +Types: + +```python +from cloudflare.types.security_center.insights import SeverityGetResponse +``` + +Methods: + +- client.security_center.insights.severity.get(\*, account_id, zone_id, \*\*params) -> Optional[SeverityGetResponse] + +### Type + +Types: + +```python +from cloudflare.types.security_center.insights import TypeGetResponse +``` + +Methods: + +- client.security_center.insights.type.get(\*, account_id, zone_id, \*\*params) -> Optional[TypeGetResponse] diff --git a/src/cloudflare/resources/security_center/insights/__init__.py b/src/cloudflare/resources/security_center/insights/__init__.py new file mode 100644 index 00000000000..5818ca6cde6 --- /dev/null +++ b/src/cloudflare/resources/security_center/insights/__init__.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .type import ( + TypeResource, + AsyncTypeResource, + TypeResourceWithRawResponse, + AsyncTypeResourceWithRawResponse, + TypeResourceWithStreamingResponse, + AsyncTypeResourceWithStreamingResponse, +) +from .class_ import ( + ClassResource, + AsyncClassResource, + ClassResourceWithRawResponse, + AsyncClassResourceWithRawResponse, + ClassResourceWithStreamingResponse, + AsyncClassResourceWithStreamingResponse, +) +from .insights import ( + InsightsResource, + AsyncInsightsResource, + InsightsResourceWithRawResponse, + AsyncInsightsResourceWithRawResponse, + InsightsResourceWithStreamingResponse, + AsyncInsightsResourceWithStreamingResponse, +) +from .severity import ( + SeverityResource, + AsyncSeverityResource, + SeverityResourceWithRawResponse, + AsyncSeverityResourceWithRawResponse, + SeverityResourceWithStreamingResponse, + AsyncSeverityResourceWithStreamingResponse, +) + +__all__ = [ + "ClassResource", + "AsyncClassResource", + "ClassResourceWithRawResponse", + "AsyncClassResourceWithRawResponse", + "ClassResourceWithStreamingResponse", + "AsyncClassResourceWithStreamingResponse", + "SeverityResource", + "AsyncSeverityResource", + "SeverityResourceWithRawResponse", + "AsyncSeverityResourceWithRawResponse", + "SeverityResourceWithStreamingResponse", + "AsyncSeverityResourceWithStreamingResponse", + "TypeResource", + "AsyncTypeResource", + "TypeResourceWithRawResponse", + "AsyncTypeResourceWithRawResponse", + "TypeResourceWithStreamingResponse", + "AsyncTypeResourceWithStreamingResponse", + "InsightsResource", + "AsyncInsightsResource", + "InsightsResourceWithRawResponse", + "AsyncInsightsResourceWithRawResponse", + "InsightsResourceWithStreamingResponse", + "AsyncInsightsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/security_center/insights/class_.py b/src/cloudflare/resources/security_center/insights/class_.py new file mode 100644 index 00000000000..5d039a45e65 --- /dev/null +++ b/src/cloudflare/resources/security_center/insights/class_.py @@ -0,0 +1,278 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, Optional, cast + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ...._utils import path_template, 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.security_center.insights import class_get_params +from ....types.intel.attack_surface_report.issue_type import IssueType +from ....types.security_center.insights.class_get_response import ClassGetResponse +from ....types.intel.attack_surface_report.severity_query_param import SeverityQueryParam + +__all__ = ["ClassResource", "AsyncClassResource"] + + +class ClassResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ClassResourceWithRawResponse: + """ + 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 ClassResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ClassResourceWithStreamingResponse: + """ + 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 ClassResourceWithStreamingResponse(self) + + def get( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismissed: bool | Omit = omit, + issue_class: SequenceNotStr[str] | Omit = omit, + issue_class_neq: SequenceNotStr[str] | Omit = omit, + issue_type: List[IssueType] | Omit = omit, + issue_type_neq: List[IssueType] | Omit = omit, + product: SequenceNotStr[str] | Omit = omit, + product_neq: SequenceNotStr[str] | Omit = omit, + severity: List[SeverityQueryParam] | Omit = omit, + severity_neq: List[SeverityQueryParam] | Omit = omit, + subject: SequenceNotStr[str] | Omit = omit, + subject_neq: 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[ClassGetResponse]: + """ + Retrieves Security Center insight counts aggregated by classification class. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights/class", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "dismissed": dismissed, + "issue_class": issue_class, + "issue_class_neq": issue_class_neq, + "issue_type": issue_type, + "issue_type_neq": issue_type_neq, + "product": product, + "product_neq": product_neq, + "severity": severity, + "severity_neq": severity_neq, + "subject": subject, + "subject_neq": subject_neq, + }, + class_get_params.ClassGetParams, + ), + post_parser=ResultWrapper[Optional[ClassGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ClassGetResponse]], ResultWrapper[ClassGetResponse]), + ) + + +class AsyncClassResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncClassResourceWithRawResponse: + """ + 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 AsyncClassResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncClassResourceWithStreamingResponse: + """ + 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 AsyncClassResourceWithStreamingResponse(self) + + async def get( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismissed: bool | Omit = omit, + issue_class: SequenceNotStr[str] | Omit = omit, + issue_class_neq: SequenceNotStr[str] | Omit = omit, + issue_type: List[IssueType] | Omit = omit, + issue_type_neq: List[IssueType] | Omit = omit, + product: SequenceNotStr[str] | Omit = omit, + product_neq: SequenceNotStr[str] | Omit = omit, + severity: List[SeverityQueryParam] | Omit = omit, + severity_neq: List[SeverityQueryParam] | Omit = omit, + subject: SequenceNotStr[str] | Omit = omit, + subject_neq: 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[ClassGetResponse]: + """ + Retrieves Security Center insight counts aggregated by classification class. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights/class", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "dismissed": dismissed, + "issue_class": issue_class, + "issue_class_neq": issue_class_neq, + "issue_type": issue_type, + "issue_type_neq": issue_type_neq, + "product": product, + "product_neq": product_neq, + "severity": severity, + "severity_neq": severity_neq, + "subject": subject, + "subject_neq": subject_neq, + }, + class_get_params.ClassGetParams, + ), + post_parser=ResultWrapper[Optional[ClassGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ClassGetResponse]], ResultWrapper[ClassGetResponse]), + ) + + +class ClassResourceWithRawResponse: + def __init__(self, class_: ClassResource) -> None: + self._class_ = class_ + + self.get = to_raw_response_wrapper( + class_.get, + ) + + +class AsyncClassResourceWithRawResponse: + def __init__(self, class_: AsyncClassResource) -> None: + self._class_ = class_ + + self.get = async_to_raw_response_wrapper( + class_.get, + ) + + +class ClassResourceWithStreamingResponse: + def __init__(self, class_: ClassResource) -> None: + self._class_ = class_ + + self.get = to_streamed_response_wrapper( + class_.get, + ) + + +class AsyncClassResourceWithStreamingResponse: + def __init__(self, class_: AsyncClassResource) -> None: + self._class_ = class_ + + self.get = async_to_streamed_response_wrapper( + class_.get, + ) diff --git a/src/cloudflare/resources/security_center/insights/insights.py b/src/cloudflare/resources/security_center/insights/insights.py new file mode 100644 index 00000000000..eb8fc46185e --- /dev/null +++ b/src/cloudflare/resources/security_center/insights/insights.py @@ -0,0 +1,531 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Optional + +import httpx + +from .type import ( + TypeResource, + AsyncTypeResource, + TypeResourceWithRawResponse, + AsyncTypeResourceWithRawResponse, + TypeResourceWithStreamingResponse, + AsyncTypeResourceWithStreamingResponse, +) +from .class_ import ( + ClassResource, + AsyncClassResource, + ClassResourceWithRawResponse, + AsyncClassResourceWithRawResponse, + ClassResourceWithStreamingResponse, + AsyncClassResourceWithStreamingResponse, +) +from .severity import ( + SeverityResource, + AsyncSeverityResource, + SeverityResourceWithRawResponse, + AsyncSeverityResourceWithRawResponse, + SeverityResourceWithStreamingResponse, + AsyncSeverityResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ...._utils import path_template, 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 ....pagination import SyncV4PagePagination, AsyncV4PagePagination +from ...._base_client import AsyncPaginator, make_request_options +from ....types.security_center import insight_list_params, insight_dismiss_params +from ....types.security_center.insight_list_response import InsightListResponse +from ....types.intel.attack_surface_report.issue_type import IssueType +from ....types.security_center.insight_dismiss_response import InsightDismissResponse +from ....types.intel.attack_surface_report.severity_query_param import SeverityQueryParam + +__all__ = ["InsightsResource", "AsyncInsightsResource"] + + +class InsightsResource(SyncAPIResource): + @cached_property + def class_(self) -> ClassResource: + return ClassResource(self._client) + + @cached_property + def severity(self) -> SeverityResource: + return SeverityResource(self._client) + + @cached_property + def type(self) -> TypeResource: + return TypeResource(self._client) + + @cached_property + def with_raw_response(self) -> InsightsResourceWithRawResponse: + """ + 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 InsightsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> InsightsResourceWithStreamingResponse: + """ + 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 InsightsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismissed: bool | Omit = omit, + issue_class: SequenceNotStr[str] | Omit = omit, + issue_class_neq: SequenceNotStr[str] | Omit = omit, + issue_type: List[IssueType] | Omit = omit, + issue_type_neq: List[IssueType] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + product: SequenceNotStr[str] | Omit = omit, + product_neq: SequenceNotStr[str] | Omit = omit, + severity: List[SeverityQueryParam] | Omit = omit, + severity_neq: List[SeverityQueryParam] | Omit = omit, + subject: SequenceNotStr[str] | Omit = omit, + subject_neq: 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, + ) -> SyncV4PagePagination[Optional[InsightListResponse]]: + """ + Lists all Security Center insights for the account or zone, showing security + findings and recommendations. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + page: Specifies the current page within paginated list of results. + + per_page: Sets the number of results per page of results. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=SyncV4PagePagination[Optional[InsightListResponse]], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "dismissed": dismissed, + "issue_class": issue_class, + "issue_class_neq": issue_class_neq, + "issue_type": issue_type, + "issue_type_neq": issue_type_neq, + "page": page, + "per_page": per_page, + "product": product, + "product_neq": product_neq, + "severity": severity, + "severity_neq": severity_neq, + "subject": subject, + "subject_neq": subject_neq, + }, + insight_list_params.InsightListParams, + ), + ), + model=InsightListResponse, + ) + + def dismiss( + self, + issue_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismiss: 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, + ) -> InsightDismissResponse: + """ + Archives a Security Center insight for an account or zone, removing it from the + active insights list while preserving historical data. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 issue_id: + raise ValueError(f"Expected a non-empty value for `issue_id` but received {issue_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._put( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights/{issue_id}/dismiss", + issue_id=issue_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=maybe_transform({"dismiss": dismiss}, insight_dismiss_params.InsightDismissParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=InsightDismissResponse, + ) + + +class AsyncInsightsResource(AsyncAPIResource): + @cached_property + def class_(self) -> AsyncClassResource: + return AsyncClassResource(self._client) + + @cached_property + def severity(self) -> AsyncSeverityResource: + return AsyncSeverityResource(self._client) + + @cached_property + def type(self) -> AsyncTypeResource: + return AsyncTypeResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncInsightsResourceWithRawResponse: + """ + 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 AsyncInsightsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncInsightsResourceWithStreamingResponse: + """ + 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 AsyncInsightsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismissed: bool | Omit = omit, + issue_class: SequenceNotStr[str] | Omit = omit, + issue_class_neq: SequenceNotStr[str] | Omit = omit, + issue_type: List[IssueType] | Omit = omit, + issue_type_neq: List[IssueType] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + product: SequenceNotStr[str] | Omit = omit, + product_neq: SequenceNotStr[str] | Omit = omit, + severity: List[SeverityQueryParam] | Omit = omit, + severity_neq: List[SeverityQueryParam] | Omit = omit, + subject: SequenceNotStr[str] | Omit = omit, + subject_neq: 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, + ) -> AsyncPaginator[Optional[InsightListResponse], AsyncV4PagePagination[Optional[InsightListResponse]]]: + """ + Lists all Security Center insights for the account or zone, showing security + findings and recommendations. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + page: Specifies the current page within paginated list of results. + + per_page: Sets the number of results per page of results. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=AsyncV4PagePagination[Optional[InsightListResponse]], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "dismissed": dismissed, + "issue_class": issue_class, + "issue_class_neq": issue_class_neq, + "issue_type": issue_type, + "issue_type_neq": issue_type_neq, + "page": page, + "per_page": per_page, + "product": product, + "product_neq": product_neq, + "severity": severity, + "severity_neq": severity_neq, + "subject": subject, + "subject_neq": subject_neq, + }, + insight_list_params.InsightListParams, + ), + ), + model=InsightListResponse, + ) + + async def dismiss( + self, + issue_id: str, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismiss: 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, + ) -> InsightDismissResponse: + """ + Archives a Security Center insight for an account or zone, removing it from the + active insights list while preserving historical data. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 issue_id: + raise ValueError(f"Expected a non-empty value for `issue_id` but received {issue_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._put( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights/{issue_id}/dismiss", + issue_id=issue_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + body=await async_maybe_transform({"dismiss": dismiss}, insight_dismiss_params.InsightDismissParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=InsightDismissResponse, + ) + + +class InsightsResourceWithRawResponse: + def __init__(self, insights: InsightsResource) -> None: + self._insights = insights + + self.list = to_raw_response_wrapper( + insights.list, + ) + self.dismiss = to_raw_response_wrapper( + insights.dismiss, + ) + + @cached_property + def class_(self) -> ClassResourceWithRawResponse: + return ClassResourceWithRawResponse(self._insights.class_) + + @cached_property + def severity(self) -> SeverityResourceWithRawResponse: + return SeverityResourceWithRawResponse(self._insights.severity) + + @cached_property + def type(self) -> TypeResourceWithRawResponse: + return TypeResourceWithRawResponse(self._insights.type) + + +class AsyncInsightsResourceWithRawResponse: + def __init__(self, insights: AsyncInsightsResource) -> None: + self._insights = insights + + self.list = async_to_raw_response_wrapper( + insights.list, + ) + self.dismiss = async_to_raw_response_wrapper( + insights.dismiss, + ) + + @cached_property + def class_(self) -> AsyncClassResourceWithRawResponse: + return AsyncClassResourceWithRawResponse(self._insights.class_) + + @cached_property + def severity(self) -> AsyncSeverityResourceWithRawResponse: + return AsyncSeverityResourceWithRawResponse(self._insights.severity) + + @cached_property + def type(self) -> AsyncTypeResourceWithRawResponse: + return AsyncTypeResourceWithRawResponse(self._insights.type) + + +class InsightsResourceWithStreamingResponse: + def __init__(self, insights: InsightsResource) -> None: + self._insights = insights + + self.list = to_streamed_response_wrapper( + insights.list, + ) + self.dismiss = to_streamed_response_wrapper( + insights.dismiss, + ) + + @cached_property + def class_(self) -> ClassResourceWithStreamingResponse: + return ClassResourceWithStreamingResponse(self._insights.class_) + + @cached_property + def severity(self) -> SeverityResourceWithStreamingResponse: + return SeverityResourceWithStreamingResponse(self._insights.severity) + + @cached_property + def type(self) -> TypeResourceWithStreamingResponse: + return TypeResourceWithStreamingResponse(self._insights.type) + + +class AsyncInsightsResourceWithStreamingResponse: + def __init__(self, insights: AsyncInsightsResource) -> None: + self._insights = insights + + self.list = async_to_streamed_response_wrapper( + insights.list, + ) + self.dismiss = async_to_streamed_response_wrapper( + insights.dismiss, + ) + + @cached_property + def class_(self) -> AsyncClassResourceWithStreamingResponse: + return AsyncClassResourceWithStreamingResponse(self._insights.class_) + + @cached_property + def severity(self) -> AsyncSeverityResourceWithStreamingResponse: + return AsyncSeverityResourceWithStreamingResponse(self._insights.severity) + + @cached_property + def type(self) -> AsyncTypeResourceWithStreamingResponse: + return AsyncTypeResourceWithStreamingResponse(self._insights.type) diff --git a/src/cloudflare/resources/security_center/insights/severity.py b/src/cloudflare/resources/security_center/insights/severity.py new file mode 100644 index 00000000000..90efbec1e05 --- /dev/null +++ b/src/cloudflare/resources/security_center/insights/severity.py @@ -0,0 +1,280 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, Optional, cast + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ...._utils import path_template, 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.security_center.insights import severity_get_params +from ....types.intel.attack_surface_report.issue_type import IssueType +from ....types.security_center.insights.severity_get_response import SeverityGetResponse +from ....types.intel.attack_surface_report.severity_query_param import SeverityQueryParam + +__all__ = ["SeverityResource", "AsyncSeverityResource"] + + +class SeverityResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SeverityResourceWithRawResponse: + """ + 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 SeverityResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SeverityResourceWithStreamingResponse: + """ + 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 SeverityResourceWithStreamingResponse(self) + + def get( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismissed: bool | Omit = omit, + issue_class: SequenceNotStr[str] | Omit = omit, + issue_class_neq: SequenceNotStr[str] | Omit = omit, + issue_type: List[IssueType] | Omit = omit, + issue_type_neq: List[IssueType] | Omit = omit, + product: SequenceNotStr[str] | Omit = omit, + product_neq: SequenceNotStr[str] | Omit = omit, + severity: List[SeverityQueryParam] | Omit = omit, + severity_neq: List[SeverityQueryParam] | Omit = omit, + subject: SequenceNotStr[str] | Omit = omit, + subject_neq: 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[SeverityGetResponse]: + """ + Retrieves Security Center insight counts aggregated by severity level (critical, + high, medium, low). + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights/severity", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "dismissed": dismissed, + "issue_class": issue_class, + "issue_class_neq": issue_class_neq, + "issue_type": issue_type, + "issue_type_neq": issue_type_neq, + "product": product, + "product_neq": product_neq, + "severity": severity, + "severity_neq": severity_neq, + "subject": subject, + "subject_neq": subject_neq, + }, + severity_get_params.SeverityGetParams, + ), + post_parser=ResultWrapper[Optional[SeverityGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SeverityGetResponse]], ResultWrapper[SeverityGetResponse]), + ) + + +class AsyncSeverityResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSeverityResourceWithRawResponse: + """ + 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 AsyncSeverityResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSeverityResourceWithStreamingResponse: + """ + 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 AsyncSeverityResourceWithStreamingResponse(self) + + async def get( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismissed: bool | Omit = omit, + issue_class: SequenceNotStr[str] | Omit = omit, + issue_class_neq: SequenceNotStr[str] | Omit = omit, + issue_type: List[IssueType] | Omit = omit, + issue_type_neq: List[IssueType] | Omit = omit, + product: SequenceNotStr[str] | Omit = omit, + product_neq: SequenceNotStr[str] | Omit = omit, + severity: List[SeverityQueryParam] | Omit = omit, + severity_neq: List[SeverityQueryParam] | Omit = omit, + subject: SequenceNotStr[str] | Omit = omit, + subject_neq: 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[SeverityGetResponse]: + """ + Retrieves Security Center insight counts aggregated by severity level (critical, + high, medium, low). + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights/severity", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "dismissed": dismissed, + "issue_class": issue_class, + "issue_class_neq": issue_class_neq, + "issue_type": issue_type, + "issue_type_neq": issue_type_neq, + "product": product, + "product_neq": product_neq, + "severity": severity, + "severity_neq": severity_neq, + "subject": subject, + "subject_neq": subject_neq, + }, + severity_get_params.SeverityGetParams, + ), + post_parser=ResultWrapper[Optional[SeverityGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SeverityGetResponse]], ResultWrapper[SeverityGetResponse]), + ) + + +class SeverityResourceWithRawResponse: + def __init__(self, severity: SeverityResource) -> None: + self._severity = severity + + self.get = to_raw_response_wrapper( + severity.get, + ) + + +class AsyncSeverityResourceWithRawResponse: + def __init__(self, severity: AsyncSeverityResource) -> None: + self._severity = severity + + self.get = async_to_raw_response_wrapper( + severity.get, + ) + + +class SeverityResourceWithStreamingResponse: + def __init__(self, severity: SeverityResource) -> None: + self._severity = severity + + self.get = to_streamed_response_wrapper( + severity.get, + ) + + +class AsyncSeverityResourceWithStreamingResponse: + def __init__(self, severity: AsyncSeverityResource) -> None: + self._severity = severity + + self.get = async_to_streamed_response_wrapper( + severity.get, + ) diff --git a/src/cloudflare/resources/security_center/insights/type.py b/src/cloudflare/resources/security_center/insights/type.py new file mode 100644 index 00000000000..d0f57e82b84 --- /dev/null +++ b/src/cloudflare/resources/security_center/insights/type.py @@ -0,0 +1,278 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, Optional, cast + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ...._utils import path_template, 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.security_center.insights import type_get_params +from ....types.intel.attack_surface_report.issue_type import IssueType +from ....types.security_center.insights.type_get_response import TypeGetResponse +from ....types.intel.attack_surface_report.severity_query_param import SeverityQueryParam + +__all__ = ["TypeResource", "AsyncTypeResource"] + + +class TypeResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> TypeResourceWithRawResponse: + """ + 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 TypeResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TypeResourceWithStreamingResponse: + """ + 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 TypeResourceWithStreamingResponse(self) + + def get( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismissed: bool | Omit = omit, + issue_class: SequenceNotStr[str] | Omit = omit, + issue_class_neq: SequenceNotStr[str] | Omit = omit, + issue_type: List[IssueType] | Omit = omit, + issue_type_neq: List[IssueType] | Omit = omit, + product: SequenceNotStr[str] | Omit = omit, + product_neq: SequenceNotStr[str] | Omit = omit, + severity: List[SeverityQueryParam] | Omit = omit, + severity_neq: List[SeverityQueryParam] | Omit = omit, + subject: SequenceNotStr[str] | Omit = omit, + subject_neq: 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[TypeGetResponse]: + """ + Retrieves Security Center insight counts aggregated by insight type. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights/type", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "dismissed": dismissed, + "issue_class": issue_class, + "issue_class_neq": issue_class_neq, + "issue_type": issue_type, + "issue_type_neq": issue_type_neq, + "product": product, + "product_neq": product_neq, + "severity": severity, + "severity_neq": severity_neq, + "subject": subject, + "subject_neq": subject_neq, + }, + type_get_params.TypeGetParams, + ), + post_parser=ResultWrapper[Optional[TypeGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TypeGetResponse]], ResultWrapper[TypeGetResponse]), + ) + + +class AsyncTypeResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncTypeResourceWithRawResponse: + """ + 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 AsyncTypeResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTypeResourceWithStreamingResponse: + """ + 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 AsyncTypeResourceWithStreamingResponse(self) + + async def get( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + dismissed: bool | Omit = omit, + issue_class: SequenceNotStr[str] | Omit = omit, + issue_class_neq: SequenceNotStr[str] | Omit = omit, + issue_type: List[IssueType] | Omit = omit, + issue_type_neq: List[IssueType] | Omit = omit, + product: SequenceNotStr[str] | Omit = omit, + product_neq: SequenceNotStr[str] | Omit = omit, + severity: List[SeverityQueryParam] | Omit = omit, + severity_neq: List[SeverityQueryParam] | Omit = omit, + subject: SequenceNotStr[str] | Omit = omit, + subject_neq: 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[TypeGetResponse]: + """ + Retrieves Security Center insight counts aggregated by insight type. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + path_template( + "/{account_or_zone}/{account_or_zone_id}/security-center/insights/type", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "dismissed": dismissed, + "issue_class": issue_class, + "issue_class_neq": issue_class_neq, + "issue_type": issue_type, + "issue_type_neq": issue_type_neq, + "product": product, + "product_neq": product_neq, + "severity": severity, + "severity_neq": severity_neq, + "subject": subject, + "subject_neq": subject_neq, + }, + type_get_params.TypeGetParams, + ), + post_parser=ResultWrapper[Optional[TypeGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TypeGetResponse]], ResultWrapper[TypeGetResponse]), + ) + + +class TypeResourceWithRawResponse: + def __init__(self, type: TypeResource) -> None: + self._type = type + + self.get = to_raw_response_wrapper( + type.get, + ) + + +class AsyncTypeResourceWithRawResponse: + def __init__(self, type: AsyncTypeResource) -> None: + self._type = type + + self.get = async_to_raw_response_wrapper( + type.get, + ) + + +class TypeResourceWithStreamingResponse: + def __init__(self, type: TypeResource) -> None: + self._type = type + + self.get = to_streamed_response_wrapper( + type.get, + ) + + +class AsyncTypeResourceWithStreamingResponse: + def __init__(self, type: AsyncTypeResource) -> None: + self._type = type + + self.get = async_to_streamed_response_wrapper( + type.get, + ) diff --git a/src/cloudflare/resources/security_center/security_center.py b/src/cloudflare/resources/security_center/security_center.py new file mode 100644 index 00000000000..8c377cc50c2 --- /dev/null +++ b/src/cloudflare/resources/security_center/security_center.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 ..._resource import SyncAPIResource, AsyncAPIResource +from .insights.insights import ( + InsightsResource, + AsyncInsightsResource, + InsightsResourceWithRawResponse, + AsyncInsightsResourceWithRawResponse, + InsightsResourceWithStreamingResponse, + AsyncInsightsResourceWithStreamingResponse, +) + +__all__ = ["SecurityCenterResource", "AsyncSecurityCenterResource"] + + +class SecurityCenterResource(SyncAPIResource): + @cached_property + def insights(self) -> InsightsResource: + return InsightsResource(self._client) + + @cached_property + def with_raw_response(self) -> SecurityCenterResourceWithRawResponse: + """ + 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 SecurityCenterResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SecurityCenterResourceWithStreamingResponse: + """ + 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 SecurityCenterResourceWithStreamingResponse(self) + + +class AsyncSecurityCenterResource(AsyncAPIResource): + @cached_property + def insights(self) -> AsyncInsightsResource: + return AsyncInsightsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSecurityCenterResourceWithRawResponse: + """ + 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 AsyncSecurityCenterResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSecurityCenterResourceWithStreamingResponse: + """ + 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 AsyncSecurityCenterResourceWithStreamingResponse(self) + + +class SecurityCenterResourceWithRawResponse: + def __init__(self, security_center: SecurityCenterResource) -> None: + self._security_center = security_center + + @cached_property + def insights(self) -> InsightsResourceWithRawResponse: + return InsightsResourceWithRawResponse(self._security_center.insights) + + +class AsyncSecurityCenterResourceWithRawResponse: + def __init__(self, security_center: AsyncSecurityCenterResource) -> None: + self._security_center = security_center + + @cached_property + def insights(self) -> AsyncInsightsResourceWithRawResponse: + return AsyncInsightsResourceWithRawResponse(self._security_center.insights) + + +class SecurityCenterResourceWithStreamingResponse: + def __init__(self, security_center: SecurityCenterResource) -> None: + self._security_center = security_center + + @cached_property + def insights(self) -> InsightsResourceWithStreamingResponse: + return InsightsResourceWithStreamingResponse(self._security_center.insights) + + +class AsyncSecurityCenterResourceWithStreamingResponse: + def __init__(self, security_center: AsyncSecurityCenterResource) -> None: + self._security_center = security_center + + @cached_property + def insights(self) -> AsyncInsightsResourceWithStreamingResponse: + return AsyncInsightsResourceWithStreamingResponse(self._security_center.insights) diff --git a/src/cloudflare/resources/security_txt/__init__.py b/src/cloudflare/resources/security_txt/__init__.py new file mode 100644 index 00000000000..7ac0dd90240 --- /dev/null +++ b/src/cloudflare/resources/security_txt/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .security_txt import ( + SecurityTXTResource, + AsyncSecurityTXTResource, + SecurityTXTResourceWithRawResponse, + AsyncSecurityTXTResourceWithRawResponse, + SecurityTXTResourceWithStreamingResponse, + AsyncSecurityTXTResourceWithStreamingResponse, +) + +__all__ = [ + "SecurityTXTResource", + "AsyncSecurityTXTResource", + "SecurityTXTResourceWithRawResponse", + "AsyncSecurityTXTResourceWithRawResponse", + "SecurityTXTResourceWithStreamingResponse", + "AsyncSecurityTXTResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/security_txt/api.md b/src/cloudflare/resources/security_txt/api.md new file mode 100644 index 00000000000..7cedaa43d85 --- /dev/null +++ b/src/cloudflare/resources/security_txt/api.md @@ -0,0 +1,17 @@ +# SecurityTXT + +Types: + +```python +from cloudflare.types.security_txt import ( + SecurityTXTUpdateResponse, + SecurityTXTDeleteResponse, + SecurityTXTGetResponse, +) +``` + +Methods: + +- client.security_txt.update(\*, zone_id, \*\*params) -> SecurityTXTUpdateResponse +- client.security_txt.delete(\*, zone_id) -> SecurityTXTDeleteResponse +- client.security_txt.get(\*, zone_id) -> Optional[SecurityTXTGetResponse] diff --git a/src/cloudflare/resources/security_txt.py b/src/cloudflare/resources/security_txt/security_txt.py similarity index 87% rename from src/cloudflare/resources/security_txt.py rename to src/cloudflare/resources/security_txt/security_txt.py index 21df4368570..3fdbe155d8c 100644 --- a/src/cloudflare/resources/security_txt.py +++ b/src/cloudflare/resources/security_txt/security_txt.py @@ -7,22 +7,22 @@ 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 ( +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import path_template, 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.security_txt import security_txt_update_params -from ..types.security_txt.security_txt_get_response import SecurityTXTGetResponse -from ..types.security_txt.security_txt_delete_response import SecurityTXTDeleteResponse -from ..types.security_txt.security_txt_update_response import SecurityTXTUpdateResponse +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.security_txt import security_txt_update_params +from ...types.security_txt.security_txt_get_response import SecurityTXTGetResponse +from ...types.security_txt.security_txt_delete_response import SecurityTXTDeleteResponse +from ...types.security_txt.security_txt_update_response import SecurityTXTUpdateResponse __all__ = ["SecurityTXTResource", "AsyncSecurityTXTResource"] @@ -50,7 +50,7 @@ def with_streaming_response(self) -> SecurityTXTResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, acknowledgments: SequenceNotStr[str] | Omit = omit, canonical: SequenceNotStr[str] | Omit = omit, contact: SequenceNotStr[str] | Omit = omit, @@ -82,10 +82,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/security-center/securitytxt", + path_template("/zones/{zone_id}/security-center/securitytxt", zone_id=zone_id), body=maybe_transform( { "acknowledgments": acknowledgments, @@ -109,7 +111,7 @@ def update( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -133,10 +135,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/security-center/securitytxt", + path_template("/zones/{zone_id}/security-center/securitytxt", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -146,7 +150,7 @@ def delete( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -169,10 +173,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/security-center/securitytxt", + path_template("/zones/{zone_id}/security-center/securitytxt", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -207,7 +213,7 @@ def with_streaming_response(self) -> AsyncSecurityTXTResourceWithStreamingRespon async def update( self, *, - zone_id: str, + zone_id: str | None = None, acknowledgments: SequenceNotStr[str] | Omit = omit, canonical: SequenceNotStr[str] | Omit = omit, contact: SequenceNotStr[str] | Omit = omit, @@ -239,10 +245,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/security-center/securitytxt", + path_template("/zones/{zone_id}/security-center/securitytxt", zone_id=zone_id), body=await async_maybe_transform( { "acknowledgments": acknowledgments, @@ -266,7 +274,7 @@ async def update( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -290,10 +298,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/security-center/securitytxt", + path_template("/zones/{zone_id}/security-center/securitytxt", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -303,7 +313,7 @@ async def delete( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -326,10 +336,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/security-center/securitytxt", + path_template("/zones/{zone_id}/security-center/securitytxt", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/snippets/api.md b/src/cloudflare/resources/snippets/api.md new file mode 100644 index 00000000000..69c8ef41d92 --- /dev/null +++ b/src/cloudflare/resources/snippets/api.md @@ -0,0 +1,28 @@ +# Snippets + +Types: + +```python +from cloudflare.types.snippets import SnippetUpdateResponse, SnippetListResponse, SnippetGetResponse +``` + +Methods: + +- client.snippets.update(snippet_name, \*, zone_id, \*\*params) -> SnippetUpdateResponse +- client.snippets.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[SnippetListResponse] +- client.snippets.delete(snippet_name, \*, zone_id) -> object +- client.snippets.get(snippet_name, \*, zone_id) -> SnippetGetResponse + +## Content + +Methods: + +- client.snippets.content.get(snippet_name, \*, zone_id) -> BinaryAPIResponse + +## Rules + +Methods: + +- client.snippets.rules.update(\*, zone_id, \*\*params) -> object +- client.snippets.rules.list(\*, zone_id) -> object +- client.snippets.rules.delete(\*, zone_id) -> object diff --git a/src/cloudflare/resources/snippets/content.py b/src/cloudflare/resources/snippets/content.py index 84f9ba1e83e..ce79f0dcc53 100644 --- a/src/cloudflare/resources/snippets/content.py +++ b/src/cloudflare/resources/snippets/content.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +47,7 @@ def get( self, snippet_name: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -70,13 +71,17 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") extra_headers = {"Accept": "multipart/form-data", **(extra_headers or {})} return self._get( - f"/zones/{zone_id}/snippets/{snippet_name}/content", + path_template( + "/zones/{zone_id}/snippets/{snippet_name}/content", zone_id=zone_id, snippet_name=snippet_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -108,7 +113,7 @@ async def get( self, snippet_name: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -132,13 +137,17 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") extra_headers = {"Accept": "multipart/form-data", **(extra_headers or {})} return await self._get( - f"/zones/{zone_id}/snippets/{snippet_name}/content", + path_template( + "/zones/{zone_id}/snippets/{snippet_name}/content", zone_id=zone_id, snippet_name=snippet_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/snippets/rules.py b/src/cloudflare/resources/snippets/rules.py index 0d6cf5b8afc..ae04f928cee 100644 --- a/src/cloudflare/resources/snippets/rules.py +++ b/src/cloudflare/resources/snippets/rules.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +46,7 @@ def with_streaming_response(self) -> RulesResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, rules: Iterable[rule_update_params.Rule], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -71,10 +71,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/snippets/snippet_rules", + path_template("/zones/{zone_id}/snippets/snippet_rules", zone_id=zone_id), body=maybe_transform({"rules": rules}, rule_update_params.RuleUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -89,7 +91,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -111,10 +113,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/snippets/snippet_rules", + path_template("/zones/{zone_id}/snippets/snippet_rules", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -128,7 +132,7 @@ def list( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -150,10 +154,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/snippets/snippet_rules", + path_template("/zones/{zone_id}/snippets/snippet_rules", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -188,7 +194,7 @@ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, rules: Iterable[rule_update_params.Rule], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -213,10 +219,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/snippets/snippet_rules", + path_template("/zones/{zone_id}/snippets/snippet_rules", zone_id=zone_id), body=await async_maybe_transform({"rules": rules}, rule_update_params.RuleUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -231,7 +239,7 @@ async def update( async def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -253,10 +261,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/snippets/snippet_rules", + path_template("/zones/{zone_id}/snippets/snippet_rules", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -270,7 +280,7 @@ async def list( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -292,10 +302,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/snippets/snippet_rules", + path_template("/zones/{zone_id}/snippets/snippet_rules", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/snippets/snippets.py b/src/cloudflare/resources/snippets/snippets.py index 21e928d8b84..abadd7a554d 100644 --- a/src/cloudflare/resources/snippets/snippets.py +++ b/src/cloudflare/resources/snippets/snippets.py @@ -23,7 +23,7 @@ AsyncContentResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -75,7 +75,7 @@ def update( self, snippet_name: str, *, - zone_id: str, + zone_id: str | None = None, metadata: snippet_update_params.Metadata, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -102,6 +102,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: @@ -111,7 +113,7 @@ def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._put( - f"/zones/{zone_id}/snippets/{snippet_name}", + path_template("/zones/{zone_id}/snippets/{snippet_name}", zone_id=zone_id, snippet_name=snippet_name), body=maybe_transform({"metadata": metadata}, snippet_update_params.SnippetUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -127,7 +129,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -155,10 +157,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/snippets", + path_template("/zones/{zone_id}/snippets", zone_id=zone_id), page=SyncV4PagePaginationArray[SnippetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -180,7 +184,7 @@ def delete( self, snippet_name: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -204,12 +208,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") return self._delete( - f"/zones/{zone_id}/snippets/{snippet_name}", + path_template("/zones/{zone_id}/snippets/{snippet_name}", zone_id=zone_id, snippet_name=snippet_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -224,7 +230,7 @@ def get( self, snippet_name: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -248,12 +254,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") return self._get( - f"/zones/{zone_id}/snippets/{snippet_name}", + path_template("/zones/{zone_id}/snippets/{snippet_name}", zone_id=zone_id, snippet_name=snippet_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -297,7 +305,7 @@ async def update( self, snippet_name: str, *, - zone_id: str, + zone_id: str | None = None, metadata: snippet_update_params.Metadata, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -324,6 +332,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: @@ -333,7 +343,7 @@ async def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._put( - f"/zones/{zone_id}/snippets/{snippet_name}", + path_template("/zones/{zone_id}/snippets/{snippet_name}", zone_id=zone_id, snippet_name=snippet_name), body=await async_maybe_transform({"metadata": metadata}, snippet_update_params.SnippetUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -349,7 +359,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -377,10 +387,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/snippets", + path_template("/zones/{zone_id}/snippets", zone_id=zone_id), page=AsyncV4PagePaginationArray[SnippetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -402,7 +414,7 @@ async def delete( self, snippet_name: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -426,12 +438,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") return await self._delete( - f"/zones/{zone_id}/snippets/{snippet_name}", + path_template("/zones/{zone_id}/snippets/{snippet_name}", zone_id=zone_id, snippet_name=snippet_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -446,7 +460,7 @@ async def get( self, snippet_name: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -470,12 +484,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") return await self._get( - f"/zones/{zone_id}/snippets/{snippet_name}", + path_template("/zones/{zone_id}/snippets/{snippet_name}", zone_id=zone_id, snippet_name=snippet_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/spectrum/analytics/aggregates/currents.py b/src/cloudflare/resources/spectrum/analytics/aggregates/currents.py index 6d4e68dec73..a9ff378ee2e 100644 --- a/src/cloudflare/resources/spectrum/analytics/aggregates/currents.py +++ b/src/cloudflare/resources/spectrum/analytics/aggregates/currents.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> CurrentsResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, app_id: str | Omit = omit, colo_name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,10 +77,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/spectrum/analytics/aggregate/current", + path_template("/zones/{zone_id}/spectrum/analytics/aggregate/current", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -122,7 +124,7 @@ def with_streaming_response(self) -> AsyncCurrentsResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, app_id: str | Omit = omit, colo_name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -152,10 +154,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/spectrum/analytics/aggregate/current", + path_template("/zones/{zone_id}/spectrum/analytics/aggregate/current", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/spectrum/analytics/events/bytimes.py b/src/cloudflare/resources/spectrum/analytics/events/bytimes.py index 4eed5839911..6f21432f782 100644 --- a/src/cloudflare/resources/spectrum/analytics/events/bytimes.py +++ b/src/cloudflare/resources/spectrum/analytics/events/bytimes.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> BytimesResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, time_delta: Literal["year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"], dimensions: List[Dimension] | Omit = omit, filters: str | Omit = omit, @@ -134,10 +134,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/spectrum/analytics/events/bytime", + path_template("/zones/{zone_id}/spectrum/analytics/events/bytime", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -184,7 +186,7 @@ def with_streaming_response(self) -> AsyncBytimesResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, time_delta: Literal["year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"], dimensions: List[Dimension] | Omit = omit, filters: str | Omit = omit, @@ -268,10 +270,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/spectrum/analytics/events/bytime", + path_template("/zones/{zone_id}/spectrum/analytics/events/bytime", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/spectrum/analytics/events/summaries.py b/src/cloudflare/resources/spectrum/analytics/events/summaries.py index 8c66f98dad7..49f04526f01 100644 --- a/src/cloudflare/resources/spectrum/analytics/events/summaries.py +++ b/src/cloudflare/resources/spectrum/analytics/events/summaries.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> SummariesResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, dimensions: List[Dimension] | Omit = omit, filters: str | Omit = omit, metrics: List[ @@ -131,10 +131,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/spectrum/analytics/events/summary", + path_template("/zones/{zone_id}/spectrum/analytics/events/summary", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -180,7 +182,7 @@ def with_streaming_response(self) -> AsyncSummariesResourceWithStreamingResponse async def get( self, *, - zone_id: str, + zone_id: str | None = None, dimensions: List[Dimension] | Omit = omit, filters: str | Omit = omit, metrics: List[ @@ -261,10 +263,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/spectrum/analytics/events/summary", + path_template("/zones/{zone_id}/spectrum/analytics/events/summary", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/spectrum/api.md b/src/cloudflare/resources/spectrum/api.md new file mode 100644 index 00000000000..5b1a19d1ac2 --- /dev/null +++ b/src/cloudflare/resources/spectrum/api.md @@ -0,0 +1,77 @@ +# Spectrum + +Types: + +```python +from cloudflare.types.spectrum import DNS, EdgeIPs, OriginDNS, OriginPort +``` + +## Analytics + +### Aggregates + +#### Currents + +Types: + +```python +from cloudflare.types.spectrum.analytics.aggregates import CurrentGetResponse +``` + +Methods: + +- client.spectrum.analytics.aggregates.currents.get(\*, zone_id, \*\*params) -> Optional[CurrentGetResponse] + +### Events + +Types: + +```python +from cloudflare.types.spectrum.analytics import Dimension +``` + +#### Bytimes + +Types: + +```python +from cloudflare.types.spectrum.analytics.events import BytimeGetResponse +``` + +Methods: + +- client.spectrum.analytics.events.bytimes.get(\*, zone_id, \*\*params) -> Optional[BytimeGetResponse] + +#### Summaries + +Types: + +```python +from cloudflare.types.spectrum.analytics.events import SummaryGetResponse +``` + +Methods: + +- client.spectrum.analytics.events.summaries.get(\*, zone_id, \*\*params) -> Optional[SummaryGetResponse] + +## Apps + +Types: + +```python +from cloudflare.types.spectrum import ( + AppCreateResponse, + AppUpdateResponse, + AppListResponse, + AppDeleteResponse, + AppGetResponse, +) +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/spectrum/apps.py b/src/cloudflare/resources/spectrum/apps.py index 9929256776c..49cc58bb679 100644 --- a/src/cloudflare/resources/spectrum/apps.py +++ b/src/cloudflare/resources/spectrum/apps.py @@ -8,7 +8,7 @@ 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 ..._utils import path_template, required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -58,7 +58,7 @@ def with_streaming_response(self) -> AppsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, traffic_type: Literal["direct", "http", "https"], @@ -135,7 +135,7 @@ def create( def create( self, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, origin_direct: SequenceNotStr[str] | Omit = omit, @@ -171,11 +171,11 @@ def create( """ ... - @required_args(["zone_id", "dns", "protocol", "traffic_type"], ["zone_id", "dns", "protocol"]) + @required_args(["dns", "protocol", "traffic_type"], ["dns", "protocol"]) def create( self, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, traffic_type: Literal["direct", "http", "https"] | Omit = omit, @@ -194,12 +194,14 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AppCreateResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[AppCreateResponse], self._post( - f"/zones/{zone_id}/spectrum/apps", + path_template("/zones/{zone_id}/spectrum/apps", zone_id=zone_id), body=maybe_transform( { "dns": dns, @@ -234,7 +236,7 @@ def update( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, traffic_type: Literal["direct", "http", "https"], @@ -314,7 +316,7 @@ def update( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, origin_direct: SequenceNotStr[str] | Omit = omit, @@ -352,12 +354,12 @@ def update( """ ... - @required_args(["zone_id", "dns", "protocol", "traffic_type"], ["zone_id", "dns", "protocol"]) + @required_args(["dns", "protocol", "traffic_type"], ["dns", "protocol"]) def update( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, traffic_type: Literal["direct", "http", "https"] | Omit = omit, @@ -376,6 +378,8 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AppUpdateResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not app_id: @@ -383,7 +387,7 @@ def update( return cast( Optional[AppUpdateResponse], self._put( - f"/zones/{zone_id}/spectrum/apps/{app_id}", + path_template("/zones/{zone_id}/spectrum/apps/{app_id}", zone_id=zone_id, app_id=app_id), body=maybe_transform( { "dns": dns, @@ -416,7 +420,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["protocol", "app_id", "created_on", "modified_on", "dns"] | Omit = omit, page: float | Omit = omit, @@ -452,10 +456,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/spectrum/apps", + path_template("/zones/{zone_id}/spectrum/apps", zone_id=zone_id), page=SyncV4PagePaginationArray[AppListResponse], options=make_request_options( extra_headers=extra_headers, @@ -479,7 +485,7 @@ def delete( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -503,12 +509,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return self._delete( - f"/zones/{zone_id}/spectrum/apps/{app_id}", + path_template("/zones/{zone_id}/spectrum/apps/{app_id}", zone_id=zone_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -523,7 +531,7 @@ def get( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -547,6 +555,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not app_id: @@ -554,7 +564,7 @@ def get( return cast( Optional[AppGetResponse], self._get( - f"/zones/{zone_id}/spectrum/apps/{app_id}", + path_template("/zones/{zone_id}/spectrum/apps/{app_id}", zone_id=zone_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -593,7 +603,7 @@ def with_streaming_response(self) -> AsyncAppsResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, traffic_type: Literal["direct", "http", "https"], @@ -670,7 +680,7 @@ async def create( async def create( self, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, origin_direct: SequenceNotStr[str] | Omit = omit, @@ -706,11 +716,11 @@ async def create( """ ... - @required_args(["zone_id", "dns", "protocol", "traffic_type"], ["zone_id", "dns", "protocol"]) + @required_args(["dns", "protocol", "traffic_type"], ["dns", "protocol"]) async def create( self, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, traffic_type: Literal["direct", "http", "https"] | Omit = omit, @@ -729,12 +739,14 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AppCreateResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( Optional[AppCreateResponse], await self._post( - f"/zones/{zone_id}/spectrum/apps", + path_template("/zones/{zone_id}/spectrum/apps", zone_id=zone_id), body=await async_maybe_transform( { "dns": dns, @@ -769,7 +781,7 @@ async def update( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, traffic_type: Literal["direct", "http", "https"], @@ -849,7 +861,7 @@ async def update( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, origin_direct: SequenceNotStr[str] | Omit = omit, @@ -887,12 +899,12 @@ async def update( """ ... - @required_args(["zone_id", "dns", "protocol", "traffic_type"], ["zone_id", "dns", "protocol"]) + @required_args(["dns", "protocol", "traffic_type"], ["dns", "protocol"]) async def update( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, dns: DNSParam, protocol: str, traffic_type: Literal["direct", "http", "https"] | Omit = omit, @@ -911,6 +923,8 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AppUpdateResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not app_id: @@ -918,7 +932,7 @@ async def update( return cast( Optional[AppUpdateResponse], await self._put( - f"/zones/{zone_id}/spectrum/apps/{app_id}", + path_template("/zones/{zone_id}/spectrum/apps/{app_id}", zone_id=zone_id, app_id=app_id), body=await async_maybe_transform( { "dns": dns, @@ -951,7 +965,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, order: Literal["protocol", "app_id", "created_on", "modified_on", "dns"] | Omit = omit, page: float | Omit = omit, @@ -987,10 +1001,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/spectrum/apps", + path_template("/zones/{zone_id}/spectrum/apps", zone_id=zone_id), page=AsyncV4PagePaginationArray[AppListResponse], options=make_request_options( extra_headers=extra_headers, @@ -1014,7 +1030,7 @@ async def delete( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1038,12 +1054,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") return await self._delete( - f"/zones/{zone_id}/spectrum/apps/{app_id}", + path_template("/zones/{zone_id}/spectrum/apps/{app_id}", zone_id=zone_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1058,7 +1076,7 @@ async def get( self, app_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1082,6 +1100,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not app_id: @@ -1089,7 +1109,7 @@ async def get( return cast( Optional[AppGetResponse], await self._get( - f"/zones/{zone_id}/spectrum/apps/{app_id}", + path_template("/zones/{zone_id}/spectrum/apps/{app_id}", zone_id=zone_id, app_id=app_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/speed/api.md b/src/cloudflare/resources/speed/api.md new file mode 100644 index 00000000000..854dca97437 --- /dev/null +++ b/src/cloudflare/resources/speed/api.md @@ -0,0 +1,61 @@ +# Speed + +Types: + +```python +from cloudflare.types.speed import LabeledRegion, LighthouseReport, Trend +``` + +## Schedule + +Types: + +```python +from cloudflare.types.speed import Schedule, ScheduleCreateResponse, ScheduleDeleteResponse +``` + +Methods: + +- 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] + +## Availabilities + +Types: + +```python +from cloudflare.types.speed import Availability +``` + +Methods: + +- client.speed.availabilities.list(\*, zone_id) -> Optional[Availability] + +## Pages + +Types: + +```python +from cloudflare.types.speed import PageListResponse +``` + +Methods: + +- client.speed.pages.list(\*, zone_id) -> SyncSinglePage[PageListResponse] +- client.speed.pages.trend(url, \*, zone_id, \*\*params) -> Optional[Trend] + +### Tests + +Types: + +```python +from cloudflare.types.speed.pages import Test, TestDeleteResponse +``` + +Methods: + +- 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] diff --git a/src/cloudflare/resources/speed/availabilities.py b/src/cloudflare/resources/speed/availabilities.py index 2f7f75fd060..ef601886701 100644 --- a/src/cloudflare/resources/speed/availabilities.py +++ b/src/cloudflare/resources/speed/availabilities.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> AvailabilitiesResourceWithStreamingResponse def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/speed_api/availabilities", + path_template("/zones/{zone_id}/speed_api/availabilities", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -105,7 +108,7 @@ def with_streaming_response(self) -> AsyncAvailabilitiesResourceWithStreamingRes async def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,10 +130,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/speed_api/availabilities", + path_template("/zones/{zone_id}/speed_api/availabilities", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/speed/pages/pages.py b/src/cloudflare/resources/speed/pages/pages.py index 145cb4a88a9..c00b9aee194 100644 --- a/src/cloudflare/resources/speed/pages/pages.py +++ b/src/cloudflare/resources/speed/pages/pages.py @@ -17,7 +17,7 @@ AsyncTestsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -63,7 +63,7 @@ def with_streaming_response(self) -> PagesResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -85,10 +85,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/speed_api/pages", + path_template("/zones/{zone_id}/speed_api/pages", zone_id=zone_id), page=SyncSinglePage[PageListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -100,7 +102,7 @@ def trend( self, url: str, *, - zone_id: str, + zone_id: str | None = None, device_type: Literal["DESKTOP", "MOBILE"], metrics: str, region: Literal[ @@ -160,12 +162,14 @@ def trend( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return self._get( - f"/zones/{zone_id}/speed_api/pages/{url}/trend", + path_template("/zones/{zone_id}/speed_api/pages/{url}/trend", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -215,7 +219,7 @@ def with_streaming_response(self) -> AsyncPagesResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -237,10 +241,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/speed_api/pages", + path_template("/zones/{zone_id}/speed_api/pages", zone_id=zone_id), page=AsyncSinglePage[PageListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -252,7 +258,7 @@ async def trend( self, url: str, *, - zone_id: str, + zone_id: str | None = None, device_type: Literal["DESKTOP", "MOBILE"], metrics: str, region: Literal[ @@ -312,12 +318,14 @@ async def trend( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return await self._get( - f"/zones/{zone_id}/speed_api/pages/{url}/trend", + path_template("/zones/{zone_id}/speed_api/pages/{url}/trend", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/speed/pages/tests.py b/src/cloudflare/resources/speed/pages/tests.py index bc17097085f..15b1d90451c 100644 --- a/src/cloudflare/resources/speed/pages/tests.py +++ b/src/cloudflare/resources/speed/pages/tests.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -53,7 +53,7 @@ def create( self, url: str, *, - zone_id: str, + zone_id: str | None = None, region: Literal[ "asia-east1", "asia-northeast1", @@ -103,12 +103,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return self._post( - f"/zones/{zone_id}/speed_api/pages/{url}/tests", + path_template("/zones/{zone_id}/speed_api/pages/{url}/tests", zone_id=zone_id, url=url), body=maybe_transform({"region": region}, test_create_params.TestCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -124,7 +126,7 @@ def list( self, url: str, *, - zone_id: str, + zone_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, region: Literal[ @@ -176,12 +178,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return self._get_api_list( - f"/zones/{zone_id}/speed_api/pages/{url}/tests", + path_template("/zones/{zone_id}/speed_api/pages/{url}/tests", zone_id=zone_id, url=url), page=SyncV4PagePaginationArray[Test], options=make_request_options( extra_headers=extra_headers, @@ -204,7 +208,7 @@ def delete( self, url: str, *, - zone_id: str, + zone_id: str | None = None, region: Literal[ "asia-east1", "asia-northeast1", @@ -256,12 +260,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return self._delete( - f"/zones/{zone_id}/speed_api/pages/{url}/tests", + path_template("/zones/{zone_id}/speed_api/pages/{url}/tests", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -277,7 +283,7 @@ def get( self, test_id: str, *, - zone_id: str, + zone_id: str | None = None, url: 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. @@ -302,6 +308,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: @@ -309,7 +317,9 @@ def get( if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return self._get( - f"/zones/{zone_id}/speed_api/pages/{url}/tests/{test_id}", + path_template( + "/zones/{zone_id}/speed_api/pages/{url}/tests/{test_id}", zone_id=zone_id, url=url, test_id=test_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -345,7 +355,7 @@ async def create( self, url: str, *, - zone_id: str, + zone_id: str | None = None, region: Literal[ "asia-east1", "asia-northeast1", @@ -395,12 +405,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return await self._post( - f"/zones/{zone_id}/speed_api/pages/{url}/tests", + path_template("/zones/{zone_id}/speed_api/pages/{url}/tests", zone_id=zone_id, url=url), body=await async_maybe_transform({"region": region}, test_create_params.TestCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -416,7 +428,7 @@ def list( self, url: str, *, - zone_id: str, + zone_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, region: Literal[ @@ -468,12 +480,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return self._get_api_list( - f"/zones/{zone_id}/speed_api/pages/{url}/tests", + path_template("/zones/{zone_id}/speed_api/pages/{url}/tests", zone_id=zone_id, url=url), page=AsyncV4PagePaginationArray[Test], options=make_request_options( extra_headers=extra_headers, @@ -496,7 +510,7 @@ async def delete( self, url: str, *, - zone_id: str, + zone_id: str | None = None, region: Literal[ "asia-east1", "asia-northeast1", @@ -548,12 +562,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return await self._delete( - f"/zones/{zone_id}/speed_api/pages/{url}/tests", + path_template("/zones/{zone_id}/speed_api/pages/{url}/tests", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -569,7 +585,7 @@ async def get( self, test_id: str, *, - zone_id: str, + zone_id: str | None = None, url: 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. @@ -594,6 +610,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: @@ -601,7 +619,9 @@ async def get( if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return await self._get( - f"/zones/{zone_id}/speed_api/pages/{url}/tests/{test_id}", + path_template( + "/zones/{zone_id}/speed_api/pages/{url}/tests/{test_id}", zone_id=zone_id, url=url, test_id=test_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/speed/schedule.py b/src/cloudflare/resources/speed/schedule.py index eb8e477807e..7bae23c10dd 100644 --- a/src/cloudflare/resources/speed/schedule.py +++ b/src/cloudflare/resources/speed/schedule.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def create( self, url: str, *, - zone_id: str, + zone_id: str | None = None, frequency: Literal["DAILY", "WEEKLY"] | Omit = omit, region: Literal[ "asia-east1", @@ -105,12 +105,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return self._post( - f"/zones/{zone_id}/speed_api/schedule/{url}", + path_template("/zones/{zone_id}/speed_api/schedule/{url}", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -132,7 +134,7 @@ def delete( self, url: str, *, - zone_id: str, + zone_id: str | None = None, region: Literal[ "asia-east1", "asia-northeast1", @@ -182,12 +184,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return self._delete( - f"/zones/{zone_id}/speed_api/schedule/{url}", + path_template("/zones/{zone_id}/speed_api/schedule/{url}", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -203,7 +207,7 @@ def get( self, url: str, *, - zone_id: str, + zone_id: str | None = None, region: Literal[ "asia-east1", "asia-northeast1", @@ -253,12 +257,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return self._get( - f"/zones/{zone_id}/speed_api/schedule/{url}", + path_template("/zones/{zone_id}/speed_api/schedule/{url}", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -295,7 +301,7 @@ async def create( self, url: str, *, - zone_id: str, + zone_id: str | None = None, frequency: Literal["DAILY", "WEEKLY"] | Omit = omit, region: Literal[ "asia-east1", @@ -349,12 +355,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return await self._post( - f"/zones/{zone_id}/speed_api/schedule/{url}", + path_template("/zones/{zone_id}/speed_api/schedule/{url}", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -376,7 +384,7 @@ async def delete( self, url: str, *, - zone_id: str, + zone_id: str | None = None, region: Literal[ "asia-east1", "asia-northeast1", @@ -426,12 +434,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return await self._delete( - f"/zones/{zone_id}/speed_api/schedule/{url}", + path_template("/zones/{zone_id}/speed_api/schedule/{url}", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -447,7 +457,7 @@ async def get( self, url: str, *, - zone_id: str, + zone_id: str | None = None, region: Literal[ "asia-east1", "asia-northeast1", @@ -497,12 +507,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not url: raise ValueError(f"Expected a non-empty value for `url` but received {url!r}") return await self._get( - f"/zones/{zone_id}/speed_api/schedule/{url}", + path_template("/zones/{zone_id}/speed_api/schedule/{url}", zone_id=zone_id, url=url), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ssl/analyze.py b/src/cloudflare/resources/ssl/analyze.py index 4d979fdab27..bbf38bf7631 100644 --- a/src/cloudflare/resources/ssl/analyze.py +++ b/src/cloudflare/resources/ssl/analyze.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> AnalyzeResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, bundle_method: BundleMethod | Omit = omit, certificate: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -80,10 +80,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/ssl/analyze", + path_template("/zones/{zone_id}/ssl/analyze", zone_id=zone_id), body=maybe_transform( { "bundle_method": bundle_method, @@ -125,7 +127,7 @@ def with_streaming_response(self) -> AsyncAnalyzeResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, bundle_method: BundleMethod | Omit = omit, certificate: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -157,10 +159,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/ssl/analyze", + path_template("/zones/{zone_id}/ssl/analyze", zone_id=zone_id), body=await async_maybe_transform( { "bundle_method": bundle_method, diff --git a/src/cloudflare/resources/ssl/api.md b/src/cloudflare/resources/ssl/api.md new file mode 100644 index 00000000000..3d0e264b2a4 --- /dev/null +++ b/src/cloudflare/resources/ssl/api.md @@ -0,0 +1,85 @@ +# SSL + +## Analyze + +Methods: + +- client.ssl.analyze.create(\*, zone_id, \*\*params) -> object + +## CertificatePacks + +Types: + +```python +from cloudflare.types.ssl import ( + Host, + RequestValidity, + Status, + ValidationMethod, + CertificatePackCreateResponse, + CertificatePackListResponse, + CertificatePackDeleteResponse, + CertificatePackEditResponse, + CertificatePackGetResponse, +) +``` + +Methods: + +- client.ssl.certificate_packs.create(\*, zone_id, \*\*params) -> Optional[CertificatePackCreateResponse] +- client.ssl.certificate_packs.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[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 + +Types: + +```python +from cloudflare.types.ssl.certificate_packs import QuotaGetResponse +``` + +Methods: + +- client.ssl.certificate_packs.quota.get(\*, zone_id) -> Optional[QuotaGetResponse] + +## Recommendations + +Types: + +```python +from cloudflare.types.ssl import RecommendationGetResponse +``` + +Methods: + +- client.ssl.recommendations.get(\*, zone_id) -> RecommendationGetResponse + +## Universal + +### Settings + +Types: + +```python +from cloudflare.types.ssl.universal import UniversalSSLSettings +``` + +Methods: + +- client.ssl.universal.settings.edit(\*, zone_id, \*\*params) -> Optional[UniversalSSLSettings] +- client.ssl.universal.settings.get(\*, zone_id) -> Optional[UniversalSSLSettings] + +## Verification + +Types: + +```python +from cloudflare.types.ssl import Verification, VerificationEditResponse, VerificationGetResponse +``` + +Methods: + +- client.ssl.verification.edit(certificate_pack_id, \*, zone_id, \*\*params) -> Optional[VerificationEditResponse] +- client.ssl.verification.get(\*, zone_id, \*\*params) -> Optional[VerificationGetResponse] diff --git a/src/cloudflare/resources/ssl/certificate_packs/certificate_packs.py b/src/cloudflare/resources/ssl/certificate_packs/certificate_packs.py index 773b8ed172d..62643b003c4 100644 --- a/src/cloudflare/resources/ssl/certificate_packs/certificate_packs.py +++ b/src/cloudflare/resources/ssl/certificate_packs/certificate_packs.py @@ -16,7 +16,7 @@ AsyncQuotaResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -66,7 +66,7 @@ def with_streaming_response(self) -> CertificatePacksResourceWithStreamingRespon def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate_authority: Literal["google", "lets_encrypt", "ssl_com"], hosts: SequenceNotStr[Host], type: Literal["advanced"], @@ -110,10 +110,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/ssl/certificate_packs/order", + path_template("/zones/{zone_id}/ssl/certificate_packs/order", zone_id=zone_id), body=maybe_transform( { "certificate_authority": certificate_authority, @@ -138,7 +140,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, deploy: Literal["staging", "production"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -172,10 +174,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/ssl/certificate_packs", + path_template("/zones/{zone_id}/ssl/certificate_packs", zone_id=zone_id), page=SyncV4PagePaginationArray[CertificatePackListResponse], options=make_request_options( extra_headers=extra_headers, @@ -199,7 +203,7 @@ def delete( self, certificate_pack_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -223,6 +227,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_pack_id: @@ -230,7 +236,11 @@ def delete( f"Expected a non-empty value for `certificate_pack_id` but received {certificate_pack_id!r}" ) return self._delete( - f"/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + path_template( + "/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + zone_id=zone_id, + certificate_pack_id=certificate_pack_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -245,7 +255,7 @@ def edit( self, certificate_pack_id: str, *, - zone_id: str, + zone_id: str | None = None, cloudflare_branding: 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. @@ -275,6 +285,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_pack_id: @@ -282,7 +294,11 @@ def edit( f"Expected a non-empty value for `certificate_pack_id` but received {certificate_pack_id!r}" ) return self._patch( - f"/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + path_template( + "/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + zone_id=zone_id, + certificate_pack_id=certificate_pack_id, + ), body=maybe_transform( {"cloudflare_branding": cloudflare_branding}, certificate_pack_edit_params.CertificatePackEditParams ), @@ -300,7 +316,7 @@ def get( self, certificate_pack_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -324,6 +340,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_pack_id: @@ -331,7 +349,11 @@ def get( f"Expected a non-empty value for `certificate_pack_id` but received {certificate_pack_id!r}" ) return self._get( - f"/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + path_template( + "/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + zone_id=zone_id, + certificate_pack_id=certificate_pack_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -370,7 +392,7 @@ def with_streaming_response(self) -> AsyncCertificatePacksResourceWithStreamingR async def create( self, *, - zone_id: str, + zone_id: str | None = None, certificate_authority: Literal["google", "lets_encrypt", "ssl_com"], hosts: SequenceNotStr[Host], type: Literal["advanced"], @@ -414,10 +436,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/ssl/certificate_packs/order", + path_template("/zones/{zone_id}/ssl/certificate_packs/order", zone_id=zone_id), body=await async_maybe_transform( { "certificate_authority": certificate_authority, @@ -442,7 +466,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, deploy: Literal["staging", "production"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -476,10 +500,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/ssl/certificate_packs", + path_template("/zones/{zone_id}/ssl/certificate_packs", zone_id=zone_id), page=AsyncV4PagePaginationArray[CertificatePackListResponse], options=make_request_options( extra_headers=extra_headers, @@ -503,7 +529,7 @@ async def delete( self, certificate_pack_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -527,6 +553,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_pack_id: @@ -534,7 +562,11 @@ async def delete( f"Expected a non-empty value for `certificate_pack_id` but received {certificate_pack_id!r}" ) return await self._delete( - f"/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + path_template( + "/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + zone_id=zone_id, + certificate_pack_id=certificate_pack_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -549,7 +581,7 @@ async def edit( self, certificate_pack_id: str, *, - zone_id: str, + zone_id: str | None = None, cloudflare_branding: 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. @@ -579,6 +611,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_pack_id: @@ -586,7 +620,11 @@ async def edit( f"Expected a non-empty value for `certificate_pack_id` but received {certificate_pack_id!r}" ) return await self._patch( - f"/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + path_template( + "/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + zone_id=zone_id, + certificate_pack_id=certificate_pack_id, + ), body=await async_maybe_transform( {"cloudflare_branding": cloudflare_branding}, certificate_pack_edit_params.CertificatePackEditParams ), @@ -604,7 +642,7 @@ async def get( self, certificate_pack_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -628,6 +666,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_pack_id: @@ -635,7 +675,11 @@ async def get( f"Expected a non-empty value for `certificate_pack_id` but received {certificate_pack_id!r}" ) return await self._get( - f"/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + path_template( + "/zones/{zone_id}/ssl/certificate_packs/{certificate_pack_id}", + zone_id=zone_id, + certificate_pack_id=certificate_pack_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ssl/certificate_packs/quota.py b/src/cloudflare/resources/ssl/certificate_packs/quota.py index 9dc81bd7913..08734ac421c 100644 --- a/src/cloudflare/resources/ssl/certificate_packs/quota.py +++ b/src/cloudflare/resources/ssl/certificate_packs/quota.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> QuotaResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/ssl/certificate_packs/quota", + path_template("/zones/{zone_id}/ssl/certificate_packs/quota", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -105,7 +108,7 @@ def with_streaming_response(self) -> AsyncQuotaResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,10 +130,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/ssl/certificate_packs/quota", + path_template("/zones/{zone_id}/ssl/certificate_packs/quota", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ssl/recommendations.py b/src/cloudflare/resources/ssl/recommendations.py index c9d81d87c87..ac79e98b332 100644 --- a/src/cloudflare/resources/ssl/recommendations.py +++ b/src/cloudflare/resources/ssl/recommendations.py @@ -8,6 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +48,7 @@ def with_streaming_response(self) -> RecommendationsResourceWithStreamingRespons def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/ssl/recommendation", + path_template("/zones/{zone_id}/ssl/recommendation", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -106,7 +109,7 @@ def with_streaming_response(self) -> AsyncRecommendationsResourceWithStreamingRe async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -126,10 +129,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/ssl/recommendation", + path_template("/zones/{zone_id}/ssl/recommendation", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ssl/universal/settings.py b/src/cloudflare/resources/ssl/universal/settings.py index a16e956a36f..a470b4797f2 100644 --- a/src/cloudflare/resources/ssl/universal/settings.py +++ b/src/cloudflare/resources/ssl/universal/settings.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: def edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -96,10 +96,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/ssl/universal/settings", + path_template("/zones/{zone_id}/ssl/universal/settings", zone_id=zone_id), body=maybe_transform({"enabled": enabled}, setting_edit_params.SettingEditParams), options=make_request_options( extra_headers=extra_headers, @@ -114,7 +116,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -136,10 +138,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/ssl/universal/settings", + path_template("/zones/{zone_id}/ssl/universal/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -174,7 +178,7 @@ def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: async def edit( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -223,10 +227,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/ssl/universal/settings", + path_template("/zones/{zone_id}/ssl/universal/settings", zone_id=zone_id), body=await async_maybe_transform({"enabled": enabled}, setting_edit_params.SettingEditParams), options=make_request_options( extra_headers=extra_headers, @@ -241,7 +247,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -263,10 +269,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/ssl/universal/settings", + path_template("/zones/{zone_id}/ssl/universal/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/ssl/verification.py b/src/cloudflare/resources/ssl/verification.py index 7262218e55a..294c5ce1618 100644 --- a/src/cloudflare/resources/ssl/verification.py +++ b/src/cloudflare/resources/ssl/verification.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def edit( self, certificate_pack_id: str, *, - zone_id: str, + zone_id: str | None = None, validation_method: Literal["http", "cname", "txt", "email"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -81,6 +81,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_pack_id: @@ -88,7 +90,11 @@ def edit( f"Expected a non-empty value for `certificate_pack_id` but received {certificate_pack_id!r}" ) return self._patch( - f"/zones/{zone_id}/ssl/verification/{certificate_pack_id}", + path_template( + "/zones/{zone_id}/ssl/verification/{certificate_pack_id}", + zone_id=zone_id, + certificate_pack_id=certificate_pack_id, + ), body=maybe_transform( {"validation_method": validation_method}, verification_edit_params.VerificationEditParams ), @@ -105,7 +111,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, retry: 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. @@ -130,10 +136,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/ssl/verification", + path_template("/zones/{zone_id}/ssl/verification", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -170,7 +178,7 @@ async def edit( self, certificate_pack_id: str, *, - zone_id: str, + zone_id: str | None = None, validation_method: Literal["http", "cname", "txt", "email"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -201,6 +209,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not certificate_pack_id: @@ -208,7 +218,11 @@ async def edit( f"Expected a non-empty value for `certificate_pack_id` but received {certificate_pack_id!r}" ) return await self._patch( - f"/zones/{zone_id}/ssl/verification/{certificate_pack_id}", + path_template( + "/zones/{zone_id}/ssl/verification/{certificate_pack_id}", + zone_id=zone_id, + certificate_pack_id=certificate_pack_id, + ), body=await async_maybe_transform( {"validation_method": validation_method}, verification_edit_params.VerificationEditParams ), @@ -225,7 +239,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, retry: 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. @@ -250,10 +264,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/ssl/verification", + path_template("/zones/{zone_id}/ssl/verification", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/stream/api.md b/src/cloudflare/resources/stream/api.md new file mode 100644 index 00000000000..272b1510939 --- /dev/null +++ b/src/cloudflare/resources/stream/api.md @@ -0,0 +1,227 @@ +# Stream + +Types: + +```python +from cloudflare.types.stream import AllowedOrigins, Video +``` + +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.edit(identifier, \*, account_id, \*\*params) -> Optional[Video] +- client.stream.get(identifier, \*, account_id) -> Optional[Video] + +## AudioTracks + +Types: + +```python +from cloudflare.types.stream import Audio, AudioTrackDeleteResponse, AudioTrackGetResponse +``` + +Methods: + +- 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) -> Optional[AudioTrackGetResponse] + +## 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[Video] + +## 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 WebhookUpdateResponse, WebhookDeleteResponse, WebhookGetResponse +``` + +Methods: + +- client.stream.webhooks.update(\*, account_id, \*\*params) -> Optional[WebhookUpdateResponse] +- client.stream.webhooks.delete(\*, account_id) -> str +- client.stream.webhooks.get(\*, account_id) -> Optional[WebhookGetResponse] + +## 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 + +Types: + +```python +from cloudflare.types.stream import ( + DownloadCreateResponse, + DownloadDeleteResponse, + DownloadGetResponse, +) +``` + +Methods: + +- client.stream.downloads.create(identifier, \*, account_id) -> Optional[DownloadCreateResponse] +- client.stream.downloads.delete(identifier, \*, account_id) -> str +- client.stream.downloads.get(identifier, \*, account_id) -> Optional[DownloadGetResponse] + +## Embed + +Types: + +```python +from cloudflare.types.stream import EmbedGetResponse +``` + +Methods: + +- client.stream.embed.get(identifier, \*, account_id) -> str + +## Token + +Types: + +```python +from cloudflare.types.stream import TokenCreateResponse +``` + +Methods: + +- client.stream.token.create(identifier, \*, account_id, \*\*params) -> Optional[TokenCreateResponse] diff --git a/src/cloudflare/resources/stream/audio_tracks.py b/src/cloudflare/resources/stream/audio_tracks.py index 003e54f7bae..213ae868e08 100644 --- a/src/cloudflare/resources/stream/audio_tracks.py +++ b/src/cloudflare/resources/stream/audio_tracks.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def delete( self, audio_identifier: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -79,6 +79,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -86,7 +88,12 @@ def delete( if not audio_identifier: raise ValueError(f"Expected a non-empty value for `audio_identifier` but received {audio_identifier!r}") return self._delete( - f"/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}", + path_template( + "/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}", + account_id=account_id, + identifier=identifier, + audio_identifier=audio_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -101,7 +108,7 @@ def copy( self, identifier: str, *, - account_id: str, + account_id: str | None = None, label: str, url: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -134,12 +141,16 @@ def copy( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._post( - f"/accounts/{account_id}/stream/{identifier}/audio/copy", + path_template( + "/accounts/{account_id}/stream/{identifier}/audio/copy", account_id=account_id, identifier=identifier + ), body=maybe_transform( { "label": label, @@ -161,7 +172,7 @@ def edit( self, audio_identifier: str, *, - account_id: str, + account_id: str | None = None, identifier: str, default: bool | Omit = omit, label: str | Omit = omit, @@ -198,6 +209,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -205,7 +218,12 @@ def edit( if not audio_identifier: raise ValueError(f"Expected a non-empty value for `audio_identifier` but received {audio_identifier!r}") return self._patch( - f"/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}", + path_template( + "/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}", + account_id=account_id, + identifier=identifier, + audio_identifier=audio_identifier, + ), body=maybe_transform( { "default": default, @@ -227,7 +245,7 @@ def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -253,12 +271,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._get( - f"/accounts/{account_id}/stream/{identifier}/audio", + path_template( + "/accounts/{account_id}/stream/{identifier}/audio", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -294,7 +316,7 @@ async def delete( self, audio_identifier: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -323,6 +345,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -330,7 +354,12 @@ async def delete( if not audio_identifier: raise ValueError(f"Expected a non-empty value for `audio_identifier` but received {audio_identifier!r}") return await self._delete( - f"/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}", + path_template( + "/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}", + account_id=account_id, + identifier=identifier, + audio_identifier=audio_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -345,7 +374,7 @@ async def copy( self, identifier: str, *, - account_id: str, + account_id: str | None = None, label: str, url: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -378,12 +407,16 @@ async def copy( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._post( - f"/accounts/{account_id}/stream/{identifier}/audio/copy", + path_template( + "/accounts/{account_id}/stream/{identifier}/audio/copy", account_id=account_id, identifier=identifier + ), body=await async_maybe_transform( { "label": label, @@ -405,7 +438,7 @@ async def edit( self, audio_identifier: str, *, - account_id: str, + account_id: str | None = None, identifier: str, default: bool | Omit = omit, label: str | Omit = omit, @@ -442,6 +475,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -449,7 +484,12 @@ async def edit( if not audio_identifier: raise ValueError(f"Expected a non-empty value for `audio_identifier` but received {audio_identifier!r}") return await self._patch( - f"/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}", + path_template( + "/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}", + account_id=account_id, + identifier=identifier, + audio_identifier=audio_identifier, + ), body=await async_maybe_transform( { "default": default, @@ -471,7 +511,7 @@ async def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -497,12 +537,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._get( - f"/accounts/{account_id}/stream/{identifier}/audio", + path_template( + "/accounts/{account_id}/stream/{identifier}/audio", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/stream/captions/captions.py b/src/cloudflare/resources/stream/captions/captions.py index 18ee4b239ee..52b7dcd4ff5 100644 --- a/src/cloudflare/resources/stream/captions/captions.py +++ b/src/cloudflare/resources/stream/captions/captions.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -56,7 +57,7 @@ def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -80,12 +81,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._get_api_list( - f"/accounts/{account_id}/stream/{identifier}/captions", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions", account_id=account_id, identifier=identifier + ), page=SyncSinglePage[Caption], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -122,7 +127,7 @@ def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -146,12 +151,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._get_api_list( - f"/accounts/{account_id}/stream/{identifier}/captions", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions", account_id=account_id, identifier=identifier + ), page=AsyncSinglePage[Caption], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/stream/captions/language/language.py b/src/cloudflare/resources/stream/captions/language/language.py index c93200cc835..151ec9bb169 100644 --- a/src/cloudflare/resources/stream/captions/language/language.py +++ b/src/cloudflare/resources/stream/captions/language/language.py @@ -15,7 +15,7 @@ AsyncVttResourceWithStreamingResponse, ) from ....._types import Body, Query, Headers, NotGiven, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -61,7 +61,7 @@ def create( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -88,6 +88,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -95,7 +97,12 @@ def create( if not language: raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return self._post( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}/generate", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}/generate", + account_id=account_id, + identifier=identifier, + language=language, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -110,7 +117,7 @@ def update( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: str, file: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -141,6 +148,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -152,7 +161,12 @@ def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._put( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}", + account_id=account_id, + identifier=identifier, + language=language, + ), body=maybe_transform({"file": file}, language_update_params.LanguageUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -168,7 +182,7 @@ def delete( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -195,6 +209,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -202,7 +218,12 @@ def delete( if not language: raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return self._delete( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}", + account_id=account_id, + identifier=identifier, + language=language, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -217,7 +238,7 @@ def get( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -244,6 +265,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -251,7 +274,12 @@ def get( if not language: raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return self._get( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}", + account_id=account_id, + identifier=identifier, + language=language, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -291,7 +319,7 @@ async def create( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -318,6 +346,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -325,7 +355,12 @@ async def create( if not language: raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return await self._post( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}/generate", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}/generate", + account_id=account_id, + identifier=identifier, + language=language, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -340,7 +375,7 @@ async def update( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: str, file: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -371,6 +406,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -382,7 +419,12 @@ async def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._put( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}", + account_id=account_id, + identifier=identifier, + language=language, + ), body=await async_maybe_transform({"file": file}, language_update_params.LanguageUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -398,7 +440,7 @@ async def delete( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -425,6 +467,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -432,7 +476,12 @@ async def delete( if not language: raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return await self._delete( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}", + account_id=account_id, + identifier=identifier, + language=language, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -447,7 +496,7 @@ async def get( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -474,6 +523,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -481,7 +532,12 @@ async def get( if not language: raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return await self._get( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}", + account_id=account_id, + identifier=identifier, + language=language, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/stream/captions/language/vtt.py b/src/cloudflare/resources/stream/captions/language/vtt.py index 40884504871..6b2c962cc66 100644 --- a/src/cloudflare/resources/stream/captions/language/vtt.py +++ b/src/cloudflare/resources/stream/captions/language/vtt.py @@ -5,6 +5,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -42,7 +43,7 @@ def get( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -69,6 +70,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -77,7 +80,12 @@ def get( raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") extra_headers = {"Accept": "text/vtt", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}/vtt", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}/vtt", + account_id=account_id, + identifier=identifier, + language=language, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -109,7 +117,7 @@ async def get( self, language: str, *, - account_id: str, + account_id: str | None = None, identifier: 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. @@ -136,6 +144,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: @@ -144,7 +154,12 @@ async def get( raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") extra_headers = {"Accept": "text/vtt", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/stream/{identifier}/captions/{language}/vtt", + path_template( + "/accounts/{account_id}/stream/{identifier}/captions/{language}/vtt", + account_id=account_id, + identifier=identifier, + language=language, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/stream/clip.py b/src/cloudflare/resources/stream/clip.py index 27ba2b3386e..939f5d0f756 100644 --- a/src/cloudflare/resources/stream/clip.py +++ b/src/cloudflare/resources/stream/clip.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> ClipResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, clipped_from_video_uid: str, end_time_seconds: int, start_time_seconds: int, @@ -117,10 +117,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/clip", + path_template("/accounts/{account_id}/stream/clip", account_id=account_id), body=maybe_transform( { "clipped_from_video_uid": clipped_from_video_uid, @@ -173,7 +175,7 @@ def with_streaming_response(self) -> AsyncClipResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, clipped_from_video_uid: str, end_time_seconds: int, start_time_seconds: int, @@ -241,10 +243,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/clip", + path_template("/accounts/{account_id}/stream/clip", account_id=account_id), body=await async_maybe_transform( { "clipped_from_video_uid": clipped_from_video_uid, diff --git a/src/cloudflare/resources/stream/copy.py b/src/cloudflare/resources/stream/copy.py index 3461c195ff6..85846e6b20d 100644 --- a/src/cloudflare/resources/stream/copy.py +++ b/src/cloudflare/resources/stream/copy.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import path_template, maybe_transform, strip_not_given, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> CopyResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, allowed_origins: SequenceNotStr[AllowedOrigins] | Omit = omit, creator: str | Omit = omit, input: str | Omit = omit, @@ -117,11 +117,13 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"Upload-Creator": upload_creator}), **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/stream/copy", + path_template("/accounts/{account_id}/stream/copy", account_id=account_id), body=maybe_transform( { "allowed_origins": allowed_origins, @@ -171,7 +173,7 @@ def with_streaming_response(self) -> AsyncCopyResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, allowed_origins: SequenceNotStr[AllowedOrigins] | Omit = omit, creator: str | Omit = omit, input: str | Omit = omit, @@ -239,11 +241,13 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"Upload-Creator": upload_creator}), **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/stream/copy", + path_template("/accounts/{account_id}/stream/copy", account_id=account_id), body=await async_maybe_transform( { "allowed_origins": allowed_origins, diff --git a/src/cloudflare/resources/stream/direct_upload.py b/src/cloudflare/resources/stream/direct_upload.py index e1bcd10bfe5..ff83d3c787f 100644 --- a/src/cloudflare/resources/stream/direct_upload.py +++ b/src/cloudflare/resources/stream/direct_upload.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import path_template, maybe_transform, strip_not_given, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> DirectUploadResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, max_duration_seconds: int, allowed_origins: SequenceNotStr[AllowedOrigins] | Omit = omit, creator: str | Omit = omit, @@ -111,11 +111,13 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"Upload-Creator": upload_creator}), **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/stream/direct_upload", + path_template("/accounts/{account_id}/stream/direct_upload", account_id=account_id), body=maybe_transform( { "max_duration_seconds": max_duration_seconds, @@ -164,7 +166,7 @@ def with_streaming_response(self) -> AsyncDirectUploadResourceWithStreamingRespo async def create( self, *, - account_id: str, + account_id: str | None = None, max_duration_seconds: int, allowed_origins: SequenceNotStr[AllowedOrigins] | Omit = omit, creator: str | Omit = omit, @@ -226,11 +228,13 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") extra_headers = {**strip_not_given({"Upload-Creator": upload_creator}), **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/stream/direct_upload", + path_template("/accounts/{account_id}/stream/direct_upload", account_id=account_id), body=await async_maybe_transform( { "max_duration_seconds": max_duration_seconds, diff --git a/src/cloudflare/resources/stream/downloads.py b/src/cloudflare/resources/stream/downloads.py index fae3000b7d1..ffce99c8df8 100644 --- a/src/cloudflare/resources/stream/downloads.py +++ b/src/cloudflare/resources/stream/downloads.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +49,7 @@ def create( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -75,12 +76,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._post( - f"/accounts/{account_id}/stream/{identifier}/downloads", + path_template( + "/accounts/{account_id}/stream/{identifier}/downloads", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -95,7 +100,7 @@ def delete( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -121,12 +126,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._delete( - f"/accounts/{account_id}/stream/{identifier}/downloads", + path_template( + "/accounts/{account_id}/stream/{identifier}/downloads", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -141,7 +150,7 @@ def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -165,12 +174,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._get( - f"/accounts/{account_id}/stream/{identifier}/downloads", + path_template( + "/accounts/{account_id}/stream/{identifier}/downloads", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -206,7 +219,7 @@ async def create( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -233,12 +246,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._post( - f"/accounts/{account_id}/stream/{identifier}/downloads", + path_template( + "/accounts/{account_id}/stream/{identifier}/downloads", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -253,7 +270,7 @@ async def delete( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -279,12 +296,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._delete( - f"/accounts/{account_id}/stream/{identifier}/downloads", + path_template( + "/accounts/{account_id}/stream/{identifier}/downloads", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -299,7 +320,7 @@ async def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -323,12 +344,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._get( - f"/accounts/{account_id}/stream/{identifier}/downloads", + path_template( + "/accounts/{account_id}/stream/{identifier}/downloads", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/stream/embed.py b/src/cloudflare/resources/stream/embed.py index ef990657f4d..3efc505a62a 100644 --- a/src/cloudflare/resources/stream/embed.py +++ b/src/cloudflare/resources/stream/embed.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -42,7 +43,7 @@ def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,13 +69,17 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") extra_headers = {"Accept": "text/html", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/stream/{identifier}/embed", + path_template( + "/accounts/{account_id}/stream/{identifier}/embed", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -106,7 +111,7 @@ async def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -132,13 +137,17 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") extra_headers = {"Accept": "text/html", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/stream/{identifier}/embed", + path_template( + "/accounts/{account_id}/stream/{identifier}/embed", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/stream/keys.py b/src/cloudflare/resources/stream/keys.py index 3b0f5dbac2f..3b99aad41f0 100644 --- a/src/cloudflare/resources/stream/keys.py +++ b/src/cloudflare/resources/stream/keys.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> KeysResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -76,10 +76,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/keys", + path_template("/accounts/{account_id}/stream/keys", account_id=account_id), body=maybe_transform(body, key_create_params.KeyCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -95,7 +97,7 @@ def delete( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -119,12 +121,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._delete( - f"/accounts/{account_id}/stream/keys/{identifier}", + path_template( + "/accounts/{account_id}/stream/keys/{identifier}", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -138,7 +144,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -160,10 +166,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/keys", + path_template("/accounts/{account_id}/stream/keys", account_id=account_id), page=SyncSinglePage[KeyGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -195,7 +203,7 @@ def with_streaming_response(self) -> AsyncKeysResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -221,10 +229,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/keys", + path_template("/accounts/{account_id}/stream/keys", account_id=account_id), body=await async_maybe_transform(body, key_create_params.KeyCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -240,7 +250,7 @@ async def delete( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -264,12 +274,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._delete( - f"/accounts/{account_id}/stream/keys/{identifier}", + path_template( + "/accounts/{account_id}/stream/keys/{identifier}", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -283,7 +297,7 @@ async def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -305,10 +319,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/keys", + path_template("/accounts/{account_id}/stream/keys", account_id=account_id), page=AsyncSinglePage[KeyGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/stream/live_inputs/live_inputs.py b/src/cloudflare/resources/stream/live_inputs/live_inputs.py index 3badf065da5..c0a9d7fb541 100644 --- a/src/cloudflare/resources/stream/live_inputs/live_inputs.py +++ b/src/cloudflare/resources/stream/live_inputs/live_inputs.py @@ -15,7 +15,7 @@ AsyncOutputsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -60,7 +60,7 @@ def with_streaming_response(self) -> LiveInputsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, default_creator: str | Omit = omit, delete_recording_after_days: float | Omit = omit, enabled: bool | Omit = omit, @@ -105,10 +105,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/live_inputs", + path_template("/accounts/{account_id}/stream/live_inputs", account_id=account_id), body=maybe_transform( { "default_creator": default_creator, @@ -133,7 +135,7 @@ def update( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, default_creator: str | Omit = omit, delete_recording_after_days: float | Omit = omit, enabled: bool | Omit = omit, @@ -179,6 +181,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -186,7 +190,11 @@ def update( f"Expected a non-empty value for `live_input_identifier` but received {live_input_identifier!r}" ) return self._put( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), body=maybe_transform( { "default_creator": default_creator, @@ -210,7 +218,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, include_counts: 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. @@ -238,10 +246,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/live_inputs", + path_template("/accounts/{account_id}/stream/live_inputs", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -257,7 +267,7 @@ def delete( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -282,6 +292,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -290,7 +302,11 @@ def delete( ) extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -301,7 +317,7 @@ def get( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -325,6 +341,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -332,7 +350,11 @@ def get( f"Expected a non-empty value for `live_input_identifier` but received {live_input_identifier!r}" ) return self._get( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -371,7 +393,7 @@ def with_streaming_response(self) -> AsyncLiveInputsResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, default_creator: str | Omit = omit, delete_recording_after_days: float | Omit = omit, enabled: bool | Omit = omit, @@ -416,10 +438,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/live_inputs", + path_template("/accounts/{account_id}/stream/live_inputs", account_id=account_id), body=await async_maybe_transform( { "default_creator": default_creator, @@ -444,7 +468,7 @@ async def update( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, default_creator: str | Omit = omit, delete_recording_after_days: float | Omit = omit, enabled: bool | Omit = omit, @@ -490,6 +514,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -497,7 +523,11 @@ async def update( f"Expected a non-empty value for `live_input_identifier` but received {live_input_identifier!r}" ) return await self._put( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), body=await async_maybe_transform( { "default_creator": default_creator, @@ -521,7 +551,7 @@ async def update( async def list( self, *, - account_id: str, + account_id: str | None = None, include_counts: 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. @@ -549,10 +579,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/live_inputs", + path_template("/accounts/{account_id}/stream/live_inputs", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -570,7 +602,7 @@ async def delete( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -595,6 +627,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -603,7 +637,11 @@ async def delete( ) extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -614,7 +652,7 @@ async def get( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -638,6 +676,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -645,7 +685,11 @@ async def get( f"Expected a non-empty value for `live_input_identifier` but received {live_input_identifier!r}" ) return await self._get( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/stream/live_inputs/outputs.py b/src/cloudflare/resources/stream/live_inputs/outputs.py index ee3ab054e87..b41a61991c9 100644 --- a/src/cloudflare/resources/stream/live_inputs/outputs.py +++ b/src/cloudflare/resources/stream/live_inputs/outputs.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def create( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, stream_key: str, url: str, enabled: bool | Omit = omit, @@ -88,6 +88,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -95,7 +97,11 @@ def create( f"Expected a non-empty value for `live_input_identifier` but received {live_input_identifier!r}" ) return self._post( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), body=maybe_transform( { "stream_key": stream_key, @@ -118,7 +124,7 @@ def update( self, output_identifier: str, *, - account_id: str, + account_id: str | None = None, live_input_identifier: str, enabled: bool, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -152,6 +158,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -161,7 +169,12 @@ def update( if not output_identifier: raise ValueError(f"Expected a non-empty value for `output_identifier` but received {output_identifier!r}") return self._put( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + output_identifier=output_identifier, + ), body=maybe_transform({"enabled": enabled}, output_update_params.OutputUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -177,7 +190,7 @@ def list( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -201,6 +214,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -208,7 +223,11 @@ def list( f"Expected a non-empty value for `live_input_identifier` but received {live_input_identifier!r}" ) return self._get_api_list( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), page=SyncSinglePage[Output], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -220,7 +239,7 @@ def delete( self, output_identifier: str, *, - account_id: str, + account_id: str | None = None, live_input_identifier: 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. @@ -247,6 +266,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -257,7 +278,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `output_identifier` but received {output_identifier!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + output_identifier=output_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -289,7 +315,7 @@ async def create( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, stream_key: str, url: str, enabled: bool | Omit = omit, @@ -328,6 +354,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -335,7 +363,11 @@ async def create( f"Expected a non-empty value for `live_input_identifier` but received {live_input_identifier!r}" ) return await self._post( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), body=await async_maybe_transform( { "stream_key": stream_key, @@ -358,7 +390,7 @@ async def update( self, output_identifier: str, *, - account_id: str, + account_id: str | None = None, live_input_identifier: str, enabled: bool, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -392,6 +424,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -401,7 +435,12 @@ async def update( if not output_identifier: raise ValueError(f"Expected a non-empty value for `output_identifier` but received {output_identifier!r}") return await self._put( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + output_identifier=output_identifier, + ), body=await async_maybe_transform({"enabled": enabled}, output_update_params.OutputUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -417,7 +456,7 @@ def list( self, live_input_identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -441,6 +480,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -448,7 +489,11 @@ def list( f"Expected a non-empty value for `live_input_identifier` but received {live_input_identifier!r}" ) return self._get_api_list( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs", + account_id=account_id, + live_input_identifier=live_input_identifier, + ), page=AsyncSinglePage[Output], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -460,7 +505,7 @@ async def delete( self, output_identifier: str, *, - account_id: str, + account_id: str | None = None, live_input_identifier: 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. @@ -487,6 +532,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not live_input_identifier: @@ -497,7 +544,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `output_identifier` but received {output_identifier!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}", + path_template( + "/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}", + account_id=account_id, + live_input_identifier=live_input_identifier, + output_identifier=output_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/stream/stream.py b/src/cloudflare/resources/stream/stream.py index eb4d5610460..b8f8aeb18ab 100644 --- a/src/cloudflare/resources/stream/stream.py +++ b/src/cloudflare/resources/stream/stream.py @@ -57,7 +57,7 @@ AsyncVideosResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, strip_not_given, async_maybe_transform +from ..._utils import path_template, maybe_transform, strip_not_given, async_maybe_transform from .webhooks import ( WebhooksResource, AsyncWebhooksResource, @@ -207,7 +207,7 @@ def with_streaming_response(self) -> StreamResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, tus_resumable: Literal["1.0.0"], upload_length: int, direct_user: bool | Omit = omit, @@ -254,6 +254,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 {})} @@ -269,7 +271,7 @@ def create( **(extra_headers or {}), } return self._post( - f"/accounts/{account_id}/stream", + path_template("/accounts/{account_id}/stream", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -283,7 +285,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, after: Union[str, datetime] | Omit = omit, asc: bool | Omit = omit, @@ -356,10 +358,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream", + path_template("/accounts/{account_id}/stream", account_id=account_id), page=SyncSinglePage[Video], options=make_request_options( extra_headers=extra_headers, @@ -394,7 +398,7 @@ def delete( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -418,13 +422,15 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/stream/{identifier}", + path_template("/accounts/{account_id}/stream/{identifier}", account_id=account_id, identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -435,7 +441,7 @@ def edit( self, identifier: str, *, - account_id: str, + account_id: str | None = None, allowed_origins: SequenceNotStr[AllowedOrigins] | Omit = omit, creator: str | Omit = omit, max_duration_seconds: int | Omit = omit, @@ -504,12 +510,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._post( - f"/accounts/{account_id}/stream/{identifier}", + path_template("/accounts/{account_id}/stream/{identifier}", account_id=account_id, identifier=identifier), body=maybe_transform( { "allowed_origins": allowed_origins, @@ -539,7 +547,7 @@ def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -563,12 +571,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._get( - f"/accounts/{account_id}/stream/{identifier}", + path_template("/accounts/{account_id}/stream/{identifier}", account_id=account_id, identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -655,7 +665,7 @@ def with_streaming_response(self) -> AsyncStreamResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, tus_resumable: Literal["1.0.0"], upload_length: int, direct_user: bool | Omit = omit, @@ -702,6 +712,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 {})} @@ -717,7 +729,7 @@ async def create( **(extra_headers or {}), } return await self._post( - f"/accounts/{account_id}/stream", + path_template("/accounts/{account_id}/stream", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -733,7 +745,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, after: Union[str, datetime] | Omit = omit, asc: bool | Omit = omit, @@ -806,10 +818,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream", + path_template("/accounts/{account_id}/stream", account_id=account_id), page=AsyncSinglePage[Video], options=make_request_options( extra_headers=extra_headers, @@ -844,7 +858,7 @@ async def delete( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -868,13 +882,15 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/stream/{identifier}", + path_template("/accounts/{account_id}/stream/{identifier}", account_id=account_id, identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -885,7 +901,7 @@ async def edit( self, identifier: str, *, - account_id: str, + account_id: str | None = None, allowed_origins: SequenceNotStr[AllowedOrigins] | Omit = omit, creator: str | Omit = omit, max_duration_seconds: int | Omit = omit, @@ -954,12 +970,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._post( - f"/accounts/{account_id}/stream/{identifier}", + path_template("/accounts/{account_id}/stream/{identifier}", account_id=account_id, identifier=identifier), body=await async_maybe_transform( { "allowed_origins": allowed_origins, @@ -989,7 +1007,7 @@ async def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1013,12 +1031,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._get( - f"/accounts/{account_id}/stream/{identifier}", + path_template("/accounts/{account_id}/stream/{identifier}", account_id=account_id, identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/stream/token.py b/src/cloudflare/resources/stream/token.py index fdf95f4ab80..fac02b60e45 100644 --- a/src/cloudflare/resources/stream/token.py +++ b/src/cloudflare/resources/stream/token.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def create( self, identifier: str, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, access_rules: Iterable[token_create_params.AccessRule] | Omit = omit, downloadable: bool | Omit = omit, @@ -104,12 +104,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._post( - f"/accounts/{account_id}/stream/{identifier}/token", + path_template( + "/accounts/{account_id}/stream/{identifier}/token", account_id=account_id, identifier=identifier + ), body=maybe_transform( { "id": id, @@ -157,7 +161,7 @@ async def create( self, identifier: str, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, access_rules: Iterable[token_create_params.AccessRule] | Omit = omit, downloadable: bool | Omit = omit, @@ -213,12 +217,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._post( - f"/accounts/{account_id}/stream/{identifier}/token", + path_template( + "/accounts/{account_id}/stream/{identifier}/token", account_id=account_id, identifier=identifier + ), body=await async_maybe_transform( { "id": id, diff --git a/src/cloudflare/resources/stream/videos.py b/src/cloudflare/resources/stream/videos.py index 2d8d2355ff1..e62acfbb4cf 100644 --- a/src/cloudflare/resources/stream/videos.py +++ b/src/cloudflare/resources/stream/videos.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> VideosResourceWithStreamingResponse: def storage_usage( self, *, - account_id: str, + account_id: str | None = None, creator: 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. @@ -72,10 +72,12 @@ def storage_usage( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/storage-usage", + path_template("/accounts/{account_id}/stream/storage-usage", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -111,7 +113,7 @@ def with_streaming_response(self) -> AsyncVideosResourceWithStreamingResponse: async def storage_usage( self, *, - account_id: str, + account_id: str | None = None, creator: 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. @@ -136,10 +138,12 @@ async def storage_usage( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/storage-usage", + path_template("/accounts/{account_id}/stream/storage-usage", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/stream/watermarks.py b/src/cloudflare/resources/stream/watermarks.py index b215e4a8468..7e0e1056ef3 100644 --- a/src/cloudflare/resources/stream/watermarks.py +++ b/src/cloudflare/resources/stream/watermarks.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> WatermarksResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, opacity: float | Omit = omit, padding: float | Omit = omit, @@ -99,10 +99,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/watermarks", + path_template("/accounts/{account_id}/stream/watermarks", account_id=account_id), body=maybe_transform( { "name": name, @@ -127,7 +129,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -149,10 +151,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/watermarks", + path_template("/accounts/{account_id}/stream/watermarks", account_id=account_id), page=SyncSinglePage[Watermark], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -164,7 +168,7 @@ def delete( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -188,12 +192,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._delete( - f"/accounts/{account_id}/stream/watermarks/{identifier}", + path_template( + "/accounts/{account_id}/stream/watermarks/{identifier}", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -208,7 +216,7 @@ def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -232,12 +240,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._get( - f"/accounts/{account_id}/stream/watermarks/{identifier}", + path_template( + "/accounts/{account_id}/stream/watermarks/{identifier}", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -272,7 +284,7 @@ def with_streaming_response(self) -> AsyncWatermarksResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, opacity: float | Omit = omit, padding: float | Omit = omit, @@ -322,10 +334,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/watermarks", + path_template("/accounts/{account_id}/stream/watermarks", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -350,7 +364,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -372,10 +386,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/watermarks", + path_template("/accounts/{account_id}/stream/watermarks", account_id=account_id), page=AsyncSinglePage[Watermark], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -387,7 +403,7 @@ async def delete( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -411,12 +427,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._delete( - f"/accounts/{account_id}/stream/watermarks/{identifier}", + path_template( + "/accounts/{account_id}/stream/watermarks/{identifier}", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -431,7 +451,7 @@ async def get( self, identifier: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -455,12 +475,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._get( - f"/accounts/{account_id}/stream/watermarks/{identifier}", + path_template( + "/accounts/{account_id}/stream/watermarks/{identifier}", account_id=account_id, identifier=identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/stream/webhooks.py b/src/cloudflare/resources/stream/webhooks.py index fedd9170bdb..685e9f8e3a1 100644 --- a/src/cloudflare/resources/stream/webhooks.py +++ b/src/cloudflare/resources/stream/webhooks.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> WebhooksResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, body_notification_url_1: str | Omit = omit, body_notification_url_2: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,10 +77,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/webhook", + path_template("/accounts/{account_id}/stream/webhook", account_id=account_id), body=maybe_transform( { "body_notification_url_1": body_notification_url_1, @@ -101,7 +103,7 @@ def update( def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,10 +125,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/webhook", + path_template("/accounts/{account_id}/stream/webhook", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -140,7 +144,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -162,10 +166,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/webhook", + path_template("/accounts/{account_id}/stream/webhook", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -200,7 +206,7 @@ def with_streaming_response(self) -> AsyncWebhooksResourceWithStreamingResponse: async def update( self, *, - account_id: str, + account_id: str | None = None, body_notification_url_1: str | Omit = omit, body_notification_url_2: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -228,10 +234,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/webhook", + path_template("/accounts/{account_id}/stream/webhook", account_id=account_id), body=await async_maybe_transform( { "body_notification_url_1": body_notification_url_1, @@ -252,7 +260,7 @@ async def update( async def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -274,10 +282,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/webhook", + path_template("/accounts/{account_id}/stream/webhook", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -291,7 +301,7 @@ async def delete( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -313,10 +323,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/stream/webhook", + path_template("/accounts/{account_id}/stream/webhook", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/token_validation/api.md b/src/cloudflare/resources/token_validation/api.md new file mode 100644 index 00000000000..98ecf33ddf8 --- /dev/null +++ b/src/cloudflare/resources/token_validation/api.md @@ -0,0 +1,51 @@ +# TokenValidation + +## Configuration + +Types: + +```python +from cloudflare.types.token_validation import ( + TokenConfig, + ConfigurationDeleteResponse, + ConfigurationEditResponse, +) +``` + +Methods: + +- 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 + +### Credentials + +Types: + +```python +from cloudflare.types.token_validation.configuration import CredentialUpdateResponse +``` + +Methods: + +- client.token_validation.configuration.credentials.update(config_id, \*, zone_id, \*\*params) -> CredentialUpdateResponse + +## Rules + +Types: + +```python +from cloudflare.types.token_validation import TokenValidationRule +``` + +Methods: + +- 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/src/cloudflare/resources/token_validation/configuration/configuration.py b/src/cloudflare/resources/token_validation/configuration/configuration.py index b151f82ff13..25674c44c92 100644 --- a/src/cloudflare/resources/token_validation/configuration/configuration.py +++ b/src/cloudflare/resources/token_validation/configuration/configuration.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from .credentials import ( CredentialsResource, @@ -63,7 +63,7 @@ def with_streaming_response(self) -> ConfigurationResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, credentials: configuration_create_params.Credentials, description: str, title: str, @@ -90,10 +90,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/config", + path_template("/zones/{zone_id}/token_validation/config", zone_id=zone_id), body=maybe_transform( { "credentials": credentials, @@ -117,7 +119,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -145,10 +147,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/config", + path_template("/zones/{zone_id}/token_validation/config", zone_id=zone_id), page=SyncV4PagePaginationArray[TokenConfig], options=make_request_options( extra_headers=extra_headers, @@ -170,7 +174,7 @@ def delete( self, config_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -194,12 +198,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return self._delete( - f"/zones/{zone_id}/token_validation/config/{config_id}", + path_template("/zones/{zone_id}/token_validation/config/{config_id}", zone_id=zone_id, config_id=config_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -214,7 +220,7 @@ def edit( self, config_id: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, title: str | Omit = omit, token_sources: SequenceNotStr[str] | Omit = omit, @@ -241,12 +247,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return self._patch( - f"/zones/{zone_id}/token_validation/config/{config_id}", + path_template("/zones/{zone_id}/token_validation/config/{config_id}", zone_id=zone_id, config_id=config_id), body=maybe_transform( { "description": description, @@ -269,7 +277,7 @@ def get( self, config_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -293,12 +301,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return self._get( - f"/zones/{zone_id}/token_validation/config/{config_id}", + path_template("/zones/{zone_id}/token_validation/config/{config_id}", zone_id=zone_id, config_id=config_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -337,7 +347,7 @@ def with_streaming_response(self) -> AsyncConfigurationResourceWithStreamingResp async def create( self, *, - zone_id: str, + zone_id: str | None = None, credentials: configuration_create_params.Credentials, description: str, title: str, @@ -364,10 +374,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/config", + path_template("/zones/{zone_id}/token_validation/config", zone_id=zone_id), body=await async_maybe_transform( { "credentials": credentials, @@ -391,7 +403,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -419,10 +431,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/config", + path_template("/zones/{zone_id}/token_validation/config", zone_id=zone_id), page=AsyncV4PagePaginationArray[TokenConfig], options=make_request_options( extra_headers=extra_headers, @@ -444,7 +458,7 @@ async def delete( self, config_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -468,12 +482,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return await self._delete( - f"/zones/{zone_id}/token_validation/config/{config_id}", + path_template("/zones/{zone_id}/token_validation/config/{config_id}", zone_id=zone_id, config_id=config_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -488,7 +504,7 @@ async def edit( self, config_id: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, title: str | Omit = omit, token_sources: SequenceNotStr[str] | Omit = omit, @@ -515,12 +531,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return await self._patch( - f"/zones/{zone_id}/token_validation/config/{config_id}", + path_template("/zones/{zone_id}/token_validation/config/{config_id}", zone_id=zone_id, config_id=config_id), body=await async_maybe_transform( { "description": description, @@ -543,7 +561,7 @@ async def get( self, config_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -567,12 +585,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return await self._get( - f"/zones/{zone_id}/token_validation/config/{config_id}", + path_template("/zones/{zone_id}/token_validation/config/{config_id}", zone_id=zone_id, config_id=config_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/token_validation/configuration/credentials.py b/src/cloudflare/resources/token_validation/configuration/credentials.py index 1214a8f8ac0..1f9f262623c 100644 --- a/src/cloudflare/resources/token_validation/configuration/credentials.py +++ b/src/cloudflare/resources/token_validation/configuration/credentials.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def update( self, config_id: str, *, - zone_id: str, + zone_id: str | None = None, keys: Iterable[credential_update_params.Key], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -72,12 +72,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return self._put( - f"/zones/{zone_id}/token_validation/config/{config_id}/credentials", + path_template( + "/zones/{zone_id}/token_validation/config/{config_id}/credentials", zone_id=zone_id, config_id=config_id + ), body=maybe_transform({"keys": keys}, credential_update_params.CredentialUpdateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -110,7 +114,7 @@ async def update( self, config_id: str, *, - zone_id: str, + zone_id: str | None = None, keys: Iterable[credential_update_params.Key], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -135,12 +139,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not config_id: raise ValueError(f"Expected a non-empty value for `config_id` but received {config_id!r}") return await self._put( - f"/zones/{zone_id}/token_validation/config/{config_id}/credentials", + path_template( + "/zones/{zone_id}/token_validation/config/{config_id}/credentials", zone_id=zone_id, config_id=config_id + ), body=await async_maybe_transform({"keys": keys}, credential_update_params.CredentialUpdateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/token_validation/rules.py b/src/cloudflare/resources/token_validation/rules.py index e16f28f343d..fb183bec83e 100644 --- a/src/cloudflare/resources/token_validation/rules.py +++ b/src/cloudflare/resources/token_validation/rules.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -55,7 +55,7 @@ def with_streaming_response(self) -> RulesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, action: Literal["log", "block"], description: str, enabled: bool, @@ -103,10 +103,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/rules", + path_template("/zones/{zone_id}/token_validation/rules", zone_id=zone_id), body=maybe_transform( { "action": action, @@ -131,7 +133,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, id: str | Omit = omit, action: Literal["log", "block"] | Omit = omit, enabled: bool | Omit = omit, @@ -181,10 +183,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/rules", + path_template("/zones/{zone_id}/token_validation/rules", zone_id=zone_id), page=SyncV4PagePaginationArray[TokenValidationRule], options=make_request_options( extra_headers=extra_headers, @@ -213,7 +217,7 @@ def delete( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -237,12 +241,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._delete( - f"/zones/{zone_id}/token_validation/rules/{rule_id}", + path_template("/zones/{zone_id}/token_validation/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -256,7 +262,7 @@ def delete( def bulk_create( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[rule_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. @@ -281,10 +287,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/rules/bulk", + path_template("/zones/{zone_id}/token_validation/rules/bulk", zone_id=zone_id), page=SyncSinglePage[TokenValidationRule], body=maybe_transform(body, Iterable[rule_bulk_create_params.Body]), options=make_request_options( @@ -297,7 +305,7 @@ def bulk_create( def bulk_edit( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[rule_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. @@ -326,10 +334,12 @@ def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/rules/bulk", + path_template("/zones/{zone_id}/token_validation/rules/bulk", zone_id=zone_id), page=SyncSinglePage[TokenValidationRule], body=maybe_transform(body, Iterable[rule_bulk_edit_params.Body]), options=make_request_options( @@ -343,7 +353,7 @@ def edit( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, action: Literal["log", "block"] | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, @@ -396,12 +406,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._patch( - f"/zones/{zone_id}/token_validation/rules/{rule_id}", + path_template("/zones/{zone_id}/token_validation/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), body=maybe_transform( { "action": action, @@ -428,7 +440,7 @@ def get( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -452,12 +464,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get( - f"/zones/{zone_id}/token_validation/rules/{rule_id}", + path_template("/zones/{zone_id}/token_validation/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -492,7 +506,7 @@ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, action: Literal["log", "block"], description: str, enabled: bool, @@ -540,10 +554,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/rules", + path_template("/zones/{zone_id}/token_validation/rules", zone_id=zone_id), body=await async_maybe_transform( { "action": action, @@ -568,7 +584,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, id: str | Omit = omit, action: Literal["log", "block"] | Omit = omit, enabled: bool | Omit = omit, @@ -618,10 +634,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/rules", + path_template("/zones/{zone_id}/token_validation/rules", zone_id=zone_id), page=AsyncV4PagePaginationArray[TokenValidationRule], options=make_request_options( extra_headers=extra_headers, @@ -650,7 +668,7 @@ async def delete( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -674,12 +692,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._delete( - f"/zones/{zone_id}/token_validation/rules/{rule_id}", + path_template("/zones/{zone_id}/token_validation/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -693,7 +713,7 @@ async def delete( def bulk_create( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[rule_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. @@ -718,10 +738,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/rules/bulk", + path_template("/zones/{zone_id}/token_validation/rules/bulk", zone_id=zone_id), page=AsyncSinglePage[TokenValidationRule], body=maybe_transform(body, Iterable[rule_bulk_create_params.Body]), options=make_request_options( @@ -734,7 +756,7 @@ def bulk_create( def bulk_edit( self, *, - zone_id: str, + zone_id: str | None = None, body: Iterable[rule_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. @@ -763,10 +785,12 @@ def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/token_validation/rules/bulk", + path_template("/zones/{zone_id}/token_validation/rules/bulk", zone_id=zone_id), page=AsyncSinglePage[TokenValidationRule], body=maybe_transform(body, Iterable[rule_bulk_edit_params.Body]), options=make_request_options( @@ -780,7 +804,7 @@ async def edit( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, action: Literal["log", "block"] | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, @@ -833,12 +857,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._patch( - f"/zones/{zone_id}/token_validation/rules/{rule_id}", + path_template("/zones/{zone_id}/token_validation/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), body=await async_maybe_transform( { "action": action, @@ -865,7 +891,7 @@ async def get( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -889,12 +915,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._get( - f"/zones/{zone_id}/token_validation/rules/{rule_id}", + path_template("/zones/{zone_id}/token_validation/rules/{rule_id}", zone_id=zone_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/turnstile/api.md b/src/cloudflare/resources/turnstile/api.md new file mode 100644 index 00000000000..65665ef099d --- /dev/null +++ b/src/cloudflare/resources/turnstile/api.md @@ -0,0 +1,18 @@ +# 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] diff --git a/src/cloudflare/resources/turnstile/widgets.py b/src/cloudflare/resources/turnstile/widgets.py index 54071126a02..902315f4396 100644 --- a/src/cloudflare/resources/turnstile/widgets.py +++ b/src/cloudflare/resources/turnstile/widgets.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -56,7 +56,7 @@ def with_streaming_response(self) -> WidgetsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, domains: SequenceNotStr[WidgetDomain], mode: Literal["non-interactive", "invisible", "managed"], name: str, @@ -129,10 +129,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/challenges/widgets", + path_template("/accounts/{account_id}/challenges/widgets", account_id=account_id), body=maybe_transform( { "domains": domains, @@ -170,7 +172,7 @@ def update( self, sitekey: str, *, - account_id: str, + account_id: str | None = None, domains: SequenceNotStr[WidgetDomain], mode: Literal["non-interactive", "invisible", "managed"], name: str, @@ -220,12 +222,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sitekey: raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}") return self._put( - f"/accounts/{account_id}/challenges/widgets/{sitekey}", + path_template( + "/accounts/{account_id}/challenges/widgets/{sitekey}", account_id=account_id, sitekey=sitekey + ), body=maybe_transform( { "domains": domains, @@ -252,7 +258,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, filter: str | Omit = omit, order: Literal["id", "sitekey", "name", "created_on", "modified_on"] | Omit = omit, @@ -299,10 +305,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/challenges/widgets", + path_template("/accounts/{account_id}/challenges/widgets", account_id=account_id), page=SyncV4PagePaginationArray[WidgetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -327,7 +335,7 @@ def delete( self, sitekey: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -351,12 +359,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sitekey: raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}") return self._delete( - f"/accounts/{account_id}/challenges/widgets/{sitekey}", + path_template( + "/accounts/{account_id}/challenges/widgets/{sitekey}", account_id=account_id, sitekey=sitekey + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -371,7 +383,7 @@ def get( self, sitekey: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -395,12 +407,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sitekey: raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}") return self._get( - f"/accounts/{account_id}/challenges/widgets/{sitekey}", + path_template( + "/accounts/{account_id}/challenges/widgets/{sitekey}", account_id=account_id, sitekey=sitekey + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -415,7 +431,7 @@ def rotate_secret( self, sitekey: str, *, - account_id: str, + account_id: str | None = None, invalidate_immediately: 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. @@ -448,12 +464,18 @@ def rotate_secret( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sitekey: raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}") return self._post( - f"/accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret", + path_template( + "/accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret", + account_id=account_id, + sitekey=sitekey, + ), body=maybe_transform( {"invalidate_immediately": invalidate_immediately}, widget_rotate_secret_params.WidgetRotateSecretParams ), @@ -491,7 +513,7 @@ def with_streaming_response(self) -> AsyncWidgetsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, domains: SequenceNotStr[WidgetDomain], mode: Literal["non-interactive", "invisible", "managed"], name: str, @@ -564,10 +586,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/challenges/widgets", + path_template("/accounts/{account_id}/challenges/widgets", account_id=account_id), body=await async_maybe_transform( { "domains": domains, @@ -605,7 +629,7 @@ async def update( self, sitekey: str, *, - account_id: str, + account_id: str | None = None, domains: SequenceNotStr[WidgetDomain], mode: Literal["non-interactive", "invisible", "managed"], name: str, @@ -655,12 +679,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sitekey: raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}") return await self._put( - f"/accounts/{account_id}/challenges/widgets/{sitekey}", + path_template( + "/accounts/{account_id}/challenges/widgets/{sitekey}", account_id=account_id, sitekey=sitekey + ), body=await async_maybe_transform( { "domains": domains, @@ -687,7 +715,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, direction: Literal["asc", "desc"] | Omit = omit, filter: str | Omit = omit, order: Literal["id", "sitekey", "name", "created_on", "modified_on"] | Omit = omit, @@ -734,10 +762,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/challenges/widgets", + path_template("/accounts/{account_id}/challenges/widgets", account_id=account_id), page=AsyncV4PagePaginationArray[WidgetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -762,7 +792,7 @@ async def delete( self, sitekey: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -786,12 +816,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sitekey: raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}") return await self._delete( - f"/accounts/{account_id}/challenges/widgets/{sitekey}", + path_template( + "/accounts/{account_id}/challenges/widgets/{sitekey}", account_id=account_id, sitekey=sitekey + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -806,7 +840,7 @@ async def get( self, sitekey: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -830,12 +864,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sitekey: raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}") return await self._get( - f"/accounts/{account_id}/challenges/widgets/{sitekey}", + path_template( + "/accounts/{account_id}/challenges/widgets/{sitekey}", account_id=account_id, sitekey=sitekey + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -850,7 +888,7 @@ async def rotate_secret( self, sitekey: str, *, - account_id: str, + account_id: str | None = None, invalidate_immediately: 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. @@ -883,12 +921,18 @@ async def rotate_secret( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not sitekey: raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}") return await self._post( - f"/accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret", + path_template( + "/accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret", + account_id=account_id, + sitekey=sitekey, + ), body=await async_maybe_transform( {"invalidate_immediately": invalidate_immediately}, widget_rotate_secret_params.WidgetRotateSecretParams ), diff --git a/src/cloudflare/resources/url_normalization/__init__.py b/src/cloudflare/resources/url_normalization/__init__.py new file mode 100644 index 00000000000..d7073195c2d --- /dev/null +++ b/src/cloudflare/resources/url_normalization/__init__.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .url_normalization import ( + URLNormalizationResource, + AsyncURLNormalizationResource, + URLNormalizationResourceWithRawResponse, + AsyncURLNormalizationResourceWithRawResponse, + URLNormalizationResourceWithStreamingResponse, + AsyncURLNormalizationResourceWithStreamingResponse, +) + +__all__ = [ + "URLNormalizationResource", + "AsyncURLNormalizationResource", + "URLNormalizationResourceWithRawResponse", + "AsyncURLNormalizationResourceWithRawResponse", + "URLNormalizationResourceWithStreamingResponse", + "AsyncURLNormalizationResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/url_normalization/api.md b/src/cloudflare/resources/url_normalization/api.md new file mode 100644 index 00000000000..3d02c0c275c --- /dev/null +++ b/src/cloudflare/resources/url_normalization/api.md @@ -0,0 +1,16 @@ +# URLNormalization + +Types: + +```python +from cloudflare.types.url_normalization import ( + URLNormalizationUpdateResponse, + URLNormalizationGetResponse, +) +``` + +Methods: + +- client.url_normalization.update(\*, zone_id, \*\*params) -> URLNormalizationUpdateResponse +- client.url_normalization.delete(\*, zone_id) -> None +- client.url_normalization.get(\*, zone_id) -> URLNormalizationGetResponse diff --git a/src/cloudflare/resources/url_normalization.py b/src/cloudflare/resources/url_normalization/url_normalization.py similarity index 88% rename from src/cloudflare/resources/url_normalization.py rename to src/cloudflare/resources/url_normalization/url_normalization.py index 2d69292f055..7472f6aab34 100644 --- a/src/cloudflare/resources/url_normalization.py +++ b/src/cloudflare/resources/url_normalization/url_normalization.py @@ -7,21 +7,21 @@ import httpx -from .._types import Body, Query, Headers, NoneType, NotGiven, not_given -from .._utils import maybe_transform, async_maybe_transform -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( +from ..._types import Body, Query, Headers, NoneType, NotGiven, not_given +from ..._utils import path_template, 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.url_normalization import url_normalization_update_params -from ..types.url_normalization.url_normalization_get_response import URLNormalizationGetResponse -from ..types.url_normalization.url_normalization_update_response import URLNormalizationUpdateResponse +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.url_normalization import url_normalization_update_params +from ...types.url_normalization.url_normalization_get_response import URLNormalizationGetResponse +from ...types.url_normalization.url_normalization_update_response import URLNormalizationUpdateResponse __all__ = ["URLNormalizationResource", "AsyncURLNormalizationResource"] @@ -49,7 +49,7 @@ def with_streaming_response(self) -> URLNormalizationResourceWithStreamingRespon def update( self, *, - zone_id: str, + zone_id: str | None = None, scope: Literal["incoming", "both", "none"], type: Literal["cloudflare", "rfc3986"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,10 +77,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/url_normalization", + path_template("/zones/{zone_id}/url_normalization", zone_id=zone_id), body=maybe_transform( { "scope": scope, @@ -101,7 +103,7 @@ def update( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,11 +125,13 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/zones/{zone_id}/url_normalization", + path_template("/zones/{zone_id}/url_normalization", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -137,7 +141,7 @@ def delete( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -159,10 +163,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/url_normalization", + path_template("/zones/{zone_id}/url_normalization", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -197,7 +203,7 @@ def with_streaming_response(self) -> AsyncURLNormalizationResourceWithStreamingR async def update( self, *, - zone_id: str, + zone_id: str | None = None, scope: Literal["incoming", "both", "none"], type: Literal["cloudflare", "rfc3986"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -225,10 +231,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/url_normalization", + path_template("/zones/{zone_id}/url_normalization", zone_id=zone_id), body=await async_maybe_transform( { "scope": scope, @@ -249,7 +257,7 @@ async def update( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -271,11 +279,13 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/zones/{zone_id}/url_normalization", + path_template("/zones/{zone_id}/url_normalization", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -285,7 +295,7 @@ async def delete( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -307,10 +317,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/url_normalization", + path_template("/zones/{zone_id}/url_normalization", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/url_scanner/api.md b/src/cloudflare/resources/url_scanner/api.md new file mode 100644 index 00000000000..799de3c9c4b --- /dev/null +++ b/src/cloudflare/resources/url_scanner/api.md @@ -0,0 +1,44 @@ +# 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 diff --git a/src/cloudflare/resources/url_scanner/responses.py b/src/cloudflare/resources/url_scanner/responses.py index d7380f1688f..4ba6626497c 100644 --- a/src/cloudflare/resources/url_scanner/responses.py +++ b/src/cloudflare/resources/url_scanner/responses.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -42,7 +43,7 @@ def get( self, response_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,13 +69,19 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not response_id: raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}") extra_headers = {"Accept": "text/plain", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/urlscanner/v2/responses/{response_id}", + path_template( + "/accounts/{account_id}/urlscanner/v2/responses/{response_id}", + account_id=account_id, + response_id=response_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -106,7 +113,7 @@ async def get( self, response_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -132,13 +139,19 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not response_id: raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}") extra_headers = {"Accept": "text/plain", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/urlscanner/v2/responses/{response_id}", + path_template( + "/accounts/{account_id}/urlscanner/v2/responses/{response_id}", + account_id=account_id, + response_id=response_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/url_scanner/scans.py b/src/cloudflare/resources/url_scanner/scans.py index b1fad6e2dfa..8736952cbc1 100644 --- a/src/cloudflare/resources/url_scanner/scans.py +++ b/src/cloudflare/resources/url_scanner/scans.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -59,8 +59,9 @@ def with_streaming_response(self) -> ScansResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, url: str, + agent_readiness: bool | Omit = omit, country: Literal[ "AF", "AL", @@ -279,6 +280,8 @@ def create( Args: account_id: Account ID. + agent_readiness: Enable agent readiness checks. + country: Country to geo egress from custom_headers: Set custom headers. @@ -299,13 +302,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/urlscanner/v2/scan", + path_template("/accounts/{account_id}/urlscanner/v2/scan", account_id=account_id), body=maybe_transform( { "url": url, + "agent_readiness": agent_readiness, "country": country, "customagent": customagent, "custom_headers": custom_headers, @@ -324,7 +330,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, q: str | Omit = omit, size: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -360,10 +366,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/urlscanner/v2/search", + path_template("/accounts/{account_id}/urlscanner/v2/search", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -383,7 +391,7 @@ def list( def bulk_create( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[scan_bulk_create_params.Body] | 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. @@ -412,10 +420,12 @@ def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/urlscanner/v2/bulk", + path_template("/accounts/{account_id}/urlscanner/v2/bulk", account_id=account_id), body=maybe_transform(body, Iterable[scan_bulk_create_params.Body]), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -427,7 +437,7 @@ def dom( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -452,13 +462,15 @@ def dom( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") extra_headers = {"Accept": "text/plain", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/urlscanner/v2/dom/{scan_id}", + path_template("/accounts/{account_id}/urlscanner/v2/dom/{scan_id}", account_id=account_id, scan_id=scan_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -469,7 +481,7 @@ def get( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -493,12 +505,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") return self._get( - f"/accounts/{account_id}/urlscanner/v2/result/{scan_id}", + path_template( + "/accounts/{account_id}/urlscanner/v2/result/{scan_id}", account_id=account_id, scan_id=scan_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -509,7 +525,7 @@ def har( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -535,12 +551,14 @@ def har( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") return self._get( - f"/accounts/{account_id}/urlscanner/v2/har/{scan_id}", + path_template("/accounts/{account_id}/urlscanner/v2/har/{scan_id}", account_id=account_id, scan_id=scan_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -551,7 +569,7 @@ def screenshot( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, resolution: Literal["desktop", "mobile", "tablet"] | 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. @@ -578,13 +596,17 @@ def screenshot( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") extra_headers = {"Accept": "image/png", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/urlscanner/v2/screenshots/{scan_id}.png", + path_template( + "/accounts/{account_id}/urlscanner/v2/screenshots/{scan_id}.png", account_id=account_id, scan_id=scan_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -619,8 +641,9 @@ def with_streaming_response(self) -> AsyncScansResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, url: str, + agent_readiness: bool | Omit = omit, country: Literal[ "AF", "AL", @@ -839,6 +862,8 @@ async def create( Args: account_id: Account ID. + agent_readiness: Enable agent readiness checks. + country: Country to geo egress from custom_headers: Set custom headers. @@ -859,13 +884,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/urlscanner/v2/scan", + path_template("/accounts/{account_id}/urlscanner/v2/scan", account_id=account_id), body=await async_maybe_transform( { "url": url, + "agent_readiness": agent_readiness, "country": country, "customagent": customagent, "custom_headers": custom_headers, @@ -884,7 +912,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, q: str | Omit = omit, size: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -920,10 +948,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/urlscanner/v2/search", + path_template("/accounts/{account_id}/urlscanner/v2/search", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -943,7 +973,7 @@ async def list( async def bulk_create( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[scan_bulk_create_params.Body] | 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. @@ -972,10 +1002,12 @@ async def bulk_create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/urlscanner/v2/bulk", + path_template("/accounts/{account_id}/urlscanner/v2/bulk", account_id=account_id), body=await async_maybe_transform(body, Iterable[scan_bulk_create_params.Body]), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -987,7 +1019,7 @@ async def dom( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1012,13 +1044,15 @@ async def dom( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") extra_headers = {"Accept": "text/plain", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/urlscanner/v2/dom/{scan_id}", + path_template("/accounts/{account_id}/urlscanner/v2/dom/{scan_id}", account_id=account_id, scan_id=scan_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1029,7 +1063,7 @@ async def get( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1053,12 +1087,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") return await self._get( - f"/accounts/{account_id}/urlscanner/v2/result/{scan_id}", + path_template( + "/accounts/{account_id}/urlscanner/v2/result/{scan_id}", account_id=account_id, scan_id=scan_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1069,7 +1107,7 @@ async def har( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1095,12 +1133,14 @@ async def har( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") return await self._get( - f"/accounts/{account_id}/urlscanner/v2/har/{scan_id}", + path_template("/accounts/{account_id}/urlscanner/v2/har/{scan_id}", account_id=account_id, scan_id=scan_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1111,7 +1151,7 @@ async def screenshot( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, resolution: Literal["desktop", "mobile", "tablet"] | 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. @@ -1138,13 +1178,17 @@ async def screenshot( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") extra_headers = {"Accept": "image/png", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/urlscanner/v2/screenshots/{scan_id}.png", + path_template( + "/accounts/{account_id}/urlscanner/v2/screenshots/{scan_id}.png", account_id=account_id, scan_id=scan_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/user/api.md b/src/cloudflare/resources/user/api.md new file mode 100644 index 00000000000..b3e52694624 --- /dev/null +++ b/src/cloudflare/resources/user/api.md @@ -0,0 +1,121 @@ +# User + +Types: + +```python +from cloudflare.types.user import UserEditResponse, UserGetResponse +``` + +Methods: + +- client.user.edit(\*\*params) -> Optional[UserEditResponse] +- client.user.get() -> Optional[UserGetResponse] + +## AuditLogs + +Methods: + +- client.user.audit_logs.list(\*\*params) -> SyncV4PagePaginationArray[AuditLog] + +## Billing + +### History + +Types: + +```python +from cloudflare.types.user.billing import BillingHistory +``` + +Methods: + +- client.user.billing.history.list(\*\*params) -> SyncV4PagePaginationArray[BillingHistory] + +### Profile + +Types: + +```python +from cloudflare.types.user.billing import ProfileGetResponse +``` + +Methods: + +- client.user.billing.profile.get() -> ProfileGetResponse + +## Invites + +Types: + +```python +from cloudflare.types.user import Invite +``` + +Methods: + +- client.user.invites.list() -> SyncSinglePage[Invite] +- 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 +``` + +Methods: + +- client.user.organizations.list(\*\*params) -> SyncV4PagePaginationArray[Organization] +- client.user.organizations.delete(organization_id) -> OrganizationDeleteResponse +- client.user.organizations.get(organization_id) -> object + +## Subscriptions + +Types: + +```python +from cloudflare.types.user import SubscriptionUpdateResponse, SubscriptionDeleteResponse +``` + +Methods: + +- client.user.subscriptions.update(identifier, \*\*params) -> SubscriptionUpdateResponse +- client.user.subscriptions.delete(identifier) -> SubscriptionDeleteResponse +- client.user.subscriptions.get() -> SyncSinglePage[Subscription] + +## Tokens + +Types: + +```python +from cloudflare.types.user import TokenCreateResponse, TokenDeleteResponse, TokenVerifyResponse +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.user.tokens import PermissionGroupListResponse +``` + +Methods: + +- client.user.tokens.permission_groups.list(\*\*params) -> SyncSinglePage[PermissionGroupListResponse] + +### Value + +Methods: + +- client.user.tokens.value.update(token_id, \*\*params) -> str diff --git a/src/cloudflare/resources/user/invites.py b/src/cloudflare/resources/user/invites.py index 6bfa26e944a..d2b8f031f8d 100644 --- a/src/cloudflare/resources/user/invites.py +++ b/src/cloudflare/resources/user/invites.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -97,7 +97,7 @@ def edit( if not invite_id: raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}") return self._patch( - f"/user/invites/{invite_id}", + path_template("/user/invites/{invite_id}", invite_id=invite_id), body=maybe_transform({"status": status}, invite_edit_params.InviteEditParams), options=make_request_options( extra_headers=extra_headers, @@ -137,7 +137,7 @@ def get( if not invite_id: raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}") return self._get( - f"/user/invites/{invite_id}", + path_template("/user/invites/{invite_id}", invite_id=invite_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -220,7 +220,7 @@ async def edit( if not invite_id: raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}") return await self._patch( - f"/user/invites/{invite_id}", + path_template("/user/invites/{invite_id}", invite_id=invite_id), body=await async_maybe_transform({"status": status}, invite_edit_params.InviteEditParams), options=make_request_options( extra_headers=extra_headers, @@ -260,7 +260,7 @@ async def get( if not invite_id: raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}") return await self._get( - f"/user/invites/{invite_id}", + path_template("/user/invites/{invite_id}", invite_id=invite_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/user/organizations.py b/src/cloudflare/resources/user/organizations.py index dd4099e4097..7dcc6295c20 100644 --- a/src/cloudflare/resources/user/organizations.py +++ b/src/cloudflare/resources/user/organizations.py @@ -9,7 +9,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -145,7 +145,7 @@ def delete( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return self._delete( - f"/user/organizations/{organization_id}", + path_template("/user/organizations/{organization_id}", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -181,7 +181,7 @@ def get( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return self._get( - f"/user/organizations/{organization_id}", + path_template("/user/organizations/{organization_id}", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -310,7 +310,7 @@ async def delete( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return await self._delete( - f"/user/organizations/{organization_id}", + path_template("/user/organizations/{organization_id}", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -346,7 +346,7 @@ async def get( if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") return await self._get( - f"/user/organizations/{organization_id}", + path_template("/user/organizations/{organization_id}", organization_id=organization_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/user/subscriptions.py b/src/cloudflare/resources/user/subscriptions.py index 7b5684234d6..d0019a98eed 100644 --- a/src/cloudflare/resources/user/subscriptions.py +++ b/src/cloudflare/resources/user/subscriptions.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -85,7 +85,7 @@ def update( return cast( SubscriptionUpdateResponse, self._put( - f"/user/subscriptions/{identifier}", + path_template("/user/subscriptions/{identifier}", identifier=identifier), body=maybe_transform( { "frequency": frequency, @@ -134,7 +134,7 @@ def delete( if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._delete( - f"/user/subscriptions/{identifier}", + path_template("/user/subscriptions/{identifier}", identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -218,7 +218,7 @@ async def update( return cast( SubscriptionUpdateResponse, await self._put( - f"/user/subscriptions/{identifier}", + path_template("/user/subscriptions/{identifier}", identifier=identifier), body=await async_maybe_transform( { "frequency": frequency, @@ -267,7 +267,7 @@ async def delete( if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._delete( - f"/user/subscriptions/{identifier}", + path_template("/user/subscriptions/{identifier}", identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/user/tokens/tokens.py b/src/cloudflare/resources/user/tokens/tokens.py index 01277f2610d..2593ffe168b 100644 --- a/src/cloudflare/resources/user/tokens/tokens.py +++ b/src/cloudflare/resources/user/tokens/tokens.py @@ -17,7 +17,7 @@ AsyncValueResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -178,7 +178,7 @@ def update( if not token_id: raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") return self._put( - f"/user/tokens/{token_id}", + path_template("/user/tokens/{token_id}", token_id=token_id), body=maybe_transform( { "name": name, @@ -279,7 +279,7 @@ def delete( if not token_id: raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") return self._delete( - f"/user/tokens/{token_id}", + path_template("/user/tokens/{token_id}", token_id=token_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -318,7 +318,7 @@ def get( if not token_id: raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") return self._get( - f"/user/tokens/{token_id}", + path_template("/user/tokens/{token_id}", token_id=token_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -484,7 +484,7 @@ async def update( 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"/user/tokens/{token_id}", + path_template("/user/tokens/{token_id}", token_id=token_id), body=await async_maybe_transform( { "name": name, @@ -585,7 +585,7 @@ async def delete( 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"/user/tokens/{token_id}", + path_template("/user/tokens/{token_id}", token_id=token_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -624,7 +624,7 @@ async def get( 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"/user/tokens/{token_id}", + path_template("/user/tokens/{token_id}", token_id=token_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/user/tokens/value.py b/src/cloudflare/resources/user/tokens/value.py index 063d76b1e91..b9414b3e18e 100644 --- a/src/cloudflare/resources/user/tokens/value.py +++ b/src/cloudflare/resources/user/tokens/value.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -73,7 +73,7 @@ def update( if not token_id: raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") return self._put( - f"/user/tokens/{token_id}/value", + path_template("/user/tokens/{token_id}/value", token_id=token_id), body=maybe_transform(body, value_update_params.ValueUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -135,7 +135,7 @@ async def update( 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"/user/tokens/{token_id}/value", + path_template("/user/tokens/{token_id}/value", token_id=token_id), body=await async_maybe_transform(body, value_update_params.ValueUpdateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/vectorize/api.md b/src/cloudflare/resources/vectorize/api.md new file mode 100644 index 00000000000..70125007eba --- /dev/null +++ b/src/cloudflare/resources/vectorize/api.md @@ -0,0 +1,55 @@ +# 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] diff --git a/src/cloudflare/resources/vectorize/indexes/indexes.py b/src/cloudflare/resources/vectorize/indexes/indexes.py index a001e62b7fb..da0af709019 100644 --- a/src/cloudflare/resources/vectorize/indexes/indexes.py +++ b/src/cloudflare/resources/vectorize/indexes/indexes.py @@ -18,7 +18,7 @@ omit, not_given, ) -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -86,7 +86,7 @@ def with_streaming_response(self) -> IndexesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, config: index_create_params.Config, name: str, description: str | Omit = omit, @@ -115,10 +115,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vectorize/v2/indexes", + path_template("/accounts/{account_id}/vectorize/v2/indexes", account_id=account_id), body=maybe_transform( { "config": config, @@ -140,7 +142,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -162,10 +164,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vectorize/v2/indexes", + path_template("/accounts/{account_id}/vectorize/v2/indexes", account_id=account_id), page=SyncSinglePage[CreateIndex], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -177,7 +181,7 @@ def delete( self, index_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -199,6 +203,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: @@ -206,7 +212,11 @@ def delete( return cast( Optional[IndexDeleteResponse], self._delete( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}", + account_id=account_id, + index_name=index_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -224,7 +234,7 @@ def delete_by_ids( self, index_name: str, *, - account_id: str, + account_id: str | None = None, ids: 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. @@ -249,12 +259,18 @@ def delete_by_ids( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/delete_by_ids", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/delete_by_ids", + account_id=account_id, + index_name=index_name, + ), body=maybe_transform({"ids": ids}, index_delete_by_ids_params.IndexDeleteByIDsParams), options=make_request_options( extra_headers=extra_headers, @@ -270,7 +286,7 @@ def get( self, index_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -292,12 +308,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._get( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}", account_id=account_id, index_name=index_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -312,7 +332,7 @@ def get_by_ids( self, index_name: str, *, - account_id: str, + account_id: str | None = None, ids: 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. @@ -337,12 +357,18 @@ def get_by_ids( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/get_by_ids", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/get_by_ids", + account_id=account_id, + index_name=index_name, + ), body=maybe_transform({"ids": ids}, index_get_by_ids_params.IndexGetByIDsParams), options=make_request_options( extra_headers=extra_headers, @@ -358,7 +384,7 @@ def info( self, index_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -380,12 +406,18 @@ def info( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._get( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/info", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/info", + account_id=account_id, + index_name=index_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -400,7 +432,7 @@ def insert( self, index_name: str, *, - account_id: str, + account_id: str | None = None, body: FileTypes, unparsable_behavior: Literal["error", "discard"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -429,12 +461,18 @@ def insert( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/insert", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/insert", + account_id=account_id, + index_name=index_name, + ), body=maybe_transform(body, index_insert_params.IndexInsertParams), options=make_request_options( extra_headers=extra_headers, @@ -453,7 +491,7 @@ def list_vectors( self, index_name: str, *, - account_id: str, + account_id: str | None = None, count: int | Omit = omit, cursor: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -481,12 +519,18 @@ def list_vectors( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._get( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/list", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/list", + account_id=account_id, + index_name=index_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -508,7 +552,7 @@ def query( self, index_name: str, *, - account_id: str, + account_id: str | None = None, vector: Iterable[float], filter: object | Omit = omit, return_metadata: Literal["none", "indexed", "all"] | Omit = omit, @@ -546,12 +590,18 @@ def query( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/query", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/query", + account_id=account_id, + index_name=index_name, + ), body=maybe_transform( { "vector": vector, @@ -576,7 +626,7 @@ def upsert( self, index_name: str, *, - account_id: str, + account_id: str | None = None, body: FileTypes, unparsable_behavior: Literal["error", "discard"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -605,12 +655,18 @@ def upsert( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/upsert", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/upsert", + account_id=account_id, + index_name=index_name, + ), body=maybe_transform(body, index_upsert_params.IndexUpsertParams), options=make_request_options( extra_headers=extra_headers, @@ -653,7 +709,7 @@ def with_streaming_response(self) -> AsyncIndexesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, config: index_create_params.Config, name: str, description: str | Omit = omit, @@ -682,10 +738,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vectorize/v2/indexes", + path_template("/accounts/{account_id}/vectorize/v2/indexes", account_id=account_id), body=await async_maybe_transform( { "config": config, @@ -707,7 +765,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -729,10 +787,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vectorize/v2/indexes", + path_template("/accounts/{account_id}/vectorize/v2/indexes", account_id=account_id), page=AsyncSinglePage[CreateIndex], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -744,7 +804,7 @@ async def delete( self, index_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -766,6 +826,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: @@ -773,7 +835,11 @@ async def delete( return cast( Optional[IndexDeleteResponse], await self._delete( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}", + account_id=account_id, + index_name=index_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -791,7 +857,7 @@ async def delete_by_ids( self, index_name: str, *, - account_id: str, + account_id: str | None = None, ids: 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. @@ -816,12 +882,18 @@ async def delete_by_ids( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/delete_by_ids", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/delete_by_ids", + account_id=account_id, + index_name=index_name, + ), body=await async_maybe_transform({"ids": ids}, index_delete_by_ids_params.IndexDeleteByIDsParams), options=make_request_options( extra_headers=extra_headers, @@ -837,7 +909,7 @@ async def get( self, index_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -859,12 +931,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._get( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}", account_id=account_id, index_name=index_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -879,7 +955,7 @@ async def get_by_ids( self, index_name: str, *, - account_id: str, + account_id: str | None = None, ids: 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. @@ -904,12 +980,18 @@ async def get_by_ids( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/get_by_ids", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/get_by_ids", + account_id=account_id, + index_name=index_name, + ), body=await async_maybe_transform({"ids": ids}, index_get_by_ids_params.IndexGetByIDsParams), options=make_request_options( extra_headers=extra_headers, @@ -925,7 +1007,7 @@ async def info( self, index_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -947,12 +1029,18 @@ async def info( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._get( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/info", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/info", + account_id=account_id, + index_name=index_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -967,7 +1055,7 @@ async def insert( self, index_name: str, *, - account_id: str, + account_id: str | None = None, body: FileTypes, unparsable_behavior: Literal["error", "discard"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -996,12 +1084,18 @@ async def insert( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/insert", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/insert", + account_id=account_id, + index_name=index_name, + ), body=await async_maybe_transform(body, index_insert_params.IndexInsertParams), options=make_request_options( extra_headers=extra_headers, @@ -1020,7 +1114,7 @@ async def list_vectors( self, index_name: str, *, - account_id: str, + account_id: str | None = None, count: int | Omit = omit, cursor: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1048,12 +1142,18 @@ async def list_vectors( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._get( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/list", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/list", + account_id=account_id, + index_name=index_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1075,7 +1175,7 @@ async def query( self, index_name: str, *, - account_id: str, + account_id: str | None = None, vector: Iterable[float], filter: object | Omit = omit, return_metadata: Literal["none", "indexed", "all"] | Omit = omit, @@ -1113,12 +1213,18 @@ async def query( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/query", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/query", + account_id=account_id, + index_name=index_name, + ), body=await async_maybe_transform( { "vector": vector, @@ -1143,7 +1249,7 @@ async def upsert( self, index_name: str, *, - account_id: str, + account_id: str | None = None, body: FileTypes, unparsable_behavior: Literal["error", "discard"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1172,12 +1278,18 @@ async def upsert( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/upsert", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/upsert", + account_id=account_id, + index_name=index_name, + ), body=await async_maybe_transform(body, index_upsert_params.IndexUpsertParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/vectorize/indexes/metadata_index.py b/src/cloudflare/resources/vectorize/indexes/metadata_index.py index 36b3d445971..fac9023ca9c 100644 --- a/src/cloudflare/resources/vectorize/indexes/metadata_index.py +++ b/src/cloudflare/resources/vectorize/indexes/metadata_index.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def create( self, index_name: str, *, - account_id: str, + account_id: str | None = None, index_type: Literal["string", "number", "boolean"], property_name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -80,12 +80,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/create", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/create", + account_id=account_id, + index_name=index_name, + ), body=maybe_transform( { "index_type": index_type, @@ -107,7 +113,7 @@ def list( self, index_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -129,12 +135,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._get( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/list", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/list", + account_id=account_id, + index_name=index_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -149,7 +161,7 @@ def delete( self, index_name: str, *, - account_id: str, + account_id: str | None = None, property_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. @@ -174,12 +186,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/delete", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/delete", + account_id=account_id, + index_name=index_name, + ), body=maybe_transform( {"property_name": property_name}, metadata_index_delete_params.MetadataIndexDeleteParams ), @@ -218,7 +236,7 @@ async def create( self, index_name: str, *, - account_id: str, + account_id: str | None = None, index_type: Literal["string", "number", "boolean"], property_name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -247,12 +265,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/create", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/create", + account_id=account_id, + index_name=index_name, + ), body=await async_maybe_transform( { "index_type": index_type, @@ -274,7 +298,7 @@ async def list( self, index_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -296,12 +320,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._get( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/list", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/list", + account_id=account_id, + index_name=index_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -316,7 +346,7 @@ async def delete( self, index_name: str, *, - account_id: str, + account_id: str | None = None, property_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. @@ -341,12 +371,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not index_name: raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}") return await self._post( - f"/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/delete", + path_template( + "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/delete", + account_id=account_id, + index_name=index_name, + ), body=await async_maybe_transform( {"property_name": property_name}, metadata_index_delete_params.MetadataIndexDeleteParams ), diff --git a/src/cloudflare/resources/vulnerability_scanner/api.md b/src/cloudflare/resources/vulnerability_scanner/api.md new file mode 100644 index 00000000000..cd78effbad5 --- /dev/null +++ b/src/cloudflare/resources/vulnerability_scanner/api.md @@ -0,0 +1,88 @@ +# VulnerabilityScanner + +## CredentialSets + +Types: + +```python +from cloudflare.types.vulnerability_scanner import ( + CredentialSetCreateResponse, + CredentialSetUpdateResponse, + CredentialSetListResponse, + CredentialSetEditResponse, + CredentialSetGetResponse, +) +``` + +Methods: + +- client.vulnerability_scanner.credential_sets.create(\*, account_id, \*\*params) -> Optional[CredentialSetCreateResponse] +- client.vulnerability_scanner.credential_sets.update(credential_set_id, \*, account_id, \*\*params) -> Optional[CredentialSetUpdateResponse] +- client.vulnerability_scanner.credential_sets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[CredentialSetListResponse] +- client.vulnerability_scanner.credential_sets.delete(credential_set_id, \*, account_id) -> object +- client.vulnerability_scanner.credential_sets.edit(credential_set_id, \*, account_id, \*\*params) -> Optional[CredentialSetEditResponse] +- client.vulnerability_scanner.credential_sets.get(credential_set_id, \*, account_id) -> Optional[CredentialSetGetResponse] + +### Credentials + +Types: + +```python +from cloudflare.types.vulnerability_scanner.credential_sets import ( + CredentialCreateResponse, + CredentialUpdateResponse, + CredentialListResponse, + CredentialEditResponse, + CredentialGetResponse, +) +``` + +Methods: + +- client.vulnerability_scanner.credential_sets.credentials.create(credential_set_id, \*, account_id, \*\*params) -> Optional[CredentialCreateResponse] +- client.vulnerability_scanner.credential_sets.credentials.update(credential_id, \*, account_id, credential_set_id, \*\*params) -> Optional[CredentialUpdateResponse] +- client.vulnerability_scanner.credential_sets.credentials.list(credential_set_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[CredentialListResponse] +- client.vulnerability_scanner.credential_sets.credentials.delete(credential_id, \*, account_id, credential_set_id) -> object +- client.vulnerability_scanner.credential_sets.credentials.edit(credential_id, \*, account_id, credential_set_id, \*\*params) -> Optional[CredentialEditResponse] +- client.vulnerability_scanner.credential_sets.credentials.get(credential_id, \*, account_id, credential_set_id) -> Optional[CredentialGetResponse] + +## Scans + +Types: + +```python +from cloudflare.types.vulnerability_scanner import ( + ScanCreateResponse, + ScanListResponse, + ScanGetResponse, +) +``` + +Methods: + +- client.vulnerability_scanner.scans.create(\*, account_id, \*\*params) -> Optional[ScanCreateResponse] +- client.vulnerability_scanner.scans.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ScanListResponse] +- client.vulnerability_scanner.scans.get(scan_id, \*, account_id) -> Optional[ScanGetResponse] + +## TargetEnvironments + +Types: + +```python +from cloudflare.types.vulnerability_scanner import ( + TargetEnvironmentCreateResponse, + TargetEnvironmentUpdateResponse, + TargetEnvironmentListResponse, + TargetEnvironmentEditResponse, + TargetEnvironmentGetResponse, +) +``` + +Methods: + +- client.vulnerability_scanner.target_environments.create(\*, account_id, \*\*params) -> Optional[TargetEnvironmentCreateResponse] +- client.vulnerability_scanner.target_environments.update(target_environment_id, \*, account_id, \*\*params) -> Optional[TargetEnvironmentUpdateResponse] +- client.vulnerability_scanner.target_environments.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[TargetEnvironmentListResponse] +- client.vulnerability_scanner.target_environments.delete(target_environment_id, \*, account_id) -> object +- client.vulnerability_scanner.target_environments.edit(target_environment_id, \*, account_id, \*\*params) -> Optional[TargetEnvironmentEditResponse] +- client.vulnerability_scanner.target_environments.get(target_environment_id, \*, account_id) -> Optional[TargetEnvironmentGetResponse] diff --git a/src/cloudflare/resources/vulnerability_scanner/credential_sets/credential_sets.py b/src/cloudflare/resources/vulnerability_scanner/credential_sets/credential_sets.py index 7de8f39bfec..1348324570f 100644 --- a/src/cloudflare/resources/vulnerability_scanner/credential_sets/credential_sets.py +++ b/src/cloudflare/resources/vulnerability_scanner/credential_sets/credential_sets.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from .credentials import ( CredentialsResource, @@ -69,7 +69,7 @@ def with_streaming_response(self) -> CredentialSetsResourceWithStreamingResponse def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -94,10 +94,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/credential_sets", + path_template("/accounts/{account_id}/vuln_scanner/credential_sets", account_id=account_id), body=maybe_transform({"name": name}, credential_set_create_params.CredentialSetCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -113,7 +115,7 @@ def update( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -139,12 +141,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return self._put( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + account_id=account_id, + credential_set_id=credential_set_id, + ), body=maybe_transform({"name": name}, credential_set_update_params.CredentialSetUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -159,7 +167,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -187,10 +195,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/credential_sets", + path_template("/accounts/{account_id}/vuln_scanner/credential_sets", account_id=account_id), page=SyncV4PagePaginationArray[CredentialSetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -212,7 +222,7 @@ def delete( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -234,12 +244,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return self._delete( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + account_id=account_id, + credential_set_id=credential_set_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -254,7 +270,7 @@ def edit( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -280,12 +296,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return self._patch( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + account_id=account_id, + credential_set_id=credential_set_id, + ), body=maybe_transform({"name": name}, credential_set_edit_params.CredentialSetEditParams), options=make_request_options( extra_headers=extra_headers, @@ -301,7 +323,7 @@ def get( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -323,12 +345,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return self._get( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + account_id=account_id, + credential_set_id=credential_set_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -367,7 +395,7 @@ def with_streaming_response(self) -> AsyncCredentialSetsResourceWithStreamingRes async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -392,10 +420,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/credential_sets", + path_template("/accounts/{account_id}/vuln_scanner/credential_sets", account_id=account_id), body=await async_maybe_transform({"name": name}, credential_set_create_params.CredentialSetCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -411,7 +441,7 @@ async def update( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -437,12 +467,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return await self._put( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + account_id=account_id, + credential_set_id=credential_set_id, + ), body=await async_maybe_transform({"name": name}, credential_set_update_params.CredentialSetUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -457,7 +493,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -485,10 +521,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/credential_sets", + path_template("/accounts/{account_id}/vuln_scanner/credential_sets", account_id=account_id), page=AsyncV4PagePaginationArray[CredentialSetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -510,7 +548,7 @@ async def delete( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -532,12 +570,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return await self._delete( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + account_id=account_id, + credential_set_id=credential_set_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -552,7 +596,7 @@ async def edit( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -578,12 +622,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return await self._patch( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + account_id=account_id, + credential_set_id=credential_set_id, + ), body=await async_maybe_transform({"name": name}, credential_set_edit_params.CredentialSetEditParams), options=make_request_options( extra_headers=extra_headers, @@ -599,7 +649,7 @@ async def get( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -621,12 +671,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return await self._get( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}", + account_id=account_id, + credential_set_id=credential_set_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/vulnerability_scanner/credential_sets/credentials.py b/src/cloudflare/resources/vulnerability_scanner/credential_sets/credentials.py index 65fcc4203b6..f615dbd8ad6 100644 --- a/src/cloudflare/resources/vulnerability_scanner/credential_sets/credentials.py +++ b/src/cloudflare/resources/vulnerability_scanner/credential_sets/credentials.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -59,7 +59,7 @@ def create( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, location: Literal["header", "cookie"], location_name: str, name: str, @@ -94,12 +94,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return self._post( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials", + account_id=account_id, + credential_set_id=credential_set_id, + ), body=maybe_transform( { "location": location, @@ -123,7 +129,7 @@ def update( self, credential_id: str, *, - account_id: str, + account_id: str | None = None, credential_set_id: str, location: Literal["header", "cookie"], location_name: str, @@ -159,6 +165,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: @@ -166,7 +174,12 @@ def update( if not credential_id: raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}") return self._put( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + account_id=account_id, + credential_set_id=credential_set_id, + credential_id=credential_id, + ), body=maybe_transform( { "location": location, @@ -190,7 +203,7 @@ def list( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -218,12 +231,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return self._get_api_list( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials", + account_id=account_id, + credential_set_id=credential_set_id, + ), page=SyncV4PagePaginationArray[CredentialListResponse], options=make_request_options( extra_headers=extra_headers, @@ -245,7 +264,7 @@ def delete( self, credential_id: str, *, - account_id: str, + account_id: str | None = None, credential_set_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. @@ -268,6 +287,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: @@ -275,7 +296,12 @@ def delete( if not credential_id: raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}") return self._delete( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + account_id=account_id, + credential_set_id=credential_set_id, + credential_id=credential_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -290,7 +316,7 @@ def edit( self, credential_id: str, *, - account_id: str, + account_id: str | None = None, credential_set_id: str, location: Literal["header", "cookie"] | Omit = omit, location_name: str | Omit = omit, @@ -326,6 +352,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: @@ -333,7 +361,12 @@ def edit( if not credential_id: raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}") return self._patch( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + account_id=account_id, + credential_set_id=credential_set_id, + credential_id=credential_id, + ), body=maybe_transform( { "location": location, @@ -357,7 +390,7 @@ def get( self, credential_id: str, *, - account_id: str, + account_id: str | None = None, credential_set_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. @@ -380,6 +413,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: @@ -387,7 +422,12 @@ def get( if not credential_id: raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}") return self._get( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + account_id=account_id, + credential_set_id=credential_set_id, + credential_id=credential_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -423,7 +463,7 @@ async def create( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, location: Literal["header", "cookie"], location_name: str, name: str, @@ -458,12 +498,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return await self._post( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials", + account_id=account_id, + credential_set_id=credential_set_id, + ), body=await async_maybe_transform( { "location": location, @@ -487,7 +533,7 @@ async def update( self, credential_id: str, *, - account_id: str, + account_id: str | None = None, credential_set_id: str, location: Literal["header", "cookie"], location_name: str, @@ -523,6 +569,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: @@ -530,7 +578,12 @@ async def update( if not credential_id: raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}") return await self._put( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + account_id=account_id, + credential_set_id=credential_set_id, + credential_id=credential_id, + ), body=await async_maybe_transform( { "location": location, @@ -554,7 +607,7 @@ def list( self, credential_set_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -582,12 +635,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: raise ValueError(f"Expected a non-empty value for `credential_set_id` but received {credential_set_id!r}") return self._get_api_list( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials", + account_id=account_id, + credential_set_id=credential_set_id, + ), page=AsyncV4PagePaginationArray[CredentialListResponse], options=make_request_options( extra_headers=extra_headers, @@ -609,7 +668,7 @@ async def delete( self, credential_id: str, *, - account_id: str, + account_id: str | None = None, credential_set_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. @@ -632,6 +691,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: @@ -639,7 +700,12 @@ async def delete( if not credential_id: raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}") return await self._delete( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + account_id=account_id, + credential_set_id=credential_set_id, + credential_id=credential_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -654,7 +720,7 @@ async def edit( self, credential_id: str, *, - account_id: str, + account_id: str | None = None, credential_set_id: str, location: Literal["header", "cookie"] | Omit = omit, location_name: str | Omit = omit, @@ -690,6 +756,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: @@ -697,7 +765,12 @@ async def edit( if not credential_id: raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}") return await self._patch( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + account_id=account_id, + credential_set_id=credential_set_id, + credential_id=credential_id, + ), body=await async_maybe_transform( { "location": location, @@ -721,7 +794,7 @@ async def get( self, credential_id: str, *, - account_id: str, + account_id: str | None = None, credential_set_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. @@ -744,6 +817,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not credential_set_id: @@ -751,7 +826,12 @@ async def get( if not credential_id: raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}") return await self._get( - f"/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}", + account_id=account_id, + credential_set_id=credential_set_id, + credential_id=credential_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/vulnerability_scanner/scans.py b/src/cloudflare/resources/vulnerability_scanner/scans.py index 49233371380..2c51c596530 100644 --- a/src/cloudflare/resources/vulnerability_scanner/scans.py +++ b/src/cloudflare/resources/vulnerability_scanner/scans.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> ScansResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, credential_sets: scan_create_params.CredentialSets, openapi: str, scan_type: Literal["bola"], @@ -88,10 +88,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/scans", + path_template("/accounts/{account_id}/vuln_scanner/scans", account_id=account_id), body=maybe_transform( { "credential_sets": credential_sets, @@ -114,7 +116,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -142,10 +144,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/scans", + path_template("/accounts/{account_id}/vuln_scanner/scans", account_id=account_id), page=SyncV4PagePaginationArray[ScanListResponse], options=make_request_options( extra_headers=extra_headers, @@ -167,7 +171,7 @@ def get( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -189,12 +193,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") return self._get( - f"/accounts/{account_id}/vuln_scanner/scans/{scan_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/scans/{scan_id}", account_id=account_id, scan_id=scan_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,7 +237,7 @@ def with_streaming_response(self) -> AsyncScansResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, credential_sets: scan_create_params.CredentialSets, openapi: str, scan_type: Literal["bola"], @@ -266,10 +274,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/scans", + path_template("/accounts/{account_id}/vuln_scanner/scans", account_id=account_id), body=await async_maybe_transform( { "credential_sets": credential_sets, @@ -292,7 +302,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -320,10 +330,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/scans", + path_template("/accounts/{account_id}/vuln_scanner/scans", account_id=account_id), page=AsyncV4PagePaginationArray[ScanListResponse], options=make_request_options( extra_headers=extra_headers, @@ -345,7 +357,7 @@ async def get( self, scan_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -367,12 +379,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not scan_id: raise ValueError(f"Expected a non-empty value for `scan_id` but received {scan_id!r}") return await self._get( - f"/accounts/{account_id}/vuln_scanner/scans/{scan_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/scans/{scan_id}", account_id=account_id, scan_id=scan_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/vulnerability_scanner/target_environments.py b/src/cloudflare/resources/vulnerability_scanner/target_environments.py index e26cec76ed8..28b25b0bab7 100644 --- a/src/cloudflare/resources/vulnerability_scanner/target_environments.py +++ b/src/cloudflare/resources/vulnerability_scanner/target_environments.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -57,7 +57,7 @@ def with_streaming_response(self) -> TargetEnvironmentsResourceWithStreamingResp def create( self, *, - account_id: str, + account_id: str | None = None, name: str, target: target_environment_create_params.Target, description: Optional[str] | Omit = omit, @@ -89,10 +89,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/target_environments", + path_template("/accounts/{account_id}/vuln_scanner/target_environments", account_id=account_id), body=maybe_transform( { "name": name, @@ -117,7 +119,7 @@ def update( self, target_environment_id: str, *, - account_id: str, + account_id: str | None = None, name: str, target: target_environment_update_params.Target, description: Optional[str] | Omit = omit, @@ -150,6 +152,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_environment_id: @@ -157,7 +161,11 @@ def update( f"Expected a non-empty value for `target_environment_id` but received {target_environment_id!r}" ) return self._put( - f"/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + account_id=account_id, + target_environment_id=target_environment_id, + ), body=maybe_transform( { "name": name, @@ -181,7 +189,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -209,10 +217,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/target_environments", + path_template("/accounts/{account_id}/vuln_scanner/target_environments", account_id=account_id), page=SyncV4PagePaginationArray[TargetEnvironmentListResponse], options=make_request_options( extra_headers=extra_headers, @@ -234,7 +244,7 @@ def delete( self, target_environment_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -256,6 +266,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_environment_id: @@ -263,7 +275,11 @@ def delete( f"Expected a non-empty value for `target_environment_id` but received {target_environment_id!r}" ) return self._delete( - f"/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + account_id=account_id, + target_environment_id=target_environment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -278,7 +294,7 @@ def edit( self, target_environment_id: str, *, - account_id: str, + account_id: str | None = None, description: Optional[str] | Omit = omit, name: str | Omit = omit, target: target_environment_edit_params.Target | Omit = omit, @@ -312,6 +328,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_environment_id: @@ -319,7 +337,11 @@ def edit( f"Expected a non-empty value for `target_environment_id` but received {target_environment_id!r}" ) return self._patch( - f"/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + account_id=account_id, + target_environment_id=target_environment_id, + ), body=maybe_transform( { "description": description, @@ -342,7 +364,7 @@ def get( self, target_environment_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -364,6 +386,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_environment_id: @@ -371,7 +395,11 @@ def get( f"Expected a non-empty value for `target_environment_id` but received {target_environment_id!r}" ) return self._get( - f"/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + account_id=account_id, + target_environment_id=target_environment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -406,7 +434,7 @@ def with_streaming_response(self) -> AsyncTargetEnvironmentsResourceWithStreamin async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, target: target_environment_create_params.Target, description: Optional[str] | Omit = omit, @@ -438,10 +466,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/target_environments", + path_template("/accounts/{account_id}/vuln_scanner/target_environments", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -466,7 +496,7 @@ async def update( self, target_environment_id: str, *, - account_id: str, + account_id: str | None = None, name: str, target: target_environment_update_params.Target, description: Optional[str] | Omit = omit, @@ -499,6 +529,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_environment_id: @@ -506,7 +538,11 @@ async def update( f"Expected a non-empty value for `target_environment_id` but received {target_environment_id!r}" ) return await self._put( - f"/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + account_id=account_id, + target_environment_id=target_environment_id, + ), body=await async_maybe_transform( { "name": name, @@ -530,7 +566,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -558,10 +594,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/vuln_scanner/target_environments", + path_template("/accounts/{account_id}/vuln_scanner/target_environments", account_id=account_id), page=AsyncV4PagePaginationArray[TargetEnvironmentListResponse], options=make_request_options( extra_headers=extra_headers, @@ -583,7 +621,7 @@ async def delete( self, target_environment_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -605,6 +643,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_environment_id: @@ -612,7 +652,11 @@ async def delete( f"Expected a non-empty value for `target_environment_id` but received {target_environment_id!r}" ) return await self._delete( - f"/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + account_id=account_id, + target_environment_id=target_environment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -627,7 +671,7 @@ async def edit( self, target_environment_id: str, *, - account_id: str, + account_id: str | None = None, description: Optional[str] | Omit = omit, name: str | Omit = omit, target: target_environment_edit_params.Target | Omit = omit, @@ -661,6 +705,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_environment_id: @@ -668,7 +714,11 @@ async def edit( f"Expected a non-empty value for `target_environment_id` but received {target_environment_id!r}" ) return await self._patch( - f"/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + account_id=account_id, + target_environment_id=target_environment_id, + ), body=await async_maybe_transform( { "description": description, @@ -691,7 +741,7 @@ async def get( self, target_environment_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -713,6 +763,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_environment_id: @@ -720,7 +772,11 @@ async def get( f"Expected a non-empty value for `target_environment_id` but received {target_environment_id!r}" ) return await self._get( - f"/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + path_template( + "/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}", + account_id=account_id, + target_environment_id=target_environment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/waiting_rooms/api.md b/src/cloudflare/resources/waiting_rooms/api.md new file mode 100644 index 00000000000..fb6b0f0296b --- /dev/null +++ b/src/cloudflare/resources/waiting_rooms/api.md @@ -0,0 +1,110 @@ +# 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(\*, 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 + +## Page + +Types: + +```python +from cloudflare.types.waiting_rooms import PagePreviewResponse +``` + +Methods: + +- client.waiting_rooms.page.preview(\*, zone_id, \*\*params) -> PagePreviewResponse + +## Events + +Types: + +```python +from cloudflare.types.waiting_rooms import Event, EventDeleteResponse +``` + +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) -> 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 + +### Details + +Types: + +```python +from cloudflare.types.waiting_rooms.events import EventQuery, DetailGetResponse +``` + +Methods: + +- client.waiting_rooms.events.details.get(event_id, \*, zone_id, waiting_room_id) -> DetailGetResponse + +## Rules + +Types: + +```python +from cloudflare.types.waiting_rooms import WaitingRoomRule +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.waiting_rooms import StatusGetResponse +``` + +Methods: + +- client.waiting_rooms.statuses.get(waiting_room_id, \*, zone_id) -> StatusGetResponse + +## Settings + +Types: + +```python +from cloudflare.types.waiting_rooms import ( + Setting, + SettingUpdateResponse, + SettingEditResponse, + SettingGetResponse, +) +``` + +Methods: + +- client.waiting_rooms.settings.update(\*, zone_id, \*\*params) -> SettingUpdateResponse +- client.waiting_rooms.settings.edit(\*, zone_id, \*\*params) -> SettingEditResponse +- client.waiting_rooms.settings.get(\*, zone_id) -> SettingGetResponse diff --git a/src/cloudflare/resources/waiting_rooms/events/details.py b/src/cloudflare/resources/waiting_rooms/events/details.py index 0d73f1971a2..d21c5cd670d 100644 --- a/src/cloudflare/resources/waiting_rooms/events/details.py +++ b/src/cloudflare/resources/waiting_rooms/events/details.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -46,7 +47,7 @@ def get( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_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. @@ -71,6 +72,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -78,7 +81,12 @@ def get( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._get( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}/details", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}/details", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -114,7 +122,7 @@ async def get( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_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. @@ -139,6 +147,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -146,7 +156,12 @@ async def get( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._get( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}/details", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}/details", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/waiting_rooms/events/events.py b/src/cloudflare/resources/waiting_rooms/events/events.py index 8acaec8e460..f6c82500281 100644 --- a/src/cloudflare/resources/waiting_rooms/events/events.py +++ b/src/cloudflare/resources/waiting_rooms/events/events.py @@ -16,7 +16,7 @@ AsyncDetailsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -63,7 +63,7 @@ def create( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, event_end_time: str, event_start_time: str, name: str, @@ -158,12 +158,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._post( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), body=maybe_transform( { "event_end_time": event_end_time, @@ -198,7 +204,7 @@ def update( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_id: str, event_end_time: str, event_start_time: str, @@ -288,6 +294,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -295,7 +303,12 @@ def update( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._put( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), body=maybe_transform( { "event_end_time": event_end_time, @@ -330,7 +343,7 @@ def list( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -358,12 +371,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), page=SyncV4PagePaginationArray[Event], options=make_request_options( extra_headers=extra_headers, @@ -385,7 +404,7 @@ def delete( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_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. @@ -408,6 +427,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -415,7 +436,12 @@ def delete( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._delete( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -430,7 +456,7 @@ def edit( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_id: str, event_end_time: str, event_start_time: str, @@ -520,6 +546,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -527,7 +555,12 @@ def edit( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._patch( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), body=maybe_transform( { "event_end_time": event_end_time, @@ -562,7 +595,7 @@ def get( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_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. @@ -585,6 +618,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -592,7 +627,12 @@ def get( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return self._get( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -632,7 +672,7 @@ async def create( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, event_end_time: str, event_start_time: str, name: str, @@ -727,12 +767,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return await self._post( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), body=await async_maybe_transform( { "event_end_time": event_end_time, @@ -767,7 +813,7 @@ async def update( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_id: str, event_end_time: str, event_start_time: str, @@ -857,6 +903,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -864,7 +912,12 @@ async def update( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._put( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), body=await async_maybe_transform( { "event_end_time": event_end_time, @@ -899,7 +952,7 @@ def list( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -927,12 +980,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), page=AsyncV4PagePaginationArray[Event], options=make_request_options( extra_headers=extra_headers, @@ -954,7 +1013,7 @@ async def delete( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_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. @@ -977,6 +1036,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -984,7 +1045,12 @@ async def delete( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._delete( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -999,7 +1065,7 @@ async def edit( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_id: str, event_end_time: str, event_start_time: str, @@ -1089,6 +1155,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -1096,7 +1164,12 @@ async def edit( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._patch( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), body=await async_maybe_transform( { "event_end_time": event_end_time, @@ -1131,7 +1204,7 @@ async def get( self, event_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_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. @@ -1154,6 +1227,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -1161,7 +1236,12 @@ async def get( if not event_id: raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") return await self._get( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/events/{event_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + event_id=event_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/waiting_rooms/page.py b/src/cloudflare/resources/waiting_rooms/page.py index feb0406b555..be00a540b69 100644 --- a/src/cloudflare/resources/waiting_rooms/page.py +++ b/src/cloudflare/resources/waiting_rooms/page.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> PageResourceWithStreamingResponse: def preview( self, *, - zone_id: str, + zone_id: str | None = None, custom_html: 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. @@ -128,10 +128,12 @@ def preview( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/waiting_rooms/preview", + path_template("/zones/{zone_id}/waiting_rooms/preview", zone_id=zone_id), body=maybe_transform({"custom_html": custom_html}, page_preview_params.PagePreviewParams), options=make_request_options( extra_headers=extra_headers, @@ -167,7 +169,7 @@ def with_streaming_response(self) -> AsyncPageResourceWithStreamingResponse: async def preview( self, *, - zone_id: str, + zone_id: str | None = None, custom_html: 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. @@ -248,10 +250,12 @@ async def preview( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/waiting_rooms/preview", + path_template("/zones/{zone_id}/waiting_rooms/preview", zone_id=zone_id), body=await async_maybe_transform({"custom_html": custom_html}, page_preview_params.PagePreviewParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/waiting_rooms/rules.py b/src/cloudflare/resources/waiting_rooms/rules.py index 7bf2947760f..7d2696c7f56 100644 --- a/src/cloudflare/resources/waiting_rooms/rules.py +++ b/src/cloudflare/resources/waiting_rooms/rules.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def create( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, rules: rule_create_params.Rules, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -74,12 +74,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), page=SyncSinglePage[WaitingRoomRule], body=maybe_transform(rules, rule_create_params.RuleCreateParams), options=make_request_options( @@ -93,7 +99,7 @@ def update( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, rules: Iterable[rule_update_params.Rule], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -118,12 +124,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), page=SyncSinglePage[WaitingRoomRule], body=maybe_transform(rules, Iterable[rule_update_params.Rule]), options=make_request_options( @@ -137,7 +149,7 @@ def delete( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_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. @@ -162,6 +174,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -169,7 +183,12 @@ def delete( if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + rule_id=rule_id, + ), page=SyncSinglePage[WaitingRoomRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -182,7 +201,7 @@ def edit( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_id: str, action: Literal["bypass_waiting_room"], expression: str, @@ -222,6 +241,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -229,7 +250,12 @@ def edit( if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + rule_id=rule_id, + ), page=SyncSinglePage[WaitingRoomRule], body=maybe_transform( { @@ -252,7 +278,7 @@ def get( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -274,12 +300,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), page=SyncSinglePage[WaitingRoomRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -312,7 +344,7 @@ def create( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, rules: rule_create_params.Rules, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -337,12 +369,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), page=AsyncSinglePage[WaitingRoomRule], body=maybe_transform(rules, rule_create_params.RuleCreateParams), options=make_request_options( @@ -356,7 +394,7 @@ def update( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, rules: Iterable[rule_update_params.Rule], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -381,12 +419,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), page=AsyncSinglePage[WaitingRoomRule], body=maybe_transform(rules, Iterable[rule_update_params.Rule]), options=make_request_options( @@ -400,7 +444,7 @@ def delete( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_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. @@ -425,6 +469,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -432,7 +478,12 @@ def delete( if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + rule_id=rule_id, + ), page=AsyncSinglePage[WaitingRoomRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -445,7 +496,7 @@ def edit( self, rule_id: str, *, - zone_id: str, + zone_id: str | None = None, waiting_room_id: str, action: Literal["bypass_waiting_room"], expression: str, @@ -485,6 +536,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: @@ -492,7 +545,12 @@ def edit( if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + rule_id=rule_id, + ), page=AsyncSinglePage[WaitingRoomRule], body=maybe_transform( { @@ -515,7 +573,7 @@ def get( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -537,12 +595,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get_api_list( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), page=AsyncSinglePage[WaitingRoomRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/waiting_rooms/settings.py b/src/cloudflare/resources/waiting_rooms/settings.py index 0b4b94ed3d3..d56033ad9d6 100644 --- a/src/cloudflare/resources/waiting_rooms/settings.py +++ b/src/cloudflare/resources/waiting_rooms/settings.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, search_engine_crawler_bypass: 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. @@ -59,7 +59,8 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingUpdateResponse: """ - Update zone-level Waiting Room settings + Fully updates zone-level Waiting Room settings, replacing the existing + configuration. Args: zone_id: Identifier. @@ -76,10 +77,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/waiting_rooms/settings", + path_template("/zones/{zone_id}/waiting_rooms/settings", zone_id=zone_id), body=maybe_transform( {"search_engine_crawler_bypass": search_engine_crawler_bypass}, setting_update_params.SettingUpdateParams, @@ -97,7 +100,7 @@ def update( def edit( self, *, - zone_id: str, + zone_id: str | None = None, search_engine_crawler_bypass: 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. @@ -107,7 +110,7 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingEditResponse: """ - Patch zone-level Waiting Room settings + Partially updates zone-level Waiting Room settings using PATCH semantics. Args: zone_id: Identifier. @@ -124,10 +127,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/waiting_rooms/settings", + path_template("/zones/{zone_id}/waiting_rooms/settings", zone_id=zone_id), body=maybe_transform( {"search_engine_crawler_bypass": search_engine_crawler_bypass}, setting_edit_params.SettingEditParams ), @@ -144,7 +149,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -153,7 +158,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingGetResponse: """ - Get zone-level Waiting Room settings + Gets the zone-level Waiting Room settings that apply as defaults to all waiting + rooms on the zone. Args: zone_id: Identifier. @@ -166,10 +172,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/waiting_rooms/settings", + path_template("/zones/{zone_id}/waiting_rooms/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -204,7 +212,7 @@ def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, search_engine_crawler_bypass: 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. @@ -214,7 +222,8 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingUpdateResponse: """ - Update zone-level Waiting Room settings + Fully updates zone-level Waiting Room settings, replacing the existing + configuration. Args: zone_id: Identifier. @@ -231,10 +240,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/waiting_rooms/settings", + path_template("/zones/{zone_id}/waiting_rooms/settings", zone_id=zone_id), body=await async_maybe_transform( {"search_engine_crawler_bypass": search_engine_crawler_bypass}, setting_update_params.SettingUpdateParams, @@ -252,7 +263,7 @@ async def update( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, search_engine_crawler_bypass: 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. @@ -262,7 +273,7 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingEditResponse: """ - Patch zone-level Waiting Room settings + Partially updates zone-level Waiting Room settings using PATCH semantics. Args: zone_id: Identifier. @@ -279,10 +290,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/waiting_rooms/settings", + path_template("/zones/{zone_id}/waiting_rooms/settings", zone_id=zone_id), body=await async_maybe_transform( {"search_engine_crawler_bypass": search_engine_crawler_bypass}, setting_edit_params.SettingEditParams ), @@ -299,7 +312,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -308,7 +321,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingGetResponse: """ - Get zone-level Waiting Room settings + Gets the zone-level Waiting Room settings that apply as defaults to all waiting + rooms on the zone. Args: zone_id: Identifier. @@ -321,10 +335,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/waiting_rooms/settings", + path_template("/zones/{zone_id}/waiting_rooms/settings", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/waiting_rooms/statuses.py b/src/cloudflare/resources/waiting_rooms/statuses.py index 9be4bcdf91a..cc1eaf2b910 100644 --- a/src/cloudflare/resources/waiting_rooms/statuses.py +++ b/src/cloudflare/resources/waiting_rooms/statuses.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +47,7 @@ def get( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -87,12 +88,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/status", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/status", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -128,7 +135,7 @@ async def get( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -169,12 +176,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return await self._get( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/status", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}/status", + zone_id=zone_id, + waiting_room_id=waiting_room_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/waiting_rooms/waiting_rooms.py b/src/cloudflare/resources/waiting_rooms/waiting_rooms.py index 4a5daea9034..49ccbc48dd3 100644 --- a/src/cloudflare/resources/waiting_rooms/waiting_rooms.py +++ b/src/cloudflare/resources/waiting_rooms/waiting_rooms.py @@ -24,7 +24,7 @@ AsyncRulesResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .settings import ( SettingsResource, AsyncSettingsResource, @@ -50,6 +50,7 @@ async_to_streamed_response_wrapper, ) from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from .events.events import ( EventsResource, AsyncEventsResource, @@ -58,9 +59,10 @@ EventsResourceWithStreamingResponse, AsyncEventsResourceWithStreamingResponse, ) -from ..._base_client import make_request_options +from ..._base_client import AsyncPaginator, make_request_options from ...types.waiting_rooms import ( waiting_room_edit_params, + waiting_room_list_params, waiting_room_create_params, waiting_room_update_params, ) @@ -115,7 +117,7 @@ def with_streaming_response(self) -> WaitingRoomsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, host: str, name: str, new_users_per_minute: int, @@ -473,10 +475,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/waiting_rooms", + path_template("/zones/{zone_id}/waiting_rooms", zone_id=zone_id), body=maybe_transform( { "host": host, @@ -517,7 +521,7 @@ def update( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, host: str, name: str, new_users_per_minute: int, @@ -875,12 +879,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._put( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}", zone_id=zone_id, waiting_room_id=waiting_room_id + ), body=maybe_transform( { "host": host, @@ -917,11 +925,84 @@ def update( cast_to=cast(Type[WaitingRoom], ResultWrapper[WaitingRoom]), ) + def list( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + 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[WaitingRoom]: + """ + Lists waiting rooms for account or zone. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. Must be a multiple of 5. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/waiting_rooms", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=SyncV4PagePaginationArray[WaitingRoom], + 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, + }, + waiting_room_list_params.WaitingRoomListParams, + ), + ), + model=WaitingRoom, + ) + def delete( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -943,12 +1024,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._delete( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}", zone_id=zone_id, waiting_room_id=waiting_room_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -963,7 +1048,7 @@ def edit( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, host: str, name: str, new_users_per_minute: int, @@ -1321,12 +1406,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._patch( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}", zone_id=zone_id, waiting_room_id=waiting_room_id + ), body=maybe_transform( { "host": host, @@ -1367,7 +1456,7 @@ def get( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1389,12 +1478,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return self._get( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}", zone_id=zone_id, waiting_room_id=waiting_room_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1449,7 +1542,7 @@ def with_streaming_response(self) -> AsyncWaitingRoomsResourceWithStreamingRespo async def create( self, *, - zone_id: str, + zone_id: str | None = None, host: str, name: str, new_users_per_minute: int, @@ -1807,10 +1900,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/waiting_rooms", + path_template("/zones/{zone_id}/waiting_rooms", zone_id=zone_id), body=await async_maybe_transform( { "host": host, @@ -1851,7 +1946,7 @@ async def update( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, host: str, name: str, new_users_per_minute: int, @@ -2209,12 +2304,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return await self._put( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}", zone_id=zone_id, waiting_room_id=waiting_room_id + ), body=await async_maybe_transform( { "host": host, @@ -2251,11 +2350,84 @@ async def update( cast_to=cast(Type[WaitingRoom], ResultWrapper[WaitingRoom]), ) + def list( + self, + *, + account_id: str | None = None, + zone_id: str | None = None, + 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[WaitingRoom, AsyncV4PagePaginationArray[WaitingRoom]]: + """ + Lists waiting rooms for account or zone. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. Must be a multiple of 5. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + path_template( + "/{account_or_zone}/{account_or_zone_id}/waiting_rooms", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), + page=AsyncV4PagePaginationArray[WaitingRoom], + 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, + }, + waiting_room_list_params.WaitingRoomListParams, + ), + ), + model=WaitingRoom, + ) + async def delete( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -2277,12 +2449,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return await self._delete( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}", zone_id=zone_id, waiting_room_id=waiting_room_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -2297,7 +2473,7 @@ async def edit( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, host: str, name: str, new_users_per_minute: int, @@ -2655,12 +2831,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return await self._patch( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}", zone_id=zone_id, waiting_room_id=waiting_room_id + ), body=await async_maybe_transform( { "host": host, @@ -2701,7 +2881,7 @@ async def get( self, waiting_room_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -2723,12 +2903,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not waiting_room_id: raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}") return await self._get( - f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}", + path_template( + "/zones/{zone_id}/waiting_rooms/{waiting_room_id}", zone_id=zone_id, waiting_room_id=waiting_room_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -2750,6 +2934,9 @@ def __init__(self, waiting_rooms: WaitingRoomsResource) -> None: self.update = to_raw_response_wrapper( waiting_rooms.update, ) + self.list = to_raw_response_wrapper( + waiting_rooms.list, + ) self.delete = to_raw_response_wrapper( waiting_rooms.delete, ) @@ -2791,6 +2978,9 @@ def __init__(self, waiting_rooms: AsyncWaitingRoomsResource) -> None: self.update = async_to_raw_response_wrapper( waiting_rooms.update, ) + self.list = async_to_raw_response_wrapper( + waiting_rooms.list, + ) self.delete = async_to_raw_response_wrapper( waiting_rooms.delete, ) @@ -2832,6 +3022,9 @@ def __init__(self, waiting_rooms: WaitingRoomsResource) -> None: self.update = to_streamed_response_wrapper( waiting_rooms.update, ) + self.list = to_streamed_response_wrapper( + waiting_rooms.list, + ) self.delete = to_streamed_response_wrapper( waiting_rooms.delete, ) @@ -2873,6 +3066,9 @@ def __init__(self, waiting_rooms: AsyncWaitingRoomsResource) -> None: self.update = async_to_streamed_response_wrapper( waiting_rooms.update, ) + self.list = async_to_streamed_response_wrapper( + waiting_rooms.list, + ) self.delete = async_to_streamed_response_wrapper( waiting_rooms.delete, ) diff --git a/src/cloudflare/resources/web3/api.md b/src/cloudflare/resources/web3/api.md new file mode 100644 index 00000000000..62963ca0fd2 --- /dev/null +++ b/src/cloudflare/resources/web3/api.md @@ -0,0 +1,54 @@ +# Web3 + +## Hostnames + +Types: + +```python +from cloudflare.types.web3 import Hostname, HostnameDeleteResponse +``` + +Methods: + +- 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 + +#### ContentLists + +Types: + +```python +from cloudflare.types.web3.hostnames.ipfs_universal_paths import ContentList +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.web3.hostnames.ipfs_universal_paths.content_lists import ( + EntryCreateResponse, + EntryUpdateResponse, + EntryListResponse, + EntryDeleteResponse, + EntryGetResponse, +) +``` + +Methods: + +- 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 diff --git a/src/cloudflare/resources/web3/hostnames/hostnames.py b/src/cloudflare/resources/web3/hostnames/hostnames.py index e10e570a89d..0f57d24f757 100644 --- a/src/cloudflare/resources/web3/hostnames/hostnames.py +++ b/src/cloudflare/resources/web3/hostnames/hostnames.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -62,7 +62,7 @@ def with_streaming_response(self) -> HostnamesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, target: Literal["ethereum", "ipfs", "ipfs_universal_path"], description: str | Omit = omit, @@ -96,10 +96,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/web3/hostnames", + path_template("/zones/{zone_id}/web3/hostnames", zone_id=zone_id), body=maybe_transform( { "name": name, @@ -122,7 +124,7 @@ def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -144,10 +146,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/web3/hostnames", + path_template("/zones/{zone_id}/web3/hostnames", zone_id=zone_id), page=SyncSinglePage[Hostname], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -159,7 +163,7 @@ def delete( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -183,12 +187,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._delete( - f"/zones/{zone_id}/web3/hostnames/{identifier}", + path_template("/zones/{zone_id}/web3/hostnames/{identifier}", zone_id=zone_id, identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -203,7 +209,7 @@ def edit( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, dnslink: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -233,12 +239,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._patch( - f"/zones/{zone_id}/web3/hostnames/{identifier}", + path_template("/zones/{zone_id}/web3/hostnames/{identifier}", zone_id=zone_id, identifier=identifier), body=maybe_transform( { "description": description, @@ -260,7 +268,7 @@ def get( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -284,12 +292,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._get( - f"/zones/{zone_id}/web3/hostnames/{identifier}", + path_template("/zones/{zone_id}/web3/hostnames/{identifier}", zone_id=zone_id, identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -328,7 +338,7 @@ def with_streaming_response(self) -> AsyncHostnamesResourceWithStreamingResponse async def create( self, *, - zone_id: str, + zone_id: str | None = None, name: str, target: Literal["ethereum", "ipfs", "ipfs_universal_path"], description: str | Omit = omit, @@ -362,10 +372,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/web3/hostnames", + path_template("/zones/{zone_id}/web3/hostnames", zone_id=zone_id), body=await async_maybe_transform( { "name": name, @@ -388,7 +400,7 @@ async def create( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -410,10 +422,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/web3/hostnames", + path_template("/zones/{zone_id}/web3/hostnames", zone_id=zone_id), page=AsyncSinglePage[Hostname], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -425,7 +439,7 @@ async def delete( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -449,12 +463,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._delete( - f"/zones/{zone_id}/web3/hostnames/{identifier}", + path_template("/zones/{zone_id}/web3/hostnames/{identifier}", zone_id=zone_id, identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -469,7 +485,7 @@ async def edit( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, description: str | Omit = omit, dnslink: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -499,12 +515,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._patch( - f"/zones/{zone_id}/web3/hostnames/{identifier}", + path_template("/zones/{zone_id}/web3/hostnames/{identifier}", zone_id=zone_id, identifier=identifier), body=await async_maybe_transform( { "description": description, @@ -526,7 +544,7 @@ async def get( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -550,12 +568,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._get( - f"/zones/{zone_id}/web3/hostnames/{identifier}", + path_template("/zones/{zone_id}/web3/hostnames/{identifier}", zone_id=zone_id, identifier=identifier), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py b/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py index 609d79b3ba8..e48830f7105 100644 --- a/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py +++ b/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py @@ -16,7 +16,7 @@ AsyncEntriesResourceWithStreamingResponse, ) from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -61,7 +61,7 @@ def update( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, action: Literal["block"], entries: Iterable[content_list_update_params.Entry], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -91,12 +91,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._put( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list", + zone_id=zone_id, + identifier=identifier, + ), body=maybe_transform( { "action": action, @@ -118,7 +124,7 @@ def get( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -142,12 +148,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._get( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list", + zone_id=zone_id, + identifier=identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -187,7 +199,7 @@ async def update( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, action: Literal["block"], entries: Iterable[content_list_update_params.Entry], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -217,12 +229,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._put( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list", + zone_id=zone_id, + identifier=identifier, + ), body=await async_maybe_transform( { "action": action, @@ -244,7 +262,7 @@ async def get( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -268,12 +286,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._get( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list", + zone_id=zone_id, + identifier=identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/entries.py b/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/entries.py index 4e784613f55..24e4aa7a6f8 100644 --- a/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/entries.py +++ b/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/entries.py @@ -8,7 +8,7 @@ import httpx from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -53,7 +53,7 @@ def create( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, content: str, type: Literal["cid", "content_path"], description: str | Omit = omit, @@ -86,12 +86,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._post( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries", + zone_id=zone_id, + identifier=identifier, + ), body=maybe_transform( { "content": content, @@ -114,7 +120,7 @@ def update( self, content_list_entry_identifier: str, *, - zone_id: str, + zone_id: str | None = None, identifier: str, content: str, type: Literal["cid", "content_path"], @@ -150,6 +156,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: @@ -159,7 +167,12 @@ def update( f"Expected a non-empty value for `content_list_entry_identifier` but received {content_list_entry_identifier!r}" ) return self._put( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + zone_id=zone_id, + identifier=identifier, + content_list_entry_identifier=content_list_entry_identifier, + ), body=maybe_transform( { "content": content, @@ -182,7 +195,7 @@ def list( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -206,12 +219,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return self._get( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries", + zone_id=zone_id, + identifier=identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -226,7 +245,7 @@ def delete( self, content_list_entry_identifier: str, *, - zone_id: str, + zone_id: str | None = None, identifier: 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. @@ -253,6 +272,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: @@ -262,7 +283,12 @@ def delete( f"Expected a non-empty value for `content_list_entry_identifier` but received {content_list_entry_identifier!r}" ) return self._delete( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + zone_id=zone_id, + identifier=identifier, + content_list_entry_identifier=content_list_entry_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -277,7 +303,7 @@ def get( self, content_list_entry_identifier: str, *, - zone_id: str, + zone_id: str | None = None, identifier: 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. @@ -304,6 +330,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: @@ -313,7 +341,12 @@ def get( f"Expected a non-empty value for `content_list_entry_identifier` but received {content_list_entry_identifier!r}" ) return self._get( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + zone_id=zone_id, + identifier=identifier, + content_list_entry_identifier=content_list_entry_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -349,7 +382,7 @@ async def create( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, content: str, type: Literal["cid", "content_path"], description: str | Omit = omit, @@ -382,12 +415,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._post( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries", + zone_id=zone_id, + identifier=identifier, + ), body=await async_maybe_transform( { "content": content, @@ -410,7 +449,7 @@ async def update( self, content_list_entry_identifier: str, *, - zone_id: str, + zone_id: str | None = None, identifier: str, content: str, type: Literal["cid", "content_path"], @@ -446,6 +485,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: @@ -455,7 +496,12 @@ async def update( f"Expected a non-empty value for `content_list_entry_identifier` but received {content_list_entry_identifier!r}" ) return await self._put( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + zone_id=zone_id, + identifier=identifier, + content_list_entry_identifier=content_list_entry_identifier, + ), body=await async_maybe_transform( { "content": content, @@ -478,7 +524,7 @@ async def list( self, identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -502,12 +548,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") return await self._get( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries", + zone_id=zone_id, + identifier=identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -522,7 +574,7 @@ async def delete( self, content_list_entry_identifier: str, *, - zone_id: str, + zone_id: str | None = None, identifier: 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. @@ -549,6 +601,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: @@ -558,7 +612,12 @@ async def delete( f"Expected a non-empty value for `content_list_entry_identifier` but received {content_list_entry_identifier!r}" ) return await self._delete( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + zone_id=zone_id, + identifier=identifier, + content_list_entry_identifier=content_list_entry_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -573,7 +632,7 @@ async def get( self, content_list_entry_identifier: str, *, - zone_id: str, + zone_id: str | None = None, identifier: 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. @@ -600,6 +659,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not identifier: @@ -609,7 +670,12 @@ async def get( f"Expected a non-empty value for `content_list_entry_identifier` but received {content_list_entry_identifier!r}" ) return await self._get( - f"/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + path_template( + "/zones/{zone_id}/web3/hostnames/{identifier}/ipfs_universal_path/content_list/entries/{content_list_entry_identifier}", + zone_id=zone_id, + identifier=identifier, + content_list_entry_identifier=content_list_entry_identifier, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/account_settings.py b/src/cloudflare/resources/workers/account_settings.py index ad45917e32d..fa107160931 100644 --- a/src/cloudflare/resources/workers/account_settings.py +++ b/src/cloudflare/resources/workers/account_settings.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> AccountSettingsResourceWithStreamingRespons def update( self, *, - account_id: str, + account_id: str | None = None, default_usage_model: str | Omit = omit, green_compute: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -72,10 +72,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/account-settings", + path_template("/accounts/{account_id}/workers/account-settings", account_id=account_id), body=maybe_transform( { "default_usage_model": default_usage_model, @@ -96,7 +98,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -118,10 +120,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/account-settings", + path_template("/accounts/{account_id}/workers/account-settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -156,7 +160,7 @@ def with_streaming_response(self) -> AsyncAccountSettingsResourceWithStreamingRe async def update( self, *, - account_id: str, + account_id: str | None = None, default_usage_model: str | Omit = omit, green_compute: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -180,10 +184,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/account-settings", + path_template("/accounts/{account_id}/workers/account-settings", account_id=account_id), body=await async_maybe_transform( { "default_usage_model": default_usage_model, @@ -204,7 +210,7 @@ async def update( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -226,10 +232,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/account-settings", + path_template("/accounts/{account_id}/workers/account-settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/api.md b/src/cloudflare/resources/workers/api.md new file mode 100644 index 00000000000..888b67dbe94 --- /dev/null +++ b/src/cloudflare/resources/workers/api.md @@ -0,0 +1,337 @@ +# 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 ( + RouteCreateResponse, + RouteUpdateResponse, + RouteListResponse, + RouteDeleteResponse, + RouteGetResponse, +) +``` + +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 ( + Script, + ScriptSetting, + ScriptUpdateResponse, + ScriptListResponse, + ScriptGetResponse, + ScriptSearchResponse, +) +``` + +Methods: + +- 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 + +### Assets + +#### Upload + +Types: + +```python +from cloudflare.types.workers.scripts.assets import UploadCreateResponse +``` + +Methods: + +- client.workers.scripts.assets.upload.create(script_name, \*, account_id, \*\*params) -> Optional[UploadCreateResponse] + +### Subdomain + +Types: + +```python +from cloudflare.types.workers.scripts import ( + SubdomainCreateResponse, + SubdomainDeleteResponse, + SubdomainGetResponse, +) +``` + +Methods: + +- 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 ScheduleUpdateResponse, ScheduleGetResponse +``` + +Methods: + +- client.workers.scripts.schedules.update(script_name, \*, account_id, \*\*params) -> ScheduleUpdateResponse +- client.workers.scripts.schedules.get(script_name, \*, account_id) -> ScheduleGetResponse + +### Tail + +Types: + +```python +from cloudflare.types.workers.scripts import ( + ConsumerScript, + TailCreateResponse, + TailDeleteResponse, + TailGetResponse, +) +``` + +Methods: + +- 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) -> TailGetResponse + +### Content + +Methods: + +- 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) -> ScriptSetting +- client.workers.scripts.settings.get(script_name, \*, account_id) -> ScriptSetting + +### Deployments + +Types: + +```python +from cloudflare.types.workers.scripts import ( + Deployment, + DeploymentListResponse, + DeploymentDeleteResponse, +) +``` + +Methods: + +- 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 + +Types: + +```python +from cloudflare.types.workers.scripts import ( + VersionCreateResponse, + VersionListResponse, + VersionGetResponse, +) +``` + +Methods: + +- 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) -> 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 + +Types: + +```python +from cloudflare.types.workers import AccountSettingUpdateResponse, AccountSettingGetResponse +``` + +Methods: + +- client.workers.account_settings.update(\*, account_id, \*\*params) -> AccountSettingUpdateResponse +- client.workers.account_settings.get(\*, account_id) -> AccountSettingGetResponse + +## Domains + +Types: + +```python +from cloudflare.types.workers import ( + DomainUpdateResponse, + DomainListResponse, + DomainDeleteResponse, + DomainGetResponse, +) +``` + +Methods: + +- client.workers.domains.update(\*, account_id, \*\*params) -> DomainUpdateResponse +- client.workers.domains.list(\*, account_id, \*\*params) -> SyncSinglePage[DomainListResponse] +- client.workers.domains.delete(domain_id, \*, account_id) -> DomainDeleteResponse +- client.workers.domains.get(domain_id, \*, account_id) -> DomainGetResponse + +## Subdomains + +Types: + +```python +from cloudflare.types.workers import SubdomainUpdateResponse, SubdomainGetResponse +``` + +Methods: + +- client.workers.subdomains.update(\*, account_id, \*\*params) -> SubdomainUpdateResponse +- client.workers.subdomains.delete(\*, account_id) -> None +- client.workers.subdomains.get(\*, account_id) -> SubdomainGetResponse + +## Observability + +### Telemetry + +Types: + +```python +from cloudflare.types.workers.observability import ( + TelemetryKeysResponse, + TelemetryQueryResponse, + TelemetryValuesResponse, +) +``` + +Methods: + +- 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] + +### Destinations + +Types: + +```python +from cloudflare.types.workers.observability import ( + DestinationCreateResponse, + DestinationUpdateResponse, + DestinationListResponse, + DestinationDeleteResponse, +) +``` + +Methods: + +- client.workers.observability.destinations.create(\*, account_id, \*\*params) -> DestinationCreateResponse +- client.workers.observability.destinations.update(slug, \*, account_id, \*\*params) -> DestinationUpdateResponse +- client.workers.observability.destinations.list(\*, account_id, \*\*params) -> SyncSinglePage[DestinationListResponse] +- client.workers.observability.destinations.delete(slug, \*, account_id) -> Optional[DestinationDeleteResponse] diff --git a/src/cloudflare/resources/workers/assets/upload.py b/src/cloudflare/resources/workers/assets/upload.py index 4ece6d4d094..b59d9ea76d4 100644 --- a/src/cloudflare/resources/workers/assets/upload.py +++ b/src/cloudflare/resources/workers/assets/upload.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> UploadResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, base64: Literal[True], body: Dict[str, str], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,6 +77,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 @@ -84,7 +86,7 @@ def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/workers/assets/upload", + path_template("/accounts/{account_id}/workers/assets/upload", account_id=account_id), body=maybe_transform(body, upload_create_params.UploadCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -121,7 +123,7 @@ def with_streaming_response(self) -> AsyncUploadResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, base64: Literal[True], body: Dict[str, str], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -150,6 +152,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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 @@ -157,7 +161,7 @@ async def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/workers/assets/upload", + path_template("/accounts/{account_id}/workers/assets/upload", account_id=account_id), body=await async_maybe_transform(body, upload_create_params.UploadCreateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/workers/beta/workers/versions.py b/src/cloudflare/resources/workers/beta/workers/versions.py index c8add11372c..a0aac19c2cc 100644 --- a/src/cloudflare/resources/workers/beta/workers/versions.py +++ b/src/cloudflare/resources/workers/beta/workers/versions.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -51,7 +51,7 @@ def create( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, deploy: bool | Omit = omit, annotations: version_create_params.Annotations | Omit = omit, assets: version_create_params.Assets | Omit = omit, @@ -140,12 +140,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return self._post( - f"/accounts/{account_id}/workers/workers/{worker_id}/versions", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}/versions", + account_id=account_id, + worker_id=worker_id, + ), body=maybe_transform( { "annotations": annotations, @@ -178,7 +184,7 @@ def list( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -208,12 +214,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/workers/{worker_id}/versions", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}/versions", + account_id=account_id, + worker_id=worker_id, + ), page=SyncV4PagePaginationArray[Version], options=make_request_options( extra_headers=extra_headers, @@ -235,7 +247,7 @@ def delete( self, version_id: str, *, - account_id: str, + account_id: str | None = None, worker_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. @@ -263,6 +275,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: @@ -270,7 +284,12 @@ def delete( if not version_id: raise ValueError(f"Expected a non-empty value for `version_id` but received {version_id!r}") return self._delete( - f"/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}", + account_id=account_id, + worker_id=worker_id, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -281,7 +300,7 @@ def get( self, version_id: str, *, - account_id: str, + account_id: str | None = None, worker_id: str, include: Literal["modules"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -314,6 +333,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: @@ -321,7 +342,12 @@ def get( 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}/workers/workers/{worker_id}/versions/{version_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}", + account_id=account_id, + worker_id=worker_id, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -358,7 +384,7 @@ async def create( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, deploy: bool | Omit = omit, annotations: version_create_params.Annotations | Omit = omit, assets: version_create_params.Assets | Omit = omit, @@ -447,12 +473,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return await self._post( - f"/accounts/{account_id}/workers/workers/{worker_id}/versions", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}/versions", + account_id=account_id, + worker_id=worker_id, + ), body=await async_maybe_transform( { "annotations": annotations, @@ -485,7 +517,7 @@ def list( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -515,12 +547,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/workers/{worker_id}/versions", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}/versions", + account_id=account_id, + worker_id=worker_id, + ), page=AsyncV4PagePaginationArray[Version], options=make_request_options( extra_headers=extra_headers, @@ -542,7 +580,7 @@ async def delete( self, version_id: str, *, - account_id: str, + account_id: str | None = None, worker_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. @@ -570,6 +608,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: @@ -577,7 +617,12 @@ async def delete( if not version_id: raise ValueError(f"Expected a non-empty value for `version_id` but received {version_id!r}") return await self._delete( - f"/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}", + account_id=account_id, + worker_id=worker_id, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -588,7 +633,7 @@ async def get( self, version_id: str, *, - account_id: str, + account_id: str | None = None, worker_id: str, include: Literal["modules"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -621,6 +666,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: @@ -628,7 +675,12 @@ async def get( 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}/workers/workers/{worker_id}/versions/{version_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}", + account_id=account_id, + worker_id=worker_id, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/beta/workers/workers.py b/src/cloudflare/resources/workers/beta/workers/workers.py index 00cca91310c..5c0d76c2857 100644 --- a/src/cloudflare/resources/workers/beta/workers/workers.py +++ b/src/cloudflare/resources/workers/beta/workers/workers.py @@ -16,7 +16,7 @@ AsyncVersionsResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -62,7 +62,7 @@ def with_streaming_response(self) -> WorkersResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, logpush: bool | Omit = omit, observability: worker_create_params.Observability | Omit = omit, @@ -102,10 +102,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/workers", + path_template("/accounts/{account_id}/workers/workers", account_id=account_id), body=maybe_transform( { "name": name, @@ -131,7 +133,7 @@ def update( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, name: str, logpush: bool | Omit = omit, observability: worker_update_params.Observability | Omit = omit, @@ -176,12 +178,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return self._put( - f"/accounts/{account_id}/workers/workers/{worker_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}", account_id=account_id, worker_id=worker_id + ), body=maybe_transform( { "name": name, @@ -206,7 +212,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, order: Literal["asc", "desc"] | Omit = omit, order_by: Literal["deployed_on", "updated_on", "created_on", "name"] | Omit = omit, page: int | Omit = omit, @@ -240,10 +246,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/workers", + path_template("/accounts/{account_id}/workers/workers", account_id=account_id), page=SyncV4PagePaginationArray[Worker], options=make_request_options( extra_headers=extra_headers, @@ -267,7 +275,7 @@ def delete( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -291,12 +299,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return self._delete( - f"/accounts/{account_id}/workers/workers/{worker_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}", account_id=account_id, worker_id=worker_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -307,7 +319,7 @@ def edit( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, logpush: bool, name: str, observability: worker_edit_params.Observability, @@ -350,12 +362,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return self._patch( - f"/accounts/{account_id}/workers/workers/{worker_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}", account_id=account_id, worker_id=worker_id + ), body=maybe_transform( { "logpush": logpush, @@ -381,7 +397,7 @@ def get( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -405,12 +421,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return self._get( - f"/accounts/{account_id}/workers/workers/{worker_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}", account_id=account_id, worker_id=worker_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -449,7 +469,7 @@ def with_streaming_response(self) -> AsyncWorkersResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, logpush: bool | Omit = omit, observability: worker_create_params.Observability | Omit = omit, @@ -489,10 +509,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/workers", + path_template("/accounts/{account_id}/workers/workers", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -518,7 +540,7 @@ async def update( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, name: str, logpush: bool | Omit = omit, observability: worker_update_params.Observability | Omit = omit, @@ -563,12 +585,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return await self._put( - f"/accounts/{account_id}/workers/workers/{worker_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}", account_id=account_id, worker_id=worker_id + ), body=await async_maybe_transform( { "name": name, @@ -593,7 +619,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, order: Literal["asc", "desc"] | Omit = omit, order_by: Literal["deployed_on", "updated_on", "created_on", "name"] | Omit = omit, page: int | Omit = omit, @@ -627,10 +653,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/workers", + path_template("/accounts/{account_id}/workers/workers", account_id=account_id), page=AsyncV4PagePaginationArray[Worker], options=make_request_options( extra_headers=extra_headers, @@ -654,7 +682,7 @@ async def delete( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -678,12 +706,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return await self._delete( - f"/accounts/{account_id}/workers/workers/{worker_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}", account_id=account_id, worker_id=worker_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -694,7 +726,7 @@ async def edit( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, logpush: bool, name: str, observability: worker_edit_params.Observability, @@ -737,12 +769,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return await self._patch( - f"/accounts/{account_id}/workers/workers/{worker_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}", account_id=account_id, worker_id=worker_id + ), body=await async_maybe_transform( { "logpush": logpush, @@ -768,7 +804,7 @@ async def get( self, worker_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -792,12 +828,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not worker_id: raise ValueError(f"Expected a non-empty value for `worker_id` but received {worker_id!r}") return await self._get( - f"/accounts/{account_id}/workers/workers/{worker_id}", + path_template( + "/accounts/{account_id}/workers/workers/{worker_id}", account_id=account_id, worker_id=worker_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/domains.py b/src/cloudflare/resources/workers/domains.py index c038483acd1..f4333194f55 100644 --- a/src/cloudflare/resources/workers/domains.py +++ b/src/cloudflare/resources/workers/domains.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> DomainsResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, hostname: str, service: str, environment: str | Omit = omit, @@ -90,10 +90,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/domains", + path_template("/accounts/{account_id}/workers/domains", account_id=account_id), body=maybe_transform( { "hostname": hostname, @@ -117,7 +119,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, environment: str | Omit = omit, hostname: str | Omit = omit, service: str | Omit = omit, @@ -154,10 +156,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/domains", + path_template("/accounts/{account_id}/workers/domains", account_id=account_id), page=SyncSinglePage[DomainListResponse], options=make_request_options( extra_headers=extra_headers, @@ -182,7 +186,7 @@ def delete( self, domain_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -208,12 +212,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_id: raise ValueError(f"Expected a non-empty value for `domain_id` but received {domain_id!r}") return self._delete( - f"/accounts/{account_id}/workers/domains/{domain_id}", + path_template( + "/accounts/{account_id}/workers/domains/{domain_id}", account_id=account_id, domain_id=domain_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -224,7 +232,7 @@ def get( self, domain_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -248,12 +256,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_id: raise ValueError(f"Expected a non-empty value for `domain_id` but received {domain_id!r}") return self._get( - f"/accounts/{account_id}/workers/domains/{domain_id}", + path_template( + "/accounts/{account_id}/workers/domains/{domain_id}", account_id=account_id, domain_id=domain_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -288,7 +300,7 @@ def with_streaming_response(self) -> AsyncDomainsResourceWithStreamingResponse: async def update( self, *, - account_id: str, + account_id: str | None = None, hostname: str, service: str, environment: str | Omit = omit, @@ -327,10 +339,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/domains", + path_template("/accounts/{account_id}/workers/domains", account_id=account_id), body=await async_maybe_transform( { "hostname": hostname, @@ -354,7 +368,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, environment: str | Omit = omit, hostname: str | Omit = omit, service: str | Omit = omit, @@ -391,10 +405,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/domains", + path_template("/accounts/{account_id}/workers/domains", account_id=account_id), page=AsyncSinglePage[DomainListResponse], options=make_request_options( extra_headers=extra_headers, @@ -419,7 +435,7 @@ async def delete( self, domain_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -445,12 +461,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_id: raise ValueError(f"Expected a non-empty value for `domain_id` but received {domain_id!r}") return await self._delete( - f"/accounts/{account_id}/workers/domains/{domain_id}", + path_template( + "/accounts/{account_id}/workers/domains/{domain_id}", account_id=account_id, domain_id=domain_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -461,7 +481,7 @@ async def get( self, domain_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -485,12 +505,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not domain_id: raise ValueError(f"Expected a non-empty value for `domain_id` but received {domain_id!r}") return await self._get( - f"/accounts/{account_id}/workers/domains/{domain_id}", + path_template( + "/accounts/{account_id}/workers/domains/{domain_id}", account_id=account_id, domain_id=domain_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/observability/destinations.py b/src/cloudflare/resources/workers/observability/destinations.py index 26a156b902d..21fc2089c5b 100644 --- a/src/cloudflare/resources/workers/observability/destinations.py +++ b/src/cloudflare/resources/workers/observability/destinations.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -56,7 +56,7 @@ def with_streaming_response(self) -> DestinationsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, configuration: destination_create_params.Configuration, enabled: bool, name: str, @@ -80,10 +80,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/destinations", + path_template("/accounts/{account_id}/workers/observability/destinations", account_id=account_id), body=maybe_transform( { "configuration": configuration, @@ -107,7 +109,7 @@ def update( self, slug: str, *, - account_id: str, + account_id: str | None = None, configuration: destination_update_params.Configuration, enabled: bool, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -129,12 +131,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not slug: raise ValueError(f"Expected a non-empty value for `slug` but received {slug!r}") return self._patch( - f"/accounts/{account_id}/workers/observability/destinations/{slug}", + path_template( + "/accounts/{account_id}/workers/observability/destinations/{slug}", account_id=account_id, slug=slug + ), body=maybe_transform( { "configuration": configuration, @@ -155,7 +161,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, order: Literal["asc", "desc"] | Omit = omit, order_by: Literal["created", "updated"] | Omit = omit, page: float | Omit = omit, @@ -179,10 +185,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/destinations", + path_template("/accounts/{account_id}/workers/observability/destinations", account_id=account_id), page=SyncSinglePage[DestinationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -206,7 +214,7 @@ def delete( self, slug: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -226,12 +234,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not slug: raise ValueError(f"Expected a non-empty value for `slug` but received {slug!r}") return self._delete( - f"/accounts/{account_id}/workers/observability/destinations/{slug}", + path_template( + "/accounts/{account_id}/workers/observability/destinations/{slug}", account_id=account_id, slug=slug + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -266,7 +278,7 @@ def with_streaming_response(self) -> AsyncDestinationsResourceWithStreamingRespo async def create( self, *, - account_id: str, + account_id: str | None = None, configuration: destination_create_params.Configuration, enabled: bool, name: str, @@ -290,10 +302,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/destinations", + path_template("/accounts/{account_id}/workers/observability/destinations", account_id=account_id), body=await async_maybe_transform( { "configuration": configuration, @@ -317,7 +331,7 @@ async def update( self, slug: str, *, - account_id: str, + account_id: str | None = None, configuration: destination_update_params.Configuration, enabled: bool, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -339,12 +353,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not slug: raise ValueError(f"Expected a non-empty value for `slug` but received {slug!r}") return await self._patch( - f"/accounts/{account_id}/workers/observability/destinations/{slug}", + path_template( + "/accounts/{account_id}/workers/observability/destinations/{slug}", account_id=account_id, slug=slug + ), body=await async_maybe_transform( { "configuration": configuration, @@ -365,7 +383,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, order: Literal["asc", "desc"] | Omit = omit, order_by: Literal["created", "updated"] | Omit = omit, page: float | Omit = omit, @@ -389,10 +407,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/destinations", + path_template("/accounts/{account_id}/workers/observability/destinations", account_id=account_id), page=AsyncSinglePage[DestinationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -416,7 +436,7 @@ async def delete( self, slug: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -436,12 +456,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not slug: raise ValueError(f"Expected a non-empty value for `slug` but received {slug!r}") return await self._delete( - f"/accounts/{account_id}/workers/observability/destinations/{slug}", + path_template( + "/accounts/{account_id}/workers/observability/destinations/{slug}", account_id=account_id, slug=slug + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/observability/telemetry.py b/src/cloudflare/resources/workers/observability/telemetry.py index c1535dc15f8..4faecf1dcf7 100644 --- a/src/cloudflare/resources/workers/observability/telemetry.py +++ b/src/cloudflare/resources/workers/observability/telemetry.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> TelemetryResourceWithStreamingResponse: def keys( self, *, - account_id: str, + account_id: str | None = None, datasets: SequenceNotStr[str] | Omit = omit, filters: Iterable[telemetry_keys_params.Filter] | Omit = omit, from_: float | Omit = omit, @@ -91,10 +91,12 @@ def keys( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/telemetry/keys", + path_template("/accounts/{account_id}/workers/observability/telemetry/keys", account_id=account_id), page=SyncSinglePage[TelemetryKeysResponse], body=maybe_transform( { @@ -118,7 +120,7 @@ def keys( def query( self, *, - account_id: str, + account_id: str | None = None, query_id: str, timeframe: telemetry_query_params.Timeframe, chart: bool | Omit = omit, @@ -186,10 +188,12 @@ def query( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/telemetry/query", + path_template("/accounts/{account_id}/workers/observability/telemetry/query", account_id=account_id), body=maybe_transform( { "query_id": query_id, @@ -221,7 +225,7 @@ def query( def values( self, *, - account_id: str, + account_id: str | None = None, datasets: SequenceNotStr[str], key: str, timeframe: telemetry_values_params.Timeframe, @@ -255,10 +259,12 @@ def values( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/telemetry/values", + path_template("/accounts/{account_id}/workers/observability/telemetry/values", account_id=account_id), page=SyncSinglePage[TelemetryValuesResponse], body=maybe_transform( { @@ -303,7 +309,7 @@ def with_streaming_response(self) -> AsyncTelemetryResourceWithStreamingResponse def keys( self, *, - account_id: str, + account_id: str | None = None, datasets: SequenceNotStr[str] | Omit = omit, filters: Iterable[telemetry_keys_params.Filter] | Omit = omit, from_: float | Omit = omit, @@ -343,10 +349,12 @@ def keys( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/telemetry/keys", + path_template("/accounts/{account_id}/workers/observability/telemetry/keys", account_id=account_id), page=AsyncSinglePage[TelemetryKeysResponse], body=maybe_transform( { @@ -370,7 +378,7 @@ def keys( async def query( self, *, - account_id: str, + account_id: str | None = None, query_id: str, timeframe: telemetry_query_params.Timeframe, chart: bool | Omit = omit, @@ -438,10 +446,12 @@ async def query( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/telemetry/query", + path_template("/accounts/{account_id}/workers/observability/telemetry/query", account_id=account_id), body=await async_maybe_transform( { "query_id": query_id, @@ -473,7 +483,7 @@ async def query( def values( self, *, - account_id: str, + account_id: str | None = None, datasets: SequenceNotStr[str], key: str, timeframe: telemetry_values_params.Timeframe, @@ -507,10 +517,12 @@ def values( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/observability/telemetry/values", + path_template("/accounts/{account_id}/workers/observability/telemetry/values", account_id=account_id), page=AsyncSinglePage[TelemetryValuesResponse], body=maybe_transform( { diff --git a/src/cloudflare/resources/workers/routes.py b/src/cloudflare/resources/workers/routes.py index 68304d512b8..68afd113ea4 100644 --- a/src/cloudflare/resources/workers/routes.py +++ b/src/cloudflare/resources/workers/routes.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> RoutesResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, pattern: str, script: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -81,10 +81,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/workers/routes", + path_template("/zones/{zone_id}/workers/routes", zone_id=zone_id), body=maybe_transform( { "pattern": pattern, @@ -106,7 +108,7 @@ def update( self, route_id: str, *, - zone_id: str, + zone_id: str | None = None, pattern: str, script: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -137,12 +139,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._put( - f"/zones/{zone_id}/workers/routes/{route_id}", + path_template("/zones/{zone_id}/workers/routes/{route_id}", zone_id=zone_id, route_id=route_id), body=maybe_transform( { "pattern": pattern, @@ -163,7 +167,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -185,10 +189,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/workers/routes", + path_template("/zones/{zone_id}/workers/routes", zone_id=zone_id), page=SyncSinglePage[RouteListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -200,7 +206,7 @@ def delete( self, route_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -224,12 +230,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._delete( - f"/zones/{zone_id}/workers/routes/{route_id}", + path_template("/zones/{zone_id}/workers/routes/{route_id}", zone_id=zone_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -244,7 +252,7 @@ def get( self, route_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -268,12 +276,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._get( - f"/zones/{zone_id}/workers/routes/{route_id}", + path_template("/zones/{zone_id}/workers/routes/{route_id}", zone_id=zone_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -308,7 +318,7 @@ def with_streaming_response(self) -> AsyncRoutesResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, pattern: str, script: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -337,10 +347,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/workers/routes", + path_template("/zones/{zone_id}/workers/routes", zone_id=zone_id), body=await async_maybe_transform( { "pattern": pattern, @@ -362,7 +374,7 @@ async def update( self, route_id: str, *, - zone_id: str, + zone_id: str | None = None, pattern: str, script: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -393,12 +405,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._put( - f"/zones/{zone_id}/workers/routes/{route_id}", + path_template("/zones/{zone_id}/workers/routes/{route_id}", zone_id=zone_id, route_id=route_id), body=await async_maybe_transform( { "pattern": pattern, @@ -419,7 +433,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -441,10 +455,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/workers/routes", + path_template("/zones/{zone_id}/workers/routes", zone_id=zone_id), page=AsyncSinglePage[RouteListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -456,7 +472,7 @@ async def delete( self, route_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -480,12 +496,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._delete( - f"/zones/{zone_id}/workers/routes/{route_id}", + path_template("/zones/{zone_id}/workers/routes/{route_id}", zone_id=zone_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -500,7 +518,7 @@ async def get( self, route_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -524,12 +542,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._get( - f"/zones/{zone_id}/workers/routes/{route_id}", + path_template("/zones/{zone_id}/workers/routes/{route_id}", zone_id=zone_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/scripts/assets/upload.py b/src/cloudflare/resources/workers/scripts/assets/upload.py index a4680e0f1d8..1ba6bba3d53 100644 --- a/src/cloudflare/resources/workers/scripts/assets/upload.py +++ b/src/cloudflare/resources/workers/scripts/assets/upload.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,7 +48,7 @@ def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, manifest: Dict[str, upload_create_params.Manifest], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -79,12 +79,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform({"manifest": manifest}, upload_create_params.UploadCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -121,7 +127,7 @@ async def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, manifest: Dict[str, upload_create_params.Manifest], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -152,12 +158,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform({"manifest": manifest}, upload_create_params.UploadCreateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/workers/scripts/content.py b/src/cloudflare/resources/workers/scripts/content.py index 166a0085820..19b75a320a7 100644 --- a/src/cloudflare/resources/workers/scripts/content.py +++ b/src/cloudflare/resources/workers/scripts/content.py @@ -19,6 +19,7 @@ ) from ...._utils import ( extract_files, + path_template, maybe_transform, strip_not_given, deepcopy_minimal, @@ -72,7 +73,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, metadata: content_update_params.Metadata, files: SequenceNotStr[FileTypes] | Omit = omit, cf_worker_body_part: str | Omit = omit, @@ -110,6 +111,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -135,7 +138,11 @@ def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._put( - f"/accounts/{account_id}/workers/scripts/{script_name}/content", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/content", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform(body, content_update_params.ContentUpdateParams), files=extracted_files, options=make_request_options( @@ -153,7 +160,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -177,13 +184,19 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") extra_headers = {"Accept": "string", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/content/v2", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/content/v2", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -215,7 +228,7 @@ async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, metadata: content_update_params.Metadata, files: SequenceNotStr[FileTypes] | Omit = omit, cf_worker_body_part: str | Omit = omit, @@ -253,6 +266,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -278,7 +293,11 @@ async def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._put( - f"/accounts/{account_id}/workers/scripts/{script_name}/content", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/content", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform(body, content_update_params.ContentUpdateParams), files=extracted_files, options=make_request_options( @@ -296,7 +315,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -320,13 +339,19 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") extra_headers = {"Accept": "string", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/content/v2", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/content/v2", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/workers/scripts/deployments.py b/src/cloudflare/resources/workers/scripts/deployments.py index 16ea873159f..9274c7e45b0 100644 --- a/src/cloudflare/resources/workers/scripts/deployments.py +++ b/src/cloudflare/resources/workers/scripts/deployments.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, strategy: Literal["percentage"], versions: Iterable[deployment_create_params.Version], force: bool | Omit = omit, @@ -85,12 +85,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/deployments", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/deployments", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform( { "strategy": strategy, @@ -114,7 +120,7 @@ def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -140,12 +146,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/deployments", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/deployments", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -160,7 +172,7 @@ def delete( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, script_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. @@ -187,6 +199,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -194,7 +208,12 @@ def delete( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return self._delete( - f"/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}", + account_id=account_id, + script_name=script_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -205,7 +224,7 @@ def get( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, script_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. @@ -230,6 +249,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -237,7 +258,12 @@ def get( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}", + account_id=account_id, + script_name=script_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -273,7 +299,7 @@ async def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, strategy: Literal["percentage"], versions: Iterable[deployment_create_params.Version], force: bool | Omit = omit, @@ -307,12 +333,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/deployments", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/deployments", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform( { "strategy": strategy, @@ -336,7 +368,7 @@ async def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -362,12 +394,18 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/deployments", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/deployments", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -382,7 +420,7 @@ async def delete( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, script_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. @@ -409,6 +447,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -416,7 +456,12 @@ async def delete( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return await self._delete( - f"/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}", + account_id=account_id, + script_name=script_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -427,7 +472,7 @@ async def get( self, deployment_id: str, *, - account_id: str, + account_id: str | None = None, script_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. @@ -452,6 +497,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -459,7 +506,12 @@ async def get( if not deployment_id: raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") return await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}", + account_id=account_id, + script_name=script_name, + deployment_id=deployment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/scripts/schedules.py b/src/cloudflare/resources/workers/scripts/schedules.py index 07db257b926..ca2230b3aaa 100644 --- a/src/cloudflare/resources/workers/scripts/schedules.py +++ b/src/cloudflare/resources/workers/scripts/schedules.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[schedule_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. @@ -74,12 +74,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._put( - f"/accounts/{account_id}/workers/scripts/{script_name}/schedules", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/schedules", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform(body, Iterable[schedule_update_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -95,7 +101,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -119,12 +125,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/schedules", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/schedules", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -160,7 +172,7 @@ async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[schedule_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. @@ -185,12 +197,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._put( - f"/accounts/{account_id}/workers/scripts/{script_name}/schedules", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/schedules", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform(body, Iterable[schedule_update_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -206,7 +224,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -230,12 +248,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/schedules", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/schedules", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/scripts/script_and_version_settings.py b/src/cloudflare/resources/workers/scripts/script_and_version_settings.py index 1d863218932..c6b4c3406e3 100644 --- a/src/cloudflare/resources/workers/scripts/script_and_version_settings.py +++ b/src/cloudflare/resources/workers/scripts/script_and_version_settings.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def edit( self, script_name: str, *, - account_id: str, + account_id: str | None = None, settings: script_and_version_setting_edit_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. @@ -74,6 +74,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -83,7 +85,11 @@ def edit( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._patch( - f"/accounts/{account_id}/workers/scripts/{script_name}/settings", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/settings", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform( {"settings": settings}, script_and_version_setting_edit_params.ScriptAndVersionSettingEditParams ), @@ -102,7 +108,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -126,12 +132,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/settings", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/settings", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -167,7 +179,7 @@ async def edit( self, script_name: str, *, - account_id: str, + account_id: str | None = None, settings: script_and_version_setting_edit_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. @@ -192,6 +204,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -201,7 +215,11 @@ async def edit( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._patch( - f"/accounts/{account_id}/workers/scripts/{script_name}/settings", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/settings", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform( {"settings": settings}, script_and_version_setting_edit_params.ScriptAndVersionSettingEditParams ), @@ -220,7 +238,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -244,12 +262,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/settings", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/settings", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/scripts/scripts.py b/src/cloudflare/resources/workers/scripts/scripts.py index f4f5877b34f..4f1dfe0682a 100644 --- a/src/cloudflare/resources/workers/scripts/scripts.py +++ b/src/cloudflare/resources/workers/scripts/scripts.py @@ -58,7 +58,7 @@ omit, not_given, ) -from ...._utils import is_given, maybe_transform, deepcopy_minimal, async_maybe_transform +from ...._utils import is_given, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform from .schedules import ( SchedulesResource, AsyncSchedulesResource, @@ -182,7 +182,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, metadata: script_update_params.Metadata, bindings_inherit: Literal["strict"] | Omit = omit, files: SequenceNotStr[FileTypes] | Omit = omit, @@ -226,6 +226,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -242,7 +244,9 @@ def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._put( - f"/accounts/{account_id}/workers/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}", account_id=account_id, script_name=script_name + ), body=maybe_transform(body, script_update_params.ScriptUpdateParams), files=extracted_files, options=make_request_options( @@ -260,7 +264,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, tags: 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. @@ -286,10 +290,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/scripts", + path_template("/accounts/{account_id}/workers/scripts", account_id=account_id), page=SyncSinglePage[ScriptListResponse], options=make_request_options( extra_headers=extra_headers, @@ -305,7 +311,7 @@ def delete( self, script_name: str, *, - account_id: str, + account_id: str | None = None, force: 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. @@ -335,12 +341,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._delete( - f"/accounts/{account_id}/workers/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}", account_id=account_id, script_name=script_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -356,7 +366,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -382,13 +392,17 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") extra_headers = {"Accept": "application/javascript", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}", account_id=account_id, script_name=script_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -398,7 +412,7 @@ def get( def search( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, name: str | Omit = omit, order_by: Literal["created_on", "modified_on", "name"] | Omit = omit, @@ -435,10 +449,12 @@ def search( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/scripts-search", + path_template("/accounts/{account_id}/workers/scripts-search", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -524,7 +540,7 @@ async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, metadata: script_update_params.Metadata, bindings_inherit: Literal["strict"] | Omit = omit, files: SequenceNotStr[FileTypes] | Omit = omit, @@ -568,6 +584,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -584,7 +602,9 @@ async def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._put( - f"/accounts/{account_id}/workers/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}", account_id=account_id, script_name=script_name + ), body=await async_maybe_transform(body, script_update_params.ScriptUpdateParams), files=extracted_files, options=make_request_options( @@ -604,7 +624,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, tags: 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. @@ -630,10 +650,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/scripts", + path_template("/accounts/{account_id}/workers/scripts", account_id=account_id), page=AsyncSinglePage[ScriptListResponse], options=make_request_options( extra_headers=extra_headers, @@ -649,7 +671,7 @@ async def delete( self, script_name: str, *, - account_id: str, + account_id: str | None = None, force: 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. @@ -679,12 +701,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._delete( - f"/accounts/{account_id}/workers/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}", account_id=account_id, script_name=script_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -700,7 +726,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -726,13 +752,17 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") extra_headers = {"Accept": "application/javascript", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}", account_id=account_id, script_name=script_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -742,7 +772,7 @@ async def get( async def search( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, name: str | Omit = omit, order_by: Literal["created_on", "modified_on", "name"] | Omit = omit, @@ -779,10 +809,12 @@ async def search( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/scripts-search", + path_template("/accounts/{account_id}/workers/scripts-search", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/scripts/secrets.py b/src/cloudflare/resources/workers/scripts/secrets.py index de30c08f9da..6a789239704 100644 --- a/src/cloudflare/resources/workers/scripts/secrets.py +++ b/src/cloudflare/resources/workers/scripts/secrets.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import required_args, maybe_transform, async_maybe_transform +from ...._utils import path_template, required_args, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -53,7 +53,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, name: str, text: str, type: Literal["secret_text"], @@ -93,7 +93,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, algorithm: object, format: Literal["raw", "pkcs8", "spki", "jwk"], name: str, @@ -147,14 +147,12 @@ def update( """ ... - @required_args( - ["account_id", "name", "text", "type"], ["account_id", "algorithm", "format", "name", "type", "usages"] - ) + @required_args(["name", "text", "type"], ["algorithm", "format", "name", "type", "usages"]) def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, name: str, text: str | Omit = omit, type: Literal["secret_text"] | Literal["secret_key"], @@ -171,6 +169,8 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[SecretUpdateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -178,7 +178,11 @@ def update( return cast( Optional[SecretUpdateResponse], self._put( - f"/accounts/{account_id}/workers/scripts/{script_name}/secrets", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/secrets", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform( { "name": name, @@ -209,7 +213,7 @@ def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -233,12 +237,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/scripts/{script_name}/secrets", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/secrets", + account_id=account_id, + script_name=script_name, + ), page=SyncSinglePage[SecretListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -250,7 +260,7 @@ def delete( self, secret_name: str, *, - account_id: str, + account_id: str | None = None, script_name: str, url_encoded: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -280,6 +290,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -287,7 +299,12 @@ def delete( if not secret_name: raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}") return self._delete( - f"/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}", + account_id=account_id, + script_name=script_name, + secret_name=secret_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -303,7 +320,7 @@ def get( self, secret_name: str, *, - account_id: str, + account_id: str | None = None, script_name: str, url_encoded: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -333,6 +350,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -342,7 +361,12 @@ def get( return cast( Optional[SecretGetResponse], self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}", + account_id=account_id, + script_name=script_name, + secret_name=secret_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -383,7 +407,7 @@ async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, name: str, text: str, type: Literal["secret_text"], @@ -423,7 +447,7 @@ async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, algorithm: object, format: Literal["raw", "pkcs8", "spki", "jwk"], name: str, @@ -477,14 +501,12 @@ async def update( """ ... - @required_args( - ["account_id", "name", "text", "type"], ["account_id", "algorithm", "format", "name", "type", "usages"] - ) + @required_args(["name", "text", "type"], ["algorithm", "format", "name", "type", "usages"]) async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, name: str, text: str | Omit = omit, type: Literal["secret_text"] | Literal["secret_key"], @@ -501,6 +523,8 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[SecretUpdateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -508,7 +532,11 @@ async def update( return cast( Optional[SecretUpdateResponse], await self._put( - f"/accounts/{account_id}/workers/scripts/{script_name}/secrets", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/secrets", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform( { "name": name, @@ -539,7 +567,7 @@ def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -563,12 +591,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/scripts/{script_name}/secrets", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/secrets", + account_id=account_id, + script_name=script_name, + ), page=AsyncSinglePage[SecretListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -580,7 +614,7 @@ async def delete( self, secret_name: str, *, - account_id: str, + account_id: str | None = None, script_name: str, url_encoded: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -610,6 +644,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -617,7 +653,12 @@ async def delete( if not secret_name: raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}") return await self._delete( - f"/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}", + account_id=account_id, + script_name=script_name, + secret_name=secret_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -635,7 +676,7 @@ async def get( self, secret_name: str, *, - account_id: str, + account_id: str | None = None, script_name: str, url_encoded: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -665,6 +706,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -674,7 +717,12 @@ async def get( return cast( Optional[SecretGetResponse], await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}", + account_id=account_id, + script_name=script_name, + secret_name=secret_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/scripts/settings.py b/src/cloudflare/resources/workers/scripts/settings.py index 01e5d5600d8..949e0428051 100644 --- a/src/cloudflare/resources/workers/scripts/settings.py +++ b/src/cloudflare/resources/workers/scripts/settings.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def edit( self, script_name: str, *, - account_id: str, + account_id: str | None = None, logpush: bool | Omit = omit, observability: Optional[setting_edit_params.Observability] | Omit = omit, tags: Optional[SequenceNotStr[str]] | Omit = omit, @@ -87,12 +87,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._patch( - f"/accounts/{account_id}/workers/scripts/{script_name}/script-settings", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/script-settings", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform( { "logpush": logpush, @@ -116,7 +122,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -142,12 +148,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/script-settings", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/script-settings", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -183,7 +195,7 @@ async def edit( self, script_name: str, *, - account_id: str, + account_id: str | None = None, logpush: bool | Omit = omit, observability: Optional[setting_edit_params.Observability] | Omit = omit, tags: Optional[SequenceNotStr[str]] | Omit = omit, @@ -221,12 +233,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._patch( - f"/accounts/{account_id}/workers/scripts/{script_name}/script-settings", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/script-settings", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform( { "logpush": logpush, @@ -250,7 +268,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -276,12 +294,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/script-settings", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/script-settings", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/scripts/subdomain.py b/src/cloudflare/resources/workers/scripts/subdomain.py index ee6e690dabd..6479681a5e8 100644 --- a/src/cloudflare/resources/workers/scripts/subdomain.py +++ b/src/cloudflare/resources/workers/scripts/subdomain.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, enabled: bool, previews_enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -81,12 +81,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform( { "enabled": enabled, @@ -108,7 +114,7 @@ def delete( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -132,12 +138,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._delete( - f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -152,7 +164,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -176,12 +188,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -217,7 +235,7 @@ async def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, enabled: bool, previews_enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -248,12 +266,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform( { "enabled": enabled, @@ -275,7 +299,7 @@ async def delete( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -299,12 +323,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._delete( - f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -319,7 +349,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -343,12 +373,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/subdomain", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/scripts/tail.py b/src/cloudflare/resources/workers/scripts/tail.py index 50f03689386..82e99589d54 100644 --- a/src/cloudflare/resources/workers/scripts/tail.py +++ b/src/cloudflare/resources/workers/scripts/tail.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -75,12 +75,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/tails", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/tails", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform(body, tail_create_params.TailCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -96,7 +102,7 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, script_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. @@ -123,6 +129,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -130,7 +138,12 @@ def delete( if not id: raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") return self._delete( - f"/accounts/{account_id}/workers/scripts/{script_name}/tails/{id}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/tails/{id}", + account_id=account_id, + script_name=script_name, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -141,7 +154,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -165,12 +178,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/tails", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/tails", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -206,7 +225,7 @@ async def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -231,12 +250,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/tails", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/tails", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform(body, tail_create_params.TailCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -252,7 +277,7 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, script_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. @@ -279,6 +304,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -286,7 +313,12 @@ async def delete( 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}/workers/scripts/{script_name}/tails/{id}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/tails/{id}", + account_id=account_id, + script_name=script_name, + id=id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -297,7 +329,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -321,12 +353,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._get( - f"/accounts/{account_id}/workers/scripts/{script_name}/tails", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/tails", + account_id=account_id, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/scripts/versions.py b/src/cloudflare/resources/workers/scripts/versions.py index 3c8f95ecbc1..12caaf824fc 100644 --- a/src/cloudflare/resources/workers/scripts/versions.py +++ b/src/cloudflare/resources/workers/scripts/versions.py @@ -18,7 +18,7 @@ omit, not_given, ) -from ...._utils import is_given, maybe_transform, deepcopy_minimal, async_maybe_transform +from ...._utils import is_given, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -62,7 +62,7 @@ def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, metadata: version_create_params.Metadata, bindings_inherit: Literal["strict"] | Omit = omit, files: SequenceNotStr[FileTypes] | Omit = omit, @@ -106,6 +106,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -122,7 +124,11 @@ def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/versions", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/versions", + account_id=account_id, + script_name=script_name, + ), body=maybe_transform(body, version_create_params.VersionCreateParams), files=extracted_files, options=make_request_options( @@ -143,7 +149,7 @@ def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, deployable: bool | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -177,12 +183,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/scripts/{script_name}/versions", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/versions", + account_id=account_id, + script_name=script_name, + ), page=SyncV4PagePagination[VersionListResponse], options=make_request_options( extra_headers=extra_headers, @@ -205,7 +217,7 @@ def get( self, version_id: str, *, - account_id: str, + account_id: str | None = None, script_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. @@ -230,6 +242,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -237,7 +251,12 @@ def get( 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}/workers/scripts/{script_name}/versions/{version_id}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/versions/{version_id}", + account_id=account_id, + script_name=script_name, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -273,7 +292,7 @@ async def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, metadata: version_create_params.Metadata, bindings_inherit: Literal["strict"] | Omit = omit, files: SequenceNotStr[FileTypes] | Omit = omit, @@ -317,6 +336,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -332,7 +353,11 @@ async def create( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/workers/scripts/{script_name}/versions", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/versions", + account_id=account_id, + script_name=script_name, + ), body=await async_maybe_transform(body, version_create_params.VersionCreateParams), files=extracted_files, options=make_request_options( @@ -353,7 +378,7 @@ def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, deployable: bool | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -387,12 +412,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/scripts/{script_name}/versions", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/versions", + account_id=account_id, + script_name=script_name, + ), page=AsyncV4PagePagination[VersionListResponse], options=make_request_options( extra_headers=extra_headers, @@ -415,7 +446,7 @@ async def get( self, version_id: str, *, - account_id: str, + account_id: str | None = None, script_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. @@ -440,6 +471,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: @@ -447,7 +480,12 @@ async def get( 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}/workers/scripts/{script_name}/versions/{version_id}", + path_template( + "/accounts/{account_id}/workers/scripts/{script_name}/versions/{version_id}", + account_id=account_id, + script_name=script_name, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers/subdomains.py b/src/cloudflare/resources/workers/subdomains.py index 9e20a222431..3bec3af310d 100644 --- a/src/cloudflare/resources/workers/subdomains.py +++ b/src/cloudflare/resources/workers/subdomains.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NoneType, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> SubdomainsResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, subdomain: 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. @@ -71,10 +71,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/subdomain", + path_template("/accounts/{account_id}/workers/subdomain", account_id=account_id), body=maybe_transform({"subdomain": subdomain}, subdomain_update_params.SubdomainUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -89,7 +91,7 @@ def update( def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -111,11 +113,13 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/subdomain", + path_template("/accounts/{account_id}/workers/subdomain", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -125,7 +129,7 @@ def delete( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -147,10 +151,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/subdomain", + path_template("/accounts/{account_id}/workers/subdomain", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -185,7 +191,7 @@ def with_streaming_response(self) -> AsyncSubdomainsResourceWithStreamingRespons async def update( self, *, - account_id: str, + account_id: str | None = None, subdomain: 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. @@ -208,10 +214,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/subdomain", + path_template("/accounts/{account_id}/workers/subdomain", account_id=account_id), body=await async_maybe_transform({"subdomain": subdomain}, subdomain_update_params.SubdomainUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -226,7 +234,7 @@ async def update( async def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -248,11 +256,13 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/subdomain", + path_template("/accounts/{account_id}/workers/subdomain", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -262,7 +272,7 @@ async def delete( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -284,10 +294,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/subdomain", + path_template("/accounts/{account_id}/workers/subdomain", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers_for_platforms/api.md b/src/cloudflare/resources/workers_for_platforms/api.md new file mode 100644 index 00000000000..970d200b5e0 --- /dev/null +++ b/src/cloudflare/resources/workers_for_platforms/api.md @@ -0,0 +1,121 @@ +# WorkersForPlatforms + +## Dispatch + +### Namespaces + +Types: + +```python +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 diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/namespaces.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/namespaces.py index eb1514caadc..d75ba29f9e8 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/namespaces.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/namespaces.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -62,7 +62,7 @@ def with_streaming_response(self) -> NamespacesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -87,10 +87,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/dispatch/namespaces", + path_template("/accounts/{account_id}/workers/dispatch/namespaces", account_id=account_id), body=maybe_transform({"name": name}, namespace_create_params.NamespaceCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -105,7 +107,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,10 +129,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/dispatch/namespaces", + path_template("/accounts/{account_id}/workers/dispatch/namespaces", account_id=account_id), page=SyncSinglePage[NamespaceListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -142,7 +146,7 @@ def delete( self, dispatch_namespace: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -166,12 +170,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: raise ValueError(f"Expected a non-empty value for `dispatch_namespace` but received {dispatch_namespace!r}") return self._delete( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -186,7 +196,7 @@ def get( self, dispatch_namespace: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -210,12 +220,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: raise ValueError(f"Expected a non-empty value for `dispatch_namespace` but received {dispatch_namespace!r}") return self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -254,7 +270,7 @@ def with_streaming_response(self) -> AsyncNamespacesResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -279,10 +295,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/dispatch/namespaces", + path_template("/accounts/{account_id}/workers/dispatch/namespaces", account_id=account_id), body=await async_maybe_transform({"name": name}, namespace_create_params.NamespaceCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -297,7 +315,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -319,10 +337,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workers/dispatch/namespaces", + path_template("/accounts/{account_id}/workers/dispatch/namespaces", account_id=account_id), page=AsyncSinglePage[NamespaceListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -334,7 +354,7 @@ async def delete( self, dispatch_namespace: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -358,12 +378,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: raise ValueError(f"Expected a non-empty value for `dispatch_namespace` but received {dispatch_namespace!r}") return await self._delete( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -378,7 +404,7 @@ async def get( self, dispatch_namespace: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -402,12 +428,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: raise ValueError(f"Expected a non-empty value for `dispatch_namespace` but received {dispatch_namespace!r}") return await self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/asset_upload.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/asset_upload.py index 9d608c0e070..3a27bfc5b07 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/asset_upload.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/asset_upload.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -50,7 +50,7 @@ def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, manifest: Dict[str, asset_upload_create_params.Manifest], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -84,6 +84,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -91,7 +93,12 @@ def create( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._post( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/assets-upload-session", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/assets-upload-session", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=maybe_transform({"manifest": manifest}, asset_upload_create_params.AssetUploadCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -128,7 +135,7 @@ async def create( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, manifest: Dict[str, asset_upload_create_params.Manifest], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -162,6 +169,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -169,7 +178,12 @@ async def create( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._post( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/assets-upload-session", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/assets-upload-session", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=await async_maybe_transform( {"manifest": manifest}, asset_upload_create_params.AssetUploadCreateParams ), diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/bindings.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/bindings.py index 1771a7f7946..fb2456fe9ea 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/bindings.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/bindings.py @@ -7,6 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given +from ......_utils import path_template from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -46,7 +47,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -74,6 +75,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -81,7 +84,12 @@ def get( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/bindings", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/bindings", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), page=SyncSinglePage[BindingGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -114,7 +122,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -142,6 +150,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -149,7 +159,12 @@ def get( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/bindings", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/bindings", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), page=AsyncSinglePage[BindingGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/content.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/content.py index d1934684156..1c51a0e8fd1 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/content.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/content.py @@ -19,6 +19,7 @@ ) from ......_utils import ( extract_files, + path_template, maybe_transform, strip_not_given, deepcopy_minimal, @@ -73,7 +74,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, metadata: WorkerMetadataParam, files: SequenceNotStr[FileTypes] | Omit = omit, @@ -114,6 +115,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -141,7 +144,12 @@ def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._put( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=maybe_transform(body, content_update_params.ContentUpdateParams), files=extracted_files, options=make_request_options( @@ -159,7 +167,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -187,6 +195,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -195,7 +205,12 @@ def get( raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") extra_headers = {"Accept": "string", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -227,7 +242,7 @@ async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, metadata: WorkerMetadataParam, files: SequenceNotStr[FileTypes] | Omit = omit, @@ -268,6 +283,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -295,7 +312,12 @@ async def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._put( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=await async_maybe_transform(body, content_update_params.ContentUpdateParams), files=extracted_files, options=make_request_options( @@ -313,7 +335,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -341,6 +363,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -349,7 +373,12 @@ async def get( raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") extra_headers = {"Accept": "string", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/scripts.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/scripts.py index 268afbd1f05..8d9e207024b 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/scripts.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/scripts.py @@ -58,7 +58,7 @@ omit, not_given, ) -from ......_utils import is_given, maybe_transform, deepcopy_minimal, async_maybe_transform +from ......_utils import is_given, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform from ......_compat import cached_property from .asset_upload import ( AssetUploadResource, @@ -132,7 +132,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, metadata: script_update_params.Metadata, bindings_inherit: Literal["strict"] | Omit = omit, @@ -179,6 +179,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -197,7 +199,12 @@ def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._put( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=maybe_transform(body, script_update_params.ScriptUpdateParams), files=extracted_files, options=make_request_options( @@ -216,7 +223,7 @@ def delete( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, force: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -250,6 +257,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -257,7 +266,12 @@ def delete( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._delete( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -273,7 +287,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -300,6 +314,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -307,7 +323,12 @@ def get( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -367,7 +388,7 @@ async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, metadata: script_update_params.Metadata, bindings_inherit: Literal["strict"] | Omit = omit, @@ -414,6 +435,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -432,7 +455,12 @@ async def update( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._put( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=await async_maybe_transform(body, script_update_params.ScriptUpdateParams), files=extracted_files, options=make_request_options( @@ -453,7 +481,7 @@ async def delete( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, force: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -487,6 +515,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -494,7 +524,12 @@ async def delete( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._delete( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -510,7 +545,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -537,6 +572,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -544,7 +581,12 @@ async def get( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/secrets.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/secrets.py index bd34213ac7d..867c48fcd92 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/secrets.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/secrets.py @@ -8,7 +8,7 @@ import httpx from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ......_utils import required_args, maybe_transform, async_maybe_transform +from ......_utils import path_template, required_args, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -57,7 +57,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, name: str, text: str, @@ -100,7 +100,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, algorithm: object, format: Literal["raw", "pkcs8", "spki", "jwk"], @@ -158,14 +158,14 @@ def update( ... @required_args( - ["account_id", "dispatch_namespace", "name", "text", "type"], - ["account_id", "dispatch_namespace", "algorithm", "format", "name", "type", "usages"], + ["dispatch_namespace", "name", "text", "type"], + ["dispatch_namespace", "algorithm", "format", "name", "type", "usages"], ) def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, name: str, text: str | Omit = omit, @@ -183,6 +183,8 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SecretUpdateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -192,7 +194,12 @@ def update( return cast( SecretUpdateResponse, self._put( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=maybe_transform( { "name": name, @@ -223,7 +230,7 @@ def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -250,6 +257,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -257,7 +266,12 @@ def list( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), page=SyncSinglePage[SecretListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -269,7 +283,7 @@ def delete( self, secret_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, script_name: str, url_encoded: bool | Omit = omit, @@ -302,6 +316,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -311,7 +327,13 @@ def delete( if not secret_name: raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}") return self._delete( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + secret_name=secret_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -327,7 +349,7 @@ def get( self, secret_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, script_name: str, url_encoded: bool | Omit = omit, @@ -361,6 +383,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -372,7 +396,13 @@ def get( return cast( SecretGetResponse, self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + secret_name=secret_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -413,7 +443,7 @@ async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, name: str, text: str, @@ -456,7 +486,7 @@ async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, algorithm: object, format: Literal["raw", "pkcs8", "spki", "jwk"], @@ -514,14 +544,14 @@ async def update( ... @required_args( - ["account_id", "dispatch_namespace", "name", "text", "type"], - ["account_id", "dispatch_namespace", "algorithm", "format", "name", "type", "usages"], + ["dispatch_namespace", "name", "text", "type"], + ["dispatch_namespace", "algorithm", "format", "name", "type", "usages"], ) async def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, name: str, text: str | Omit = omit, @@ -539,6 +569,8 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SecretUpdateResponse: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -548,7 +580,12 @@ async def update( return cast( SecretUpdateResponse, await self._put( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=await async_maybe_transform( { "name": name, @@ -579,7 +616,7 @@ def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -606,6 +643,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -613,7 +652,12 @@ def list( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), page=AsyncSinglePage[SecretListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -625,7 +669,7 @@ async def delete( self, secret_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, script_name: str, url_encoded: bool | Omit = omit, @@ -658,6 +702,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -667,7 +713,13 @@ async def delete( if not secret_name: raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}") return await self._delete( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + secret_name=secret_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -685,7 +737,7 @@ async def get( self, secret_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, script_name: str, url_encoded: bool | Omit = omit, @@ -719,6 +771,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -730,7 +784,13 @@ async def get( return cast( SecretGetResponse, await self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + secret_name=secret_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/settings.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/settings.py index 72c7db91d51..448188925a2 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/settings.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/settings.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -49,7 +49,7 @@ def edit( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, settings: setting_edit_params.Settings | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -81,6 +81,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -92,7 +94,12 @@ def edit( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._patch( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=maybe_transform({"settings": settings}, setting_edit_params.SettingEditParams), options=make_request_options( extra_headers=extra_headers, @@ -109,7 +116,7 @@ def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -136,6 +143,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -143,7 +152,12 @@ def get( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -179,7 +193,7 @@ async def edit( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, settings: setting_edit_params.Settings | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -211,6 +225,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -222,7 +238,12 @@ async def edit( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._patch( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), body=await async_maybe_transform({"settings": settings}, setting_edit_params.SettingEditParams), options=make_request_options( extra_headers=extra_headers, @@ -239,7 +260,7 @@ async def get( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -266,6 +287,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -273,7 +296,12 @@ async def get( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return await self._get( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/tags.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/tags.py index 6c802370411..3a5d2114360 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/tags.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/tags.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -49,7 +49,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, body: Optional[SequenceNotStr[str]], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -79,6 +79,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -86,7 +88,12 @@ def update( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), page=SyncSinglePage[TagUpdateResponse], body=maybe_transform(body, Optional[SequenceNotStr[str]]), options=make_request_options( @@ -100,7 +107,7 @@ def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -127,6 +134,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -134,7 +143,12 @@ def list( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), page=SyncSinglePage[TagListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -146,7 +160,7 @@ def delete( self, tag: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, script_name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -174,6 +188,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -183,7 +199,13 @@ def delete( if not tag: raise ValueError(f"Expected a non-empty value for `tag` but received {tag!r}") return self._delete( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags/{tag}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags/{tag}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + tag=tag, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -219,7 +241,7 @@ def update( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, body: Optional[SequenceNotStr[str]], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -249,6 +271,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -256,7 +280,12 @@ def update( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), page=AsyncSinglePage[TagUpdateResponse], body=maybe_transform(body, Optional[SequenceNotStr[str]]), options=make_request_options( @@ -270,7 +299,7 @@ def list( self, script_name: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: 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. @@ -297,6 +326,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -304,7 +335,12 @@ def list( if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + ), page=AsyncSinglePage[TagListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -316,7 +352,7 @@ async def delete( self, tag: str, *, - account_id: str, + account_id: str | None = None, dispatch_namespace: str, script_name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -344,6 +380,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dispatch_namespace: @@ -353,7 +391,13 @@ async def delete( if not tag: raise ValueError(f"Expected a non-empty value for `tag` but received {tag!r}") return await self._delete( - f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags/{tag}", + path_template( + "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/tags/{tag}", + account_id=account_id, + dispatch_namespace=dispatch_namespace, + script_name=script_name, + tag=tag, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workflows/api.md b/src/cloudflare/resources/workflows/api.md new file mode 100644 index 00000000000..a90bde50ec2 --- /dev/null +++ b/src/cloudflare/resources/workflows/api.md @@ -0,0 +1,70 @@ +# Workflows + +Types: + +```python +from cloudflare.types.workflows import ( + WorkflowUpdateResponse, + WorkflowListResponse, + WorkflowDeleteResponse, + WorkflowGetResponse, +) +``` + +Methods: + +- 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 + +## Instances + +Types: + +```python +from cloudflare.types.workflows import ( + InstanceCreateResponse, + InstanceListResponse, + InstanceBulkResponse, + InstanceGetResponse, +) +``` + +Methods: + +- 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, \*\*params) -> InstanceGetResponse + +### Status + +Types: + +```python +from cloudflare.types.workflows.instances import StatusEditResponse +``` + +Methods: + +- client.workflows.instances.status.edit(instance_id, \*, account_id, workflow_name, \*\*params) -> StatusEditResponse + +### Events + +Methods: + +- client.workflows.instances.events.create(event_type, \*, account_id, workflow_name, instance_id, \*\*params) -> object + +## Versions + +Types: + +```python +from cloudflare.types.workflows import VersionListResponse, VersionGetResponse +``` + +Methods: + +- client.workflows.versions.list(workflow_name, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[VersionListResponse] +- client.workflows.versions.get(version_id, \*, account_id, workflow_name) -> VersionGetResponse diff --git a/src/cloudflare/resources/workflows/instances/events.py b/src/cloudflare/resources/workflows/instances/events.py index 1509e234b2b..ec6c023ec3c 100644 --- a/src/cloudflare/resources/workflows/instances/events.py +++ b/src/cloudflare/resources/workflows/instances/events.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def create( self, event_type: str, *, - account_id: str, + account_id: str | None = None, workflow_name: str, instance_id: str, body: object | Omit = omit, @@ -70,6 +70,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: @@ -79,7 +81,13 @@ def create( if not event_type: raise ValueError(f"Expected a non-empty value for `event_type` but received {event_type!r}") return self._post( - f"/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}", + account_id=account_id, + workflow_name=workflow_name, + instance_id=instance_id, + event_type=event_type, + ), body=maybe_transform(body, event_create_params.EventCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -116,7 +124,7 @@ async def create( self, event_type: str, *, - account_id: str, + account_id: str | None = None, workflow_name: str, instance_id: str, body: object | Omit = omit, @@ -139,6 +147,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: @@ -148,7 +158,13 @@ async def create( if not event_type: raise ValueError(f"Expected a non-empty value for `event_type` but received {event_type!r}") return await self._post( - f"/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}", + account_id=account_id, + workflow_name=workflow_name, + instance_id=instance_id, + event_type=event_type, + ), body=await async_maybe_transform(body, event_create_params.EventCreateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/workflows/instances/instances.py b/src/cloudflare/resources/workflows/instances/instances.py index af214f095b5..9de456c03ba 100644 --- a/src/cloudflare/resources/workflows/instances/instances.py +++ b/src/cloudflare/resources/workflows/instances/instances.py @@ -25,7 +25,7 @@ AsyncStatusResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -78,7 +78,7 @@ def create( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, instance_id: str | Omit = omit, instance_retention: instance_create_params.InstanceRetention | Omit = omit, params: object | Omit = omit, @@ -101,12 +101,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._post( - f"/accounts/{account_id}/workflows/{workflow_name}/instances", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances", + account_id=account_id, + workflow_name=workflow_name, + ), body=maybe_transform( { "instance_id": instance_id, @@ -129,7 +135,7 @@ def list( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, date_end: Union[str, datetime] | Omit = omit, date_start: Union[str, datetime] | Omit = omit, @@ -169,12 +175,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workflows/{workflow_name}/instances", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances", + account_id=account_id, + workflow_name=workflow_name, + ), page=SyncV4PagePaginationArray[InstanceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -201,7 +213,7 @@ def bulk( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[instance_bulk_params.Body] | 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. @@ -222,12 +234,18 @@ def bulk( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workflows/{workflow_name}/instances/batch", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances/batch", + account_id=account_id, + workflow_name=workflow_name, + ), page=SyncSinglePage[InstanceBulkResponse], body=maybe_transform(body, Iterable[instance_bulk_params.Body]), options=make_request_options( @@ -241,7 +259,7 @@ def get( self, instance_id: str, *, - account_id: str, + account_id: str | None = None, workflow_name: str, order: Literal["asc", "desc"] | Omit = omit, simple: Literal["true", "false"] | Omit = omit, @@ -268,6 +286,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: @@ -275,7 +295,12 @@ def get( if not instance_id: raise ValueError(f"Expected a non-empty value for `instance_id` but received {instance_id!r}") return self._get( - f"/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}", + account_id=account_id, + workflow_name=workflow_name, + instance_id=instance_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -326,7 +351,7 @@ async def create( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, instance_id: str | Omit = omit, instance_retention: instance_create_params.InstanceRetention | Omit = omit, params: object | Omit = omit, @@ -349,12 +374,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return await self._post( - f"/accounts/{account_id}/workflows/{workflow_name}/instances", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances", + account_id=account_id, + workflow_name=workflow_name, + ), body=await async_maybe_transform( { "instance_id": instance_id, @@ -377,7 +408,7 @@ def list( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, cursor: str | Omit = omit, date_end: Union[str, datetime] | Omit = omit, date_start: Union[str, datetime] | Omit = omit, @@ -417,12 +448,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workflows/{workflow_name}/instances", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances", + account_id=account_id, + workflow_name=workflow_name, + ), page=AsyncV4PagePaginationArray[InstanceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -449,7 +486,7 @@ def bulk( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[instance_bulk_params.Body] | 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. @@ -470,12 +507,18 @@ def bulk( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workflows/{workflow_name}/instances/batch", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances/batch", + account_id=account_id, + workflow_name=workflow_name, + ), page=AsyncSinglePage[InstanceBulkResponse], body=maybe_transform(body, Iterable[instance_bulk_params.Body]), options=make_request_options( @@ -489,7 +532,7 @@ async def get( self, instance_id: str, *, - account_id: str, + account_id: str | None = None, workflow_name: str, order: Literal["asc", "desc"] | Omit = omit, simple: Literal["true", "false"] | Omit = omit, @@ -516,6 +559,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: @@ -523,7 +568,12 @@ async def get( if not instance_id: raise ValueError(f"Expected a non-empty value for `instance_id` but received {instance_id!r}") return await self._get( - f"/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}", + account_id=account_id, + workflow_name=workflow_name, + instance_id=instance_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workflows/instances/status.py b/src/cloudflare/resources/workflows/instances/status.py index 3b23b17a5bc..eb3b52525f0 100644 --- a/src/cloudflare/resources/workflows/instances/status.py +++ b/src/cloudflare/resources/workflows/instances/status.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def edit( self, instance_id: str, *, - account_id: str, + account_id: str | None = None, workflow_name: str, status: Literal["resume", "pause", "terminate", "restart"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -74,6 +74,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: @@ -81,7 +83,12 @@ def edit( if not instance_id: raise ValueError(f"Expected a non-empty value for `instance_id` but received {instance_id!r}") return self._patch( - f"/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/status", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/status", + account_id=account_id, + workflow_name=workflow_name, + instance_id=instance_id, + ), body=maybe_transform({"status": status}, status_edit_params.StatusEditParams), options=make_request_options( extra_headers=extra_headers, @@ -118,7 +125,7 @@ async def edit( self, instance_id: str, *, - account_id: str, + account_id: str | None = None, workflow_name: str, status: Literal["resume", "pause", "terminate", "restart"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -143,6 +150,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: @@ -150,7 +159,12 @@ async def edit( if not instance_id: raise ValueError(f"Expected a non-empty value for `instance_id` but received {instance_id!r}") return await self._patch( - f"/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/status", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/status", + account_id=account_id, + workflow_name=workflow_name, + instance_id=instance_id, + ), body=await async_maybe_transform({"status": status}, status_edit_params.StatusEditParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/workflows/versions.py b/src/cloudflare/resources/workflows/versions.py index 2a683b3a473..79434869d64 100644 --- a/src/cloudflare/resources/workflows/versions.py +++ b/src/cloudflare/resources/workflows/versions.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -50,7 +50,7 @@ def list( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -72,12 +72,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workflows/{workflow_name}/versions", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/versions", + account_id=account_id, + workflow_name=workflow_name, + ), page=SyncV4PagePaginationArray[VersionListResponse], options=make_request_options( extra_headers=extra_headers, @@ -99,7 +105,7 @@ def get( self, version_id: str, *, - account_id: str, + account_id: str | None = None, workflow_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. @@ -120,6 +126,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: @@ -127,7 +135,12 @@ def get( 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}/workflows/{workflow_name}/versions/{version_id}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/versions/{version_id}", + account_id=account_id, + workflow_name=workflow_name, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -163,7 +176,7 @@ def list( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -185,12 +198,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._get_api_list( - f"/accounts/{account_id}/workflows/{workflow_name}/versions", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/versions", + account_id=account_id, + workflow_name=workflow_name, + ), page=AsyncV4PagePaginationArray[VersionListResponse], options=make_request_options( extra_headers=extra_headers, @@ -212,7 +231,7 @@ async def get( self, version_id: str, *, - account_id: str, + account_id: str | None = None, workflow_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. @@ -233,6 +252,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: @@ -240,7 +261,12 @@ async def get( 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}/workflows/{workflow_name}/versions/{version_id}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}/versions/{version_id}", + account_id=account_id, + workflow_name=workflow_name, + version_id=version_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/workflows/workflows.py b/src/cloudflare/resources/workflows/workflows.py index 049fdee3dd5..02d76468b2f 100644 --- a/src/cloudflare/resources/workflows/workflows.py +++ b/src/cloudflare/resources/workflows/workflows.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .versions import ( VersionsResource, AsyncVersionsResource, @@ -76,7 +76,7 @@ def update( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, class_name: str, script_name: str, limits: workflow_update_params.Limits | Omit = omit, @@ -99,12 +99,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._put( - f"/accounts/{account_id}/workflows/{workflow_name}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}", account_id=account_id, workflow_name=workflow_name + ), body=maybe_transform( { "class_name": class_name, @@ -126,7 +130,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: float | Omit = omit, per_page: float | Omit = omit, search: str | Omit = omit, @@ -151,10 +155,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workflows", + path_template("/accounts/{account_id}/workflows", account_id=account_id), page=SyncV4PagePaginationArray[WorkflowListResponse], options=make_request_options( extra_headers=extra_headers, @@ -177,7 +183,7 @@ def delete( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -199,12 +205,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._delete( - f"/accounts/{account_id}/workflows/{workflow_name}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}", account_id=account_id, workflow_name=workflow_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -219,7 +229,7 @@ def get( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -239,12 +249,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return self._get( - f"/accounts/{account_id}/workflows/{workflow_name}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}", account_id=account_id, workflow_name=workflow_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -288,7 +302,7 @@ async def update( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, class_name: str, script_name: str, limits: workflow_update_params.Limits | Omit = omit, @@ -311,12 +325,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return await self._put( - f"/accounts/{account_id}/workflows/{workflow_name}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}", account_id=account_id, workflow_name=workflow_name + ), body=await async_maybe_transform( { "class_name": class_name, @@ -338,7 +356,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: float | Omit = omit, per_page: float | Omit = omit, search: str | Omit = omit, @@ -363,10 +381,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/workflows", + path_template("/accounts/{account_id}/workflows", account_id=account_id), page=AsyncV4PagePaginationArray[WorkflowListResponse], options=make_request_options( extra_headers=extra_headers, @@ -389,7 +409,7 @@ async def delete( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -411,12 +431,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return await self._delete( - f"/accounts/{account_id}/workflows/{workflow_name}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}", account_id=account_id, workflow_name=workflow_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -431,7 +455,7 @@ async def get( self, workflow_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -451,12 +475,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not workflow_name: raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}") return await self._get( - f"/accounts/{account_id}/workflows/{workflow_name}", + path_template( + "/accounts/{account_id}/workflows/{workflow_name}", account_id=account_id, workflow_name=workflow_name + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zaraz/api.md b/src/cloudflare/resources/zaraz/api.md new file mode 100644 index 00000000000..ede071d3f4b --- /dev/null +++ b/src/cloudflare/resources/zaraz/api.md @@ -0,0 +1,85 @@ +# Zaraz + +Types: + +```python +from cloudflare.types.zaraz import ButtonTextTranslation, NeoEvent +``` + +Methods: + +- client.zaraz.update(\*, zone_id, \*\*params) -> Workflow + +## Config + +Types: + +```python +from cloudflare.types.zaraz import Configuration +``` + +Methods: + +- client.zaraz.config.update(\*, zone_id, \*\*params) -> Configuration +- client.zaraz.config.get(\*, zone_id) -> Configuration + +## Default + +Methods: + +- client.zaraz.default.get(\*, zone_id) -> Configuration + +## Export + +Methods: + +- client.zaraz.export.get(\*, zone_id) -> Configuration + +## History + +Types: + +```python +from cloudflare.types.zaraz import HistoryListResponse +``` + +Methods: + +- client.zaraz.history.update(\*, zone_id, \*\*params) -> Configuration +- client.zaraz.history.list(\*, zone_id, \*\*params) -> SyncSinglePage[HistoryListResponse] + +### Configs + +Types: + +```python +from cloudflare.types.zaraz.history import ConfigGetResponse +``` + +Methods: + +- client.zaraz.history.configs.get(\*, zone_id, \*\*params) -> ConfigGetResponse + +## Publish + +Types: + +```python +from cloudflare.types.zaraz import PublishCreateResponse +``` + +Methods: + +- client.zaraz.publish.create(\*, zone_id, \*\*params) -> str + +## Workflow + +Types: + +```python +from cloudflare.types.zaraz import Workflow +``` + +Methods: + +- client.zaraz.workflow.get(\*, zone_id) -> Workflow diff --git a/src/cloudflare/resources/zaraz/config.py b/src/cloudflare/resources/zaraz/config.py index 5d1b304df81..feee007e472 100644 --- a/src/cloudflare/resources/zaraz/config.py +++ b/src/cloudflare/resources/zaraz/config.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> ConfigResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, data_layer: bool, debug_key: str, settings: config_update_params.Settings, @@ -103,10 +103,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/settings/zaraz/config", + path_template("/zones/{zone_id}/settings/zaraz/config", zone_id=zone_id), body=maybe_transform( { "data_layer": data_layer, @@ -135,7 +137,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -160,10 +162,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/settings/zaraz/config", + path_template("/zones/{zone_id}/settings/zaraz/config", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -198,7 +202,7 @@ def with_streaming_response(self) -> AsyncConfigResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, data_layer: bool, debug_key: str, settings: config_update_params.Settings, @@ -254,10 +258,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/settings/zaraz/config", + path_template("/zones/{zone_id}/settings/zaraz/config", zone_id=zone_id), body=await async_maybe_transform( { "data_layer": data_layer, @@ -286,7 +292,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -311,10 +317,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/settings/zaraz/config", + path_template("/zones/{zone_id}/settings/zaraz/config", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zaraz/default.py b/src/cloudflare/resources/zaraz/default.py index 3e800d50847..c97fa58cf63 100644 --- a/src/cloudflare/resources/zaraz/default.py +++ b/src/cloudflare/resources/zaraz/default.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> DefaultResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/settings/zaraz/default", + path_template("/zones/{zone_id}/settings/zaraz/default", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -105,7 +108,7 @@ def with_streaming_response(self) -> AsyncDefaultResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,10 +130,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/settings/zaraz/default", + path_template("/zones/{zone_id}/settings/zaraz/default", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zaraz/export.py b/src/cloudflare/resources/zaraz/export.py index 22ecf15a791..18734c3dcbd 100644 --- a/src/cloudflare/resources/zaraz/export.py +++ b/src/cloudflare/resources/zaraz/export.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -42,7 +43,7 @@ def with_streaming_response(self) -> ExportResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -65,10 +66,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/settings/zaraz/export", + path_template("/zones/{zone_id}/settings/zaraz/export", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -99,7 +102,7 @@ def with_streaming_response(self) -> AsyncExportResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -122,10 +125,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/settings/zaraz/export", + path_template("/zones/{zone_id}/settings/zaraz/export", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/zaraz/history/configs.py b/src/cloudflare/resources/zaraz/history/configs.py index cad23f0ea1a..2919d870f18 100644 --- a/src/cloudflare/resources/zaraz/history/configs.py +++ b/src/cloudflare/resources/zaraz/history/configs.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> ConfigsResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, ids: Iterable[int], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -72,10 +72,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/settings/zaraz/history/configs", + path_template("/zones/{zone_id}/settings/zaraz/history/configs", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -111,7 +113,7 @@ def with_streaming_response(self) -> AsyncConfigsResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, ids: Iterable[int], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -136,10 +138,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/settings/zaraz/history/configs", + path_template("/zones/{zone_id}/settings/zaraz/history/configs", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zaraz/history/history.py b/src/cloudflare/resources/zaraz/history/history.py index 3e92f22636b..13e3a95d46a 100644 --- a/src/cloudflare/resources/zaraz/history/history.py +++ b/src/cloudflare/resources/zaraz/history/history.py @@ -16,7 +16,7 @@ AsyncConfigsResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -62,7 +62,7 @@ def with_streaming_response(self) -> HistoryResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, body: int, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -87,10 +87,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/settings/zaraz/history", + path_template("/zones/{zone_id}/settings/zaraz/history", zone_id=zone_id), body=maybe_transform(body, history_update_params.HistoryUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -105,7 +107,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, limit: int | Omit = omit, offset: int | Omit = omit, sort_field: Literal["id", "user_id", "description", "created_at", "updated_at"] | Omit = omit, @@ -139,10 +141,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/settings/zaraz/history", + path_template("/zones/{zone_id}/settings/zaraz/history", zone_id=zone_id), page=SyncSinglePage[HistoryListResponse], options=make_request_options( extra_headers=extra_headers, @@ -190,7 +194,7 @@ def with_streaming_response(self) -> AsyncHistoryResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, body: int, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -215,10 +219,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/settings/zaraz/history", + path_template("/zones/{zone_id}/settings/zaraz/history", zone_id=zone_id), body=await async_maybe_transform(body, history_update_params.HistoryUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -233,7 +239,7 @@ async def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, limit: int | Omit = omit, offset: int | Omit = omit, sort_field: Literal["id", "user_id", "description", "created_at", "updated_at"] | Omit = omit, @@ -267,10 +273,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/settings/zaraz/history", + path_template("/zones/{zone_id}/settings/zaraz/history", zone_id=zone_id), page=AsyncSinglePage[HistoryListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zaraz/publish.py b/src/cloudflare/resources/zaraz/publish.py index 5c3e4db9d5f..9681688e0c0 100644 --- a/src/cloudflare/resources/zaraz/publish.py +++ b/src/cloudflare/resources/zaraz/publish.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> PublishResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, body: 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. @@ -72,10 +72,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/settings/zaraz/publish", + path_template("/zones/{zone_id}/settings/zaraz/publish", zone_id=zone_id), body=maybe_transform(body, publish_create_params.PublishCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -111,7 +113,7 @@ def with_streaming_response(self) -> AsyncPublishResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, body: 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. @@ -136,10 +138,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/settings/zaraz/publish", + path_template("/zones/{zone_id}/settings/zaraz/publish", zone_id=zone_id), body=await async_maybe_transform(body, publish_create_params.PublishCreateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zaraz/workflow.py b/src/cloudflare/resources/zaraz/workflow.py index 0497a24bea6..d5680f56c07 100644 --- a/src/cloudflare/resources/zaraz/workflow.py +++ b/src/cloudflare/resources/zaraz/workflow.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> WorkflowResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/settings/zaraz/workflow", + path_template("/zones/{zone_id}/settings/zaraz/workflow", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -107,7 +110,7 @@ def with_streaming_response(self) -> AsyncWorkflowResourceWithStreamingResponse: async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -129,10 +132,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/settings/zaraz/workflow", + path_template("/zones/{zone_id}/settings/zaraz/workflow", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zaraz/zaraz.py b/src/cloudflare/resources/zaraz/zaraz.py index 5302880e879..efbe0454406 100644 --- a/src/cloudflare/resources/zaraz/zaraz.py +++ b/src/cloudflare/resources/zaraz/zaraz.py @@ -39,7 +39,7 @@ AsyncPublishResourceWithStreamingResponse, ) from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .workflow import ( WorkflowResource, AsyncWorkflowResource, @@ -119,7 +119,7 @@ def with_streaming_response(self) -> ZarazResourceWithStreamingResponse: def update( self, *, - zone_id: str, + zone_id: str | None = None, workflow: Workflow, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -144,10 +144,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/settings/zaraz/workflow", + path_template("/zones/{zone_id}/settings/zaraz/workflow", zone_id=zone_id), body=maybe_transform(workflow, zaraz_update_params.ZarazUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -209,7 +211,7 @@ def with_streaming_response(self) -> AsyncZarazResourceWithStreamingResponse: async def update( self, *, - zone_id: str, + zone_id: str | None = None, workflow: Workflow, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -234,10 +236,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/settings/zaraz/workflow", + path_template("/zones/{zone_id}/settings/zaraz/workflow", zone_id=zone_id), body=await async_maybe_transform(workflow, zaraz_update_params.ZarazUpdateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/access/ai_controls/mcp/portals.py b/src/cloudflare/resources/zero_trust/access/ai_controls/mcp/portals.py index fa3d5a8b86f..5f2484327fa 100644 --- a/src/cloudflare/resources/zero_trust/access/ai_controls/mcp/portals.py +++ b/src/cloudflare/resources/zero_trust/access/ai_controls/mcp/portals.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> PortalsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, id: str, hostname: str, name: str, @@ -85,10 +85,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals", account_id=account_id), body=maybe_transform( { "id": id, @@ -115,7 +117,7 @@ def update( self, id: str, *, - account_id: str, + account_id: str | None = None, allow_code_mode: bool | Omit = omit, description: str | Omit = omit, hostname: str | Omit = omit, @@ -147,12 +149,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals/{id}", account_id=account_id, id=id), body=maybe_transform( { "allow_code_mode": allow_code_mode, @@ -177,7 +181,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -202,10 +206,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals", account_id=account_id), page=SyncV4PagePaginationArray[PortalListResponse], options=make_request_options( extra_headers=extra_headers, @@ -228,7 +234,7 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -250,12 +256,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -270,7 +278,7 @@ def read( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -292,12 +300,14 @@ def read( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -332,7 +342,7 @@ def with_streaming_response(self) -> AsyncPortalsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, id: str, hostname: str, name: str, @@ -365,10 +375,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals", account_id=account_id), body=await async_maybe_transform( { "id": id, @@ -395,7 +407,7 @@ async def update( self, id: str, *, - account_id: str, + account_id: str | None = None, allow_code_mode: bool | Omit = omit, description: str | Omit = omit, hostname: str | Omit = omit, @@ -427,12 +439,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals/{id}", account_id=account_id, id=id), body=await async_maybe_transform( { "allow_code_mode": allow_code_mode, @@ -457,7 +471,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -482,10 +496,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals", account_id=account_id), page=AsyncV4PagePaginationArray[PortalListResponse], options=make_request_options( extra_headers=extra_headers, @@ -508,7 +524,7 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -530,12 +546,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -550,7 +568,7 @@ async def read( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -572,12 +590,14 @@ async def read( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/portals/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/portals/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/ai_controls/mcp/servers.py b/src/cloudflare/resources/zero_trust/access/ai_controls/mcp/servers.py index c18377acc4e..74006087ff9 100644 --- a/src/cloudflare/resources/zero_trust/access/ai_controls/mcp/servers.py +++ b/src/cloudflare/resources/zero_trust/access/ai_controls/mcp/servers.py @@ -8,7 +8,7 @@ import httpx from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> ServersResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, id: str, auth_type: Literal["oauth", "bearer", "unauthenticated"], hostname: str, @@ -83,10 +83,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers", account_id=account_id), body=maybe_transform( { "id": id, @@ -114,7 +116,7 @@ def update( self, id: str, *, - account_id: str, + account_id: str | None = None, auth_credentials: str | Omit = omit, description: Optional[str] | Omit = omit, name: str | Omit = omit, @@ -141,12 +143,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id), body=maybe_transform( { "auth_credentials": auth_credentials, @@ -170,7 +174,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -195,10 +199,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers", account_id=account_id), page=SyncV4PagePaginationArray[ServerListResponse], options=make_request_options( extra_headers=extra_headers, @@ -221,7 +227,7 @@ def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -243,12 +249,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -263,7 +271,7 @@ def read( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -285,12 +293,14 @@ def read( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -305,7 +315,7 @@ def sync( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -327,12 +337,16 @@ def sync( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers/{id}/sync", + path_template( + "/accounts/{account_id}/access/ai-controls/mcp/servers/{id}/sync", account_id=account_id, id=id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -367,7 +381,7 @@ def with_streaming_response(self) -> AsyncServersResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, id: str, auth_type: Literal["oauth", "bearer", "unauthenticated"], hostname: str, @@ -397,10 +411,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers", account_id=account_id), body=await async_maybe_transform( { "id": id, @@ -428,7 +444,7 @@ async def update( self, id: str, *, - account_id: str, + account_id: str | None = None, auth_credentials: str | Omit = omit, description: Optional[str] | Omit = omit, name: str | Omit = omit, @@ -455,12 +471,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id), body=await async_maybe_transform( { "auth_credentials": auth_credentials, @@ -484,7 +502,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -509,10 +527,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers", account_id=account_id), page=AsyncV4PagePaginationArray[ServerListResponse], options=make_request_options( extra_headers=extra_headers, @@ -535,7 +555,7 @@ async def delete( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -557,12 +577,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -577,7 +599,7 @@ async def read( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -599,12 +621,14 @@ async def read( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers/{id}", + path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -619,7 +643,7 @@ async def sync( self, id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -641,12 +665,16 @@ async def sync( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/ai-controls/mcp/servers/{id}/sync", + path_template( + "/accounts/{account_id}/access/ai-controls/mcp/servers/{id}/sync", account_id=account_id, id=id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/applications/applications.py b/src/cloudflare/resources/zero_trust/access/applications/applications.py index 8d064d27f84..cdb6187e24d 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/applications.py +++ b/src/cloudflare/resources/zero_trust/access/applications/applications.py @@ -32,7 +32,7 @@ AsyncSettingsResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -127,8 +127,8 @@ def create( *, domain: str, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -285,8 +285,8 @@ def create( def create( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, app_launcher_visible: bool | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -371,8 +371,8 @@ def create( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -546,8 +546,8 @@ def create( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -720,8 +720,8 @@ def create( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, app_launcher_logo_url: str | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -802,8 +802,8 @@ def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -866,8 +866,8 @@ def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -930,8 +930,8 @@ def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -1000,8 +1000,8 @@ def create( def create( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, app_launcher_visible: bool | Omit = omit, domain: str | Omit = omit, logo_url: str | Omit = omit, @@ -1058,8 +1058,8 @@ def create( *, target_criteria: Iterable[application_create_params.InfrastructureApplicationTargetCriterion], type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, name: str | Omit = omit, policies: Iterable[application_create_params.InfrastructureApplicationPolicy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1100,8 +1100,8 @@ def create( domain: str, target_criteria: Iterable[application_create_params.BrowserRDPApplicationTargetCriterion], type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -1259,8 +1259,8 @@ def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -1371,8 +1371,8 @@ def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -1504,8 +1504,8 @@ def create( "proxy_endpoint", ] | Omit = omit, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -1588,6 +1588,10 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ApplicationCreateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1603,7 +1607,11 @@ def create( return cast( Optional[ApplicationCreateResponse], self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "domain": domain, @@ -1668,8 +1676,8 @@ def update( *, domain: str, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -1829,8 +1837,8 @@ def update( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, app_launcher_visible: bool | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -1918,8 +1926,8 @@ def update( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -2096,8 +2104,8 @@ def update( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -2273,8 +2281,8 @@ def update( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, app_launcher_logo_url: str | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -2358,8 +2366,8 @@ def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -2425,8 +2433,8 @@ def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -2492,8 +2500,8 @@ def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -2565,8 +2573,8 @@ def update( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, app_launcher_visible: bool | Omit = omit, domain: str | Omit = omit, logo_url: str | Omit = omit, @@ -2626,8 +2634,8 @@ def update( *, target_criteria: Iterable[application_update_params.InfrastructureApplicationTargetCriterion], type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, name: str | Omit = omit, policies: Iterable[application_update_params.InfrastructureApplicationPolicy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -2671,8 +2679,8 @@ def update( domain: str, target_criteria: Iterable[application_update_params.BrowserRDPApplicationTargetCriterion], type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -2833,8 +2841,8 @@ def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -2948,8 +2956,8 @@ def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -3084,8 +3092,8 @@ def update( "proxy_endpoint", ] | Omit = omit, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -3170,6 +3178,10 @@ def update( ) -> Optional[ApplicationUpdateResponse]: if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3185,7 +3197,12 @@ def update( return cast( Optional[ApplicationUpdateResponse], self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "domain": domain, @@ -3246,8 +3263,8 @@ def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, aud: str | Omit = omit, domain: str | Omit = omit, exact: bool | Omit = omit, @@ -3295,6 +3312,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3308,7 +3329,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncV4PagePaginationArray[ApplicationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -3336,8 +3361,8 @@ def delete( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -3365,6 +3390,10 @@ def delete( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3378,7 +3407,12 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -3393,8 +3427,8 @@ def get( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -3422,6 +3456,10 @@ def get( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3437,7 +3475,12 @@ def get( return cast( Optional[ApplicationGetResponse], self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -3455,8 +3498,8 @@ def revoke_tokens( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -3484,6 +3527,10 @@ def revoke_tokens( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3497,7 +3544,12 @@ def revoke_tokens( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/revoke_tokens", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/revoke_tokens", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -3555,8 +3607,8 @@ async def create( *, domain: str, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -3713,8 +3765,8 @@ async def create( async def create( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, app_launcher_visible: bool | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -3799,8 +3851,8 @@ async def create( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -3974,8 +4026,8 @@ async def create( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -4148,8 +4200,8 @@ async def create( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, app_launcher_logo_url: str | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -4230,8 +4282,8 @@ async def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -4294,8 +4346,8 @@ async def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -4358,8 +4410,8 @@ async def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -4428,8 +4480,8 @@ async def create( async def create( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, app_launcher_visible: bool | Omit = omit, domain: str | Omit = omit, logo_url: str | Omit = omit, @@ -4486,8 +4538,8 @@ async def create( *, target_criteria: Iterable[application_create_params.InfrastructureApplicationTargetCriterion], type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, name: str | Omit = omit, policies: Iterable[application_create_params.InfrastructureApplicationPolicy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -4528,8 +4580,8 @@ async def create( domain: str, target_criteria: Iterable[application_create_params.BrowserRDPApplicationTargetCriterion], type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -4687,8 +4739,8 @@ async def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -4799,8 +4851,8 @@ async def create( self, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -4932,8 +4984,8 @@ async def create( "proxy_endpoint", ] | Omit = omit, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -5016,6 +5068,10 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ApplicationCreateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -5031,7 +5087,11 @@ async def create( return cast( Optional[ApplicationCreateResponse], await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "domain": domain, @@ -5096,8 +5156,8 @@ async def update( *, domain: str, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -5257,8 +5317,8 @@ async def update( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, app_launcher_visible: bool | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -5346,8 +5406,8 @@ async def update( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -5524,8 +5584,8 @@ async def update( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -5701,8 +5761,8 @@ async def update( "mcp_portal", "proxy_endpoint", ], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, app_launcher_logo_url: str | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -5786,8 +5846,8 @@ async def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -5853,8 +5913,8 @@ async def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -5920,8 +5980,8 @@ async def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, custom_deny_url: str | Omit = omit, @@ -5993,8 +6053,8 @@ async def update( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, app_launcher_visible: bool | Omit = omit, domain: str | Omit = omit, logo_url: str | Omit = omit, @@ -6054,8 +6114,8 @@ async def update( *, target_criteria: Iterable[application_update_params.InfrastructureApplicationTargetCriterion], type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, name: str | Omit = omit, policies: Iterable[application_update_params.InfrastructureApplicationPolicy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -6099,8 +6159,8 @@ async def update( domain: str, target_criteria: Iterable[application_update_params.BrowserRDPApplicationTargetCriterion], type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -6261,8 +6321,8 @@ async def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -6376,8 +6436,8 @@ async def update( app_id: AppID, *, type: ApplicationType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -6512,8 +6572,8 @@ async def update( "proxy_endpoint", ] | Omit = omit, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, allow_iframe: bool | Omit = omit, allowed_idps: SequenceNotStr[AllowedIdPs] | Omit = omit, @@ -6598,6 +6658,10 @@ async def update( ) -> Optional[ApplicationUpdateResponse]: if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -6613,7 +6677,12 @@ async def update( return cast( Optional[ApplicationUpdateResponse], await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "domain": domain, @@ -6674,8 +6743,8 @@ async def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, aud: str | Omit = omit, domain: str | Omit = omit, exact: bool | Omit = omit, @@ -6723,6 +6792,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -6736,7 +6809,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncV4PagePaginationArray[ApplicationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -6764,8 +6841,8 @@ async def delete( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -6793,6 +6870,10 @@ async def delete( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -6806,7 +6887,12 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -6821,8 +6907,8 @@ async def get( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -6850,6 +6936,10 @@ async def get( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -6865,7 +6955,12 @@ async def get( return cast( Optional[ApplicationGetResponse], await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -6883,8 +6978,8 @@ async def revoke_tokens( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -6912,6 +7007,10 @@ async def revoke_tokens( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -6925,7 +7024,12 @@ async def revoke_tokens( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/revoke_tokens", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/revoke_tokens", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/applications/cas.py b/src/cloudflare/resources/zero_trust/access/applications/cas.py index 503adeb3150..6b94f74be28 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/cas.py +++ b/src/cloudflare/resources/zero_trust/access/applications/cas.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -50,8 +50,8 @@ def create( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -79,6 +79,10 @@ def create( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -92,7 +96,12 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -106,8 +115,8 @@ def create( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -137,6 +146,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -150,7 +163,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/ca", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/ca", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncV4PagePaginationArray[CA], options=make_request_options( extra_headers=extra_headers, @@ -172,8 +189,8 @@ def delete( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -201,6 +218,10 @@ def delete( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -214,7 +235,12 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,8 +255,8 @@ def get( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -258,6 +284,10 @@ def get( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -271,7 +301,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -307,8 +342,8 @@ async def create( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -336,6 +371,10 @@ async def create( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -349,7 +388,12 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -363,8 +407,8 @@ async def create( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -394,6 +438,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -407,7 +455,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/ca", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/ca", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncV4PagePaginationArray[CA], options=make_request_options( extra_headers=extra_headers, @@ -429,8 +481,8 @@ async def delete( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -458,6 +510,10 @@ async def delete( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -471,7 +527,12 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -486,8 +547,8 @@ async def get( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -515,6 +576,10 @@ async def get( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -528,7 +593,12 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/applications/policies.py b/src/cloudflare/resources/zero_trust/access/applications/policies.py index 8d7dc0d9675..80357828993 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/policies.py +++ b/src/cloudflare/resources/zero_trust/access/applications/policies.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -54,8 +54,8 @@ def create( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, approval_groups: Iterable[ApprovalGroupParam] | Omit = omit, approval_required: bool | Omit = omit, connection_rules: policy_create_params.ConnectionRules | Omit = omit, @@ -120,6 +120,10 @@ def create( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -133,7 +137,12 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "approval_groups": approval_groups, @@ -163,8 +172,8 @@ def update( policy_id: str, *, app_id: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, approval_groups: Iterable[ApprovalGroupParam] | Omit = omit, approval_required: bool | Omit = omit, connection_rules: policy_update_params.ConnectionRules | Omit = omit, @@ -232,6 +241,10 @@ def update( raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -245,7 +258,13 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + app_id=app_id, + policy_id=policy_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "approval_groups": approval_groups, @@ -274,8 +293,8 @@ def list( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -311,6 +330,10 @@ def list( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -324,7 +347,12 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncV4PagePaginationArray[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, @@ -347,8 +375,8 @@ def delete( policy_id: str, *, app_id: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -382,6 +410,10 @@ def delete( raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -395,7 +427,13 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + app_id=app_id, + policy_id=policy_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -411,8 +449,8 @@ def get( policy_id: str, *, app_id: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -446,6 +484,10 @@ def get( raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -459,7 +501,13 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + app_id=app_id, + policy_id=policy_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -495,8 +543,8 @@ async def create( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, approval_groups: Iterable[ApprovalGroupParam] | Omit = omit, approval_required: bool | Omit = omit, connection_rules: policy_create_params.ConnectionRules | Omit = omit, @@ -561,6 +609,10 @@ async def create( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -574,7 +626,12 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "approval_groups": approval_groups, @@ -604,8 +661,8 @@ async def update( policy_id: str, *, app_id: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, approval_groups: Iterable[ApprovalGroupParam] | Omit = omit, approval_required: bool | Omit = omit, connection_rules: policy_update_params.ConnectionRules | Omit = omit, @@ -673,6 +730,10 @@ async def update( raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -686,7 +747,13 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + app_id=app_id, + policy_id=policy_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "approval_groups": approval_groups, @@ -715,8 +782,8 @@ def list( self, app_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -752,6 +819,10 @@ def list( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -765,7 +836,12 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncV4PagePaginationArray[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, @@ -788,8 +864,8 @@ async def delete( policy_id: str, *, app_id: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -823,6 +899,10 @@ async def delete( raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -836,7 +916,13 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + app_id=app_id, + policy_id=policy_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -852,8 +938,8 @@ async def get( policy_id: str, *, app_id: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -887,6 +973,10 @@ async def get( raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -900,7 +990,13 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + app_id=app_id, + policy_id=policy_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/applications/policy_tests/policy_tests.py b/src/cloudflare/resources/zero_trust/access/applications/policy_tests/policy_tests.py index 570d37005f9..79319458393 100755 --- a/src/cloudflare/resources/zero_trust/access/applications/policy_tests/policy_tests.py +++ b/src/cloudflare/resources/zero_trust/access/applications/policy_tests/policy_tests.py @@ -15,7 +15,7 @@ AsyncUsersResourceWithStreamingResponse, ) from ......_types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -60,7 +60,7 @@ def with_streaming_response(self) -> PolicyTestsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, policies: SequenceNotStr[policy_test_create_params.Policy] | 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. @@ -83,10 +83,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/policy-tests", + path_template("/accounts/{account_id}/access/policy-tests", account_id=account_id), body=maybe_transform({"policies": policies}, policy_test_create_params.PolicyTestCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -102,7 +104,7 @@ def get( self, policy_test_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -126,12 +128,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_test_id: raise ValueError(f"Expected a non-empty value for `policy_test_id` but received {policy_test_id!r}") return self._get( - f"/accounts/{account_id}/access/policy-tests/{policy_test_id}", + path_template( + "/accounts/{account_id}/access/policy-tests/{policy_test_id}", + account_id=account_id, + policy_test_id=policy_test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -170,7 +178,7 @@ def with_streaming_response(self) -> AsyncPolicyTestsResourceWithStreamingRespon async def create( self, *, - account_id: str, + account_id: str | None = None, policies: SequenceNotStr[policy_test_create_params.Policy] | 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. @@ -193,10 +201,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/policy-tests", + path_template("/accounts/{account_id}/access/policy-tests", account_id=account_id), body=await async_maybe_transform({"policies": policies}, policy_test_create_params.PolicyTestCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -212,7 +222,7 @@ async def get( self, policy_test_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -236,12 +246,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_test_id: raise ValueError(f"Expected a non-empty value for `policy_test_id` but received {policy_test_id!r}") return await self._get( - f"/accounts/{account_id}/access/policy-tests/{policy_test_id}", + path_template( + "/accounts/{account_id}/access/policy-tests/{policy_test_id}", + account_id=account_id, + policy_test_id=policy_test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/applications/policy_tests/users.py b/src/cloudflare/resources/zero_trust/access/applications/policy_tests/users.py index cc6cc310771..5d7941f44f3 100755 --- a/src/cloudflare/resources/zero_trust/access/applications/policy_tests/users.py +++ b/src/cloudflare/resources/zero_trust/access/applications/policy_tests/users.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -48,7 +48,7 @@ def list( self, policy_test_id: str, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, status: Literal["success", "fail", "error"] | Omit = omit, @@ -79,12 +79,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_test_id: raise ValueError(f"Expected a non-empty value for `policy_test_id` but received {policy_test_id!r}") return self._get_api_list( - f"/accounts/{account_id}/access/policy-tests/{policy_test_id}/users", + path_template( + "/accounts/{account_id}/access/policy-tests/{policy_test_id}/users", + account_id=account_id, + policy_test_id=policy_test_id, + ), page=SyncV4PagePaginationArray[UserListResponse], options=make_request_options( extra_headers=extra_headers, @@ -128,7 +134,7 @@ def list( self, policy_test_id: str, *, - account_id: str, + account_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, status: Literal["success", "fail", "error"] | Omit = omit, @@ -159,12 +165,18 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_test_id: raise ValueError(f"Expected a non-empty value for `policy_test_id` but received {policy_test_id!r}") return self._get_api_list( - f"/accounts/{account_id}/access/policy-tests/{policy_test_id}/users", + path_template( + "/accounts/{account_id}/access/policy-tests/{policy_test_id}/users", + account_id=account_id, + policy_test_id=policy_test_id, + ), page=AsyncV4PagePaginationArray[UserListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/access/applications/settings.py b/src/cloudflare/resources/zero_trust/access/applications/settings.py index d9e2f34f63d..c260d1ea15e 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/settings.py +++ b/src/cloudflare/resources/zero_trust/access/applications/settings.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -51,8 +51,8 @@ def update( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_iframe: bool | Omit = omit, skip_interstitial: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -86,6 +86,10 @@ def update( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -99,7 +103,12 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/settings", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/settings", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "allow_iframe": allow_iframe, @@ -121,8 +130,8 @@ def edit( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_iframe: bool | Omit = omit, skip_interstitial: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -156,6 +165,10 @@ def edit( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -169,7 +182,12 @@ def edit( account_or_zone = "zones" account_or_zone_id = zone_id return self._patch( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/settings", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/settings", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "allow_iframe": allow_iframe, @@ -212,8 +230,8 @@ async def update( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_iframe: bool | Omit = omit, skip_interstitial: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -247,6 +265,10 @@ async def update( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -260,7 +282,12 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/settings", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/settings", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "allow_iframe": allow_iframe, @@ -282,8 +309,8 @@ async def edit( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_iframe: bool | Omit = omit, skip_interstitial: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -317,6 +344,10 @@ async def edit( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -330,7 +361,12 @@ async def edit( account_or_zone = "zones" account_or_zone_id = zone_id return await self._patch( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/settings", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/settings", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "allow_iframe": allow_iframe, diff --git a/src/cloudflare/resources/zero_trust/access/applications/user_policy_checks.py b/src/cloudflare/resources/zero_trust/access/applications/user_policy_checks.py index ae499ccaa5a..47a90d689a4 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/user_policy_checks.py +++ b/src/cloudflare/resources/zero_trust/access/applications/user_policy_checks.py @@ -6,7 +6,8 @@ import httpx -from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,8 +49,8 @@ def list( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -77,6 +78,10 @@ def list( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -90,7 +95,12 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/user_policy_checks", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/user_policy_checks", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -126,8 +136,8 @@ async def list( self, app_id: AppID, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -155,6 +165,10 @@ async def list( """ if not app_id: raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -168,7 +182,12 @@ async def list( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/user_policy_checks", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/user_policy_checks", + app_id=app_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/bookmarks.py b/src/cloudflare/resources/zero_trust/access/bookmarks.py index 003b54c7fdb..d192969d6f4 100644 --- a/src/cloudflare/resources/zero_trust/access/bookmarks.py +++ b/src/cloudflare/resources/zero_trust/access/bookmarks.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def create( self, bookmark_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -75,12 +75,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bookmark_id: raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") return self._post( - f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + path_template( + "/accounts/{account_id}/access/bookmarks/{bookmark_id}", account_id=account_id, bookmark_id=bookmark_id + ), body=maybe_transform(body, bookmark_create_params.BookmarkCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -97,7 +101,7 @@ def update( self, bookmark_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -120,12 +124,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bookmark_id: raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") return self._put( - f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + path_template( + "/accounts/{account_id}/access/bookmarks/{bookmark_id}", account_id=account_id, bookmark_id=bookmark_id + ), body=maybe_transform(body, bookmark_update_params.BookmarkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -141,7 +149,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -161,10 +169,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/bookmarks", + path_template("/accounts/{account_id}/access/bookmarks", account_id=account_id), page=SyncSinglePage[Bookmark], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -177,7 +187,7 @@ def delete( self, bookmark_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -199,12 +209,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bookmark_id: raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") return self._delete( - f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + path_template( + "/accounts/{account_id}/access/bookmarks/{bookmark_id}", account_id=account_id, bookmark_id=bookmark_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -220,7 +234,7 @@ def get( self, bookmark_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -242,12 +256,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bookmark_id: raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") return self._get( - f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + path_template( + "/accounts/{account_id}/access/bookmarks/{bookmark_id}", account_id=account_id, bookmark_id=bookmark_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -284,7 +302,7 @@ async def create( self, bookmark_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -307,12 +325,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bookmark_id: raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") return await self._post( - f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + path_template( + "/accounts/{account_id}/access/bookmarks/{bookmark_id}", account_id=account_id, bookmark_id=bookmark_id + ), body=await async_maybe_transform(body, bookmark_create_params.BookmarkCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -329,7 +351,7 @@ async def update( self, bookmark_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -352,12 +374,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bookmark_id: raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") return await self._put( - f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + path_template( + "/accounts/{account_id}/access/bookmarks/{bookmark_id}", account_id=account_id, bookmark_id=bookmark_id + ), body=await async_maybe_transform(body, bookmark_update_params.BookmarkUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -373,7 +399,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -393,10 +419,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/bookmarks", + path_template("/accounts/{account_id}/access/bookmarks", account_id=account_id), page=AsyncSinglePage[Bookmark], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -409,7 +437,7 @@ async def delete( self, bookmark_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -431,12 +459,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bookmark_id: raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") return await self._delete( - f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + path_template( + "/accounts/{account_id}/access/bookmarks/{bookmark_id}", account_id=account_id, bookmark_id=bookmark_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -452,7 +484,7 @@ async def get( self, bookmark_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -474,12 +506,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not bookmark_id: raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") return await self._get( - f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + path_template( + "/accounts/{account_id}/access/bookmarks/{bookmark_id}", account_id=account_id, bookmark_id=bookmark_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/certificates/certificates.py b/src/cloudflare/resources/zero_trust/access/certificates/certificates.py index 7a366046139..4605c3f00e3 100644 --- a/src/cloudflare/resources/zero_trust/access/certificates/certificates.py +++ b/src/cloudflare/resources/zero_trust/access/certificates/certificates.py @@ -15,7 +15,7 @@ AsyncSettingsResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -64,8 +64,8 @@ def create( *, certificate: str, name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, associated_hostnames: SequenceNotStr[AssociatedHostnames] | 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. @@ -96,6 +96,10 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -109,7 +113,11 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "certificate": certificate, @@ -133,8 +141,8 @@ def update( certificate_id: str, *, associated_hostnames: SequenceNotStr[AssociatedHostnames], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -167,6 +175,10 @@ def update( """ if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -180,7 +192,12 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + certificate_id=certificate_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "associated_hostnames": associated_hostnames, @@ -201,8 +218,8 @@ def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -232,6 +249,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -245,7 +266,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncV4PagePaginationArray[Certificate], options=make_request_options( extra_headers=extra_headers, @@ -267,8 +292,8 @@ def delete( self, certificate_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -296,6 +321,10 @@ def delete( """ if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -309,7 +338,12 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + certificate_id=certificate_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -324,8 +358,8 @@ def get( self, certificate_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -353,6 +387,10 @@ def get( """ if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -366,7 +404,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + certificate_id=certificate_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -407,8 +450,8 @@ async def create( *, certificate: str, name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, associated_hostnames: SequenceNotStr[AssociatedHostnames] | 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. @@ -439,6 +482,10 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -452,7 +499,11 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "certificate": certificate, @@ -476,8 +527,8 @@ async def update( certificate_id: str, *, associated_hostnames: SequenceNotStr[AssociatedHostnames], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -510,6 +561,10 @@ async def update( """ if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -523,7 +578,12 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + certificate_id=certificate_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "associated_hostnames": associated_hostnames, @@ -544,8 +604,8 @@ async def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, 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. @@ -575,6 +635,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -588,7 +652,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncV4PagePaginationArray[Certificate], options=make_request_options( extra_headers=extra_headers, @@ -610,8 +678,8 @@ async def delete( self, certificate_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -639,6 +707,10 @@ async def delete( """ if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -652,7 +724,12 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + certificate_id=certificate_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -667,8 +744,8 @@ async def get( self, certificate_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -696,6 +773,10 @@ async def get( """ if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -709,7 +790,12 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + certificate_id=certificate_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/certificates/settings.py b/src/cloudflare/resources/zero_trust/access/certificates/settings.py index 6279f4cf55f..d67dc33ce7e 100644 --- a/src/cloudflare/resources/zero_trust/access/certificates/settings.py +++ b/src/cloudflare/resources/zero_trust/access/certificates/settings.py @@ -6,8 +6,8 @@ import httpx -from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -49,8 +49,8 @@ def update( self, *, settings: Iterable[CertificateSettingsParam], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -74,6 +74,10 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -87,7 +91,11 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/settings", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/settings", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncSinglePage[CertificateSettings], body=maybe_transform({"settings": settings}, setting_update_params.SettingUpdateParams), options=make_request_options( @@ -100,8 +108,8 @@ def update( def get( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -125,6 +133,10 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -138,7 +150,11 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/settings", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/settings", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncSinglePage[CertificateSettings], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -171,8 +187,8 @@ def update( self, *, settings: Iterable[CertificateSettingsParam], - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -196,6 +212,10 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -209,7 +229,11 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/settings", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/settings", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncSinglePage[CertificateSettings], body=maybe_transform({"settings": settings}, setting_update_params.SettingUpdateParams), options=make_request_options( @@ -222,8 +246,8 @@ def update( def get( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -247,6 +271,10 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -260,7 +288,11 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/settings", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/certificates/settings", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncSinglePage[CertificateSettings], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/access/custom_pages.py b/src/cloudflare/resources/zero_trust/access/custom_pages.py index a0221d88a29..139d8963bae 100644 --- a/src/cloudflare/resources/zero_trust/access/custom_pages.py +++ b/src/cloudflare/resources/zero_trust/access/custom_pages.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> CustomPagesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, custom_html: str, name: str, type: Literal["identity_denied", "forbidden"], @@ -82,10 +82,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/custom_pages", + path_template("/accounts/{account_id}/access/custom_pages", account_id=account_id), body=maybe_transform( { "custom_html": custom_html, @@ -108,7 +110,7 @@ def update( self, custom_page_id: str, *, - account_id: str, + account_id: str | None = None, custom_html: str, name: str, type: Literal["identity_denied", "forbidden"], @@ -141,12 +143,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not custom_page_id: raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") return self._put( - f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + path_template( + "/accounts/{account_id}/access/custom_pages/{custom_page_id}", + account_id=account_id, + custom_page_id=custom_page_id, + ), body=maybe_transform( { "custom_html": custom_html, @@ -168,7 +176,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -196,10 +204,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/custom_pages", + path_template("/accounts/{account_id}/access/custom_pages", account_id=account_id), page=SyncV4PagePaginationArray[CustomPageWithoutHTML], options=make_request_options( extra_headers=extra_headers, @@ -221,7 +231,7 @@ def delete( self, custom_page_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -245,12 +255,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not custom_page_id: raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") return self._delete( - f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + path_template( + "/accounts/{account_id}/access/custom_pages/{custom_page_id}", + account_id=account_id, + custom_page_id=custom_page_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -265,7 +281,7 @@ def get( self, custom_page_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -289,12 +305,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not custom_page_id: raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") return self._get( - f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + path_template( + "/accounts/{account_id}/access/custom_pages/{custom_page_id}", + account_id=account_id, + custom_page_id=custom_page_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -329,7 +351,7 @@ def with_streaming_response(self) -> AsyncCustomPagesResourceWithStreamingRespon async def create( self, *, - account_id: str, + account_id: str | None = None, custom_html: str, name: str, type: Literal["identity_denied", "forbidden"], @@ -360,10 +382,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/custom_pages", + path_template("/accounts/{account_id}/access/custom_pages", account_id=account_id), body=await async_maybe_transform( { "custom_html": custom_html, @@ -386,7 +410,7 @@ async def update( self, custom_page_id: str, *, - account_id: str, + account_id: str | None = None, custom_html: str, name: str, type: Literal["identity_denied", "forbidden"], @@ -419,12 +443,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not custom_page_id: raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") return await self._put( - f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + path_template( + "/accounts/{account_id}/access/custom_pages/{custom_page_id}", + account_id=account_id, + custom_page_id=custom_page_id, + ), body=await async_maybe_transform( { "custom_html": custom_html, @@ -446,7 +476,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -474,10 +504,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/custom_pages", + path_template("/accounts/{account_id}/access/custom_pages", account_id=account_id), page=AsyncV4PagePaginationArray[CustomPageWithoutHTML], options=make_request_options( extra_headers=extra_headers, @@ -499,7 +531,7 @@ async def delete( self, custom_page_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -523,12 +555,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not custom_page_id: raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") return await self._delete( - f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + path_template( + "/accounts/{account_id}/access/custom_pages/{custom_page_id}", + account_id=account_id, + custom_page_id=custom_page_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -543,7 +581,7 @@ async def get( self, custom_page_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -567,12 +605,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not custom_page_id: raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") return await self._get( - f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + path_template( + "/accounts/{account_id}/access/custom_pages/{custom_page_id}", + account_id=account_id, + custom_page_id=custom_page_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/gateway_ca.py b/src/cloudflare/resources/zero_trust/access/gateway_ca.py index ed2e6346595..559fff3c106 100644 --- a/src/cloudflare/resources/zero_trust/access/gateway_ca.py +++ b/src/cloudflare/resources/zero_trust/access/gateway_ca.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +49,7 @@ def with_streaming_response(self) -> GatewayCAResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -70,10 +71,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/gateway_ca", + path_template("/accounts/{account_id}/access/gateway_ca", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -87,7 +90,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -109,10 +112,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/gateway_ca", + path_template("/accounts/{account_id}/access/gateway_ca", account_id=account_id), page=SyncSinglePage[GatewayCAListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -124,7 +129,7 @@ def delete( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -148,12 +153,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._delete( - f"/accounts/{account_id}/access/gateway_ca/{certificate_id}", + path_template( + "/accounts/{account_id}/access/gateway_ca/{certificate_id}", + account_id=account_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -188,7 +199,7 @@ def with_streaming_response(self) -> AsyncGatewayCAResourceWithStreamingResponse async def create( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -210,10 +221,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/gateway_ca", + path_template("/accounts/{account_id}/access/gateway_ca", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -227,7 +240,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -249,10 +262,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/gateway_ca", + path_template("/accounts/{account_id}/access/gateway_ca", account_id=account_id), page=AsyncSinglePage[GatewayCAListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -264,7 +279,7 @@ async def delete( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -288,12 +303,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._delete( - f"/accounts/{account_id}/access/gateway_ca/{certificate_id}", + path_template( + "/accounts/{account_id}/access/gateway_ca/{certificate_id}", + account_id=account_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/groups.py b/src/cloudflare/resources/zero_trust/access/groups.py index c27dba939fb..48aac0f3c4b 100644 --- a/src/cloudflare/resources/zero_trust/access/groups.py +++ b/src/cloudflare/resources/zero_trust/access/groups.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -55,8 +55,8 @@ def create( *, include: Iterable[AccessRuleParam], name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, exclude: Iterable[AccessRuleParam] | Omit = omit, is_default: bool | Omit = omit, require: Iterable[AccessRuleParam] | Omit = omit, @@ -96,6 +96,10 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -109,7 +113,11 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/groups", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "include": include, @@ -136,8 +144,8 @@ def update( *, include: Iterable[AccessRuleParam], name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, exclude: Iterable[AccessRuleParam] | Omit = omit, is_default: bool | Omit = omit, require: Iterable[AccessRuleParam] | Omit = omit, @@ -181,6 +189,10 @@ def update( """ if not group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -194,7 +206,12 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + group_id=group_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "include": include, @@ -218,8 +235,8 @@ def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, name: str | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -255,6 +272,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -268,7 +289,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/groups", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncV4PagePaginationArray[GroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -292,8 +317,8 @@ def delete( self, group_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -321,6 +346,10 @@ def delete( """ if not group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -334,7 +363,12 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + group_id=group_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -349,8 +383,8 @@ def get( self, group_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -378,6 +412,10 @@ def get( """ if not group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -391,7 +429,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + group_id=group_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -428,8 +471,8 @@ async def create( *, include: Iterable[AccessRuleParam], name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, exclude: Iterable[AccessRuleParam] | Omit = omit, is_default: bool | Omit = omit, require: Iterable[AccessRuleParam] | Omit = omit, @@ -469,6 +512,10 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -482,7 +529,11 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/groups", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "include": include, @@ -509,8 +560,8 @@ async def update( *, include: Iterable[AccessRuleParam], name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, exclude: Iterable[AccessRuleParam] | Omit = omit, is_default: bool | Omit = omit, require: Iterable[AccessRuleParam] | Omit = omit, @@ -554,6 +605,10 @@ async def update( """ if not group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -567,7 +622,12 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + group_id=group_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "include": include, @@ -591,8 +651,8 @@ async def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, name: str | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -628,6 +688,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -641,7 +705,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/groups", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncV4PagePaginationArray[GroupListResponse], options=make_request_options( extra_headers=extra_headers, @@ -665,8 +733,8 @@ async def delete( self, group_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -694,6 +762,10 @@ async def delete( """ if not group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -707,7 +779,12 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + group_id=group_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -722,8 +799,8 @@ async def get( self, group_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -751,6 +828,10 @@ async def get( """ if not group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -764,7 +845,12 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + group_id=group_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/infrastructure/targets.py b/src/cloudflare/resources/zero_trust/access/infrastructure/targets.py index 79543f77c2f..71a82df1fc6 100644 --- a/src/cloudflare/resources/zero_trust/access/infrastructure/targets.py +++ b/src/cloudflare/resources/zero_trust/access/infrastructure/targets.py @@ -10,7 +10,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -61,7 +61,7 @@ def with_streaming_response(self) -> TargetsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, hostname: str, ip: target_create_params.IP, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -91,10 +91,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets", + path_template("/accounts/{account_id}/infrastructure/targets", account_id=account_id), body=maybe_transform( { "hostname": hostname, @@ -116,7 +118,7 @@ def update( self, target_id: str, *, - account_id: str, + account_id: str | None = None, hostname: str, ip: target_update_params.IP, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -148,12 +150,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") return self._put( - f"/accounts/{account_id}/infrastructure/targets/{target_id}", + path_template( + "/accounts/{account_id}/infrastructure/targets/{target_id}", account_id=account_id, target_id=target_id + ), body=maybe_transform( { "hostname": hostname, @@ -174,7 +180,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, created_after: Union[str, datetime, None] | Omit = omit, created_before: Union[str, datetime, None] | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, @@ -265,10 +271,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets", + path_template("/accounts/{account_id}/infrastructure/targets", account_id=account_id), page=SyncV4PagePaginationArray[TargetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -308,7 +316,7 @@ def delete( self, target_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -332,13 +340,17 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/infrastructure/targets/{target_id}", + path_template( + "/accounts/{account_id}/infrastructure/targets/{target_id}", account_id=account_id, target_id=target_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -349,7 +361,7 @@ def delete( def bulk_delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -371,11 +383,13 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets/batch", + path_template("/accounts/{account_id}/infrastructure/targets/batch", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -385,7 +399,7 @@ def bulk_delete( def bulk_delete_v2( self, *, - account_id: str, + account_id: str | None = None, target_ids: 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. @@ -410,11 +424,13 @@ def bulk_delete_v2( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets/batch_delete", + path_template("/accounts/{account_id}/infrastructure/targets/batch_delete", account_id=account_id), body=maybe_transform({"target_ids": target_ids}, target_bulk_delete_v2_params.TargetBulkDeleteV2Params), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -425,7 +441,7 @@ def bulk_delete_v2( def bulk_update( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[target_bulk_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. @@ -448,10 +464,12 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets/batch", + path_template("/accounts/{account_id}/infrastructure/targets/batch", account_id=account_id), page=SyncSinglePage[TargetBulkUpdateResponse], body=maybe_transform(body, Iterable[target_bulk_update_params.Body]), options=make_request_options( @@ -465,7 +483,7 @@ def get( self, target_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -489,12 +507,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") return self._get( - f"/accounts/{account_id}/infrastructure/targets/{target_id}", + path_template( + "/accounts/{account_id}/infrastructure/targets/{target_id}", account_id=account_id, target_id=target_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -529,7 +551,7 @@ def with_streaming_response(self) -> AsyncTargetsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, hostname: str, ip: target_create_params.IP, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -559,10 +581,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets", + path_template("/accounts/{account_id}/infrastructure/targets", account_id=account_id), body=await async_maybe_transform( { "hostname": hostname, @@ -584,7 +608,7 @@ async def update( self, target_id: str, *, - account_id: str, + account_id: str | None = None, hostname: str, ip: target_update_params.IP, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -616,12 +640,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") return await self._put( - f"/accounts/{account_id}/infrastructure/targets/{target_id}", + path_template( + "/accounts/{account_id}/infrastructure/targets/{target_id}", account_id=account_id, target_id=target_id + ), body=await async_maybe_transform( { "hostname": hostname, @@ -642,7 +670,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, created_after: Union[str, datetime, None] | Omit = omit, created_before: Union[str, datetime, None] | Omit = omit, direction: Literal["asc", "desc"] | Omit = omit, @@ -733,10 +761,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets", + path_template("/accounts/{account_id}/infrastructure/targets", account_id=account_id), page=AsyncV4PagePaginationArray[TargetListResponse], options=make_request_options( extra_headers=extra_headers, @@ -776,7 +806,7 @@ async def delete( self, target_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -800,13 +830,17 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/infrastructure/targets/{target_id}", + path_template( + "/accounts/{account_id}/infrastructure/targets/{target_id}", account_id=account_id, target_id=target_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -817,7 +851,7 @@ async def delete( async def bulk_delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -839,11 +873,13 @@ async def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets/batch", + path_template("/accounts/{account_id}/infrastructure/targets/batch", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -853,7 +889,7 @@ async def bulk_delete( async def bulk_delete_v2( self, *, - account_id: str, + account_id: str | None = None, target_ids: 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. @@ -878,11 +914,13 @@ async def bulk_delete_v2( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets/batch_delete", + path_template("/accounts/{account_id}/infrastructure/targets/batch_delete", account_id=account_id), body=await async_maybe_transform( {"target_ids": target_ids}, target_bulk_delete_v2_params.TargetBulkDeleteV2Params ), @@ -895,7 +933,7 @@ async def bulk_delete_v2( def bulk_update( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[target_bulk_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. @@ -918,10 +956,12 @@ def bulk_update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/infrastructure/targets/batch", + path_template("/accounts/{account_id}/infrastructure/targets/batch", account_id=account_id), page=AsyncSinglePage[TargetBulkUpdateResponse], body=maybe_transform(body, Iterable[target_bulk_update_params.Body]), options=make_request_options( @@ -935,7 +975,7 @@ async def get( self, target_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -959,12 +999,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not target_id: raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}") return await self._get( - f"/accounts/{account_id}/infrastructure/targets/{target_id}", + path_template( + "/accounts/{account_id}/infrastructure/targets/{target_id}", account_id=account_id, target_id=target_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/keys.py b/src/cloudflare/resources/zero_trust/access/keys.py index 075fc667f34..ea9cea5410a 100644 --- a/src/cloudflare/resources/zero_trust/access/keys.py +++ b/src/cloudflare/resources/zero_trust/access/keys.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> KeysResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, key_rotation_interval_days: 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. @@ -74,10 +74,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/keys", + path_template("/accounts/{account_id}/access/keys", account_id=account_id), body=maybe_transform( {"key_rotation_interval_days": key_rotation_interval_days}, key_update_params.KeyUpdateParams ), @@ -94,7 +96,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -116,10 +118,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/keys", + path_template("/accounts/{account_id}/access/keys", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -133,7 +137,7 @@ def get( def rotate( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -155,10 +159,12 @@ def rotate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/keys/rotate", + path_template("/accounts/{account_id}/access/keys/rotate", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -193,7 +199,7 @@ def with_streaming_response(self) -> AsyncKeysResourceWithStreamingResponse: async def update( self, *, - account_id: str, + account_id: str | None = None, key_rotation_interval_days: 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. @@ -218,10 +224,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/keys", + path_template("/accounts/{account_id}/access/keys", account_id=account_id), body=await async_maybe_transform( {"key_rotation_interval_days": key_rotation_interval_days}, key_update_params.KeyUpdateParams ), @@ -238,7 +246,7 @@ async def update( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -260,10 +268,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/keys", + path_template("/accounts/{account_id}/access/keys", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -277,7 +287,7 @@ async def get( async def rotate( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -299,10 +309,12 @@ async def rotate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/keys/rotate", + path_template("/accounts/{account_id}/access/keys/rotate", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/logs/access_requests.py b/src/cloudflare/resources/zero_trust/access/logs/access_requests.py index fefdd9c061f..f7de2d4a9f3 100644 --- a/src/cloudflare/resources/zero_trust/access/logs/access_requests.py +++ b/src/cloudflare/resources/zero_trust/access/logs/access_requests.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> AccessRequestsResourceWithStreamingResponse def list( self, *, - account_id: str, + account_id: str | None = None, allowed_op: Literal["eq", "neq"] | Omit = omit, app_type_op: Literal["eq", "neq"] | Omit = omit, app_uid_op: Literal["eq", "neq"] | Omit = omit, @@ -132,10 +132,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/logs/access_requests", + path_template("/accounts/{account_id}/access/logs/access_requests", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -194,7 +196,7 @@ def with_streaming_response(self) -> AsyncAccessRequestsResourceWithStreamingRes async def list( self, *, - account_id: str, + account_id: str | None = None, allowed_op: Literal["eq", "neq"] | Omit = omit, app_type_op: Literal["eq", "neq"] | Omit = omit, app_uid_op: Literal["eq", "neq"] | Omit = omit, @@ -277,10 +279,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/logs/access_requests", + path_template("/accounts/{account_id}/access/logs/access_requests", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/logs/scim/updates.py b/src/cloudflare/resources/zero_trust/access/logs/scim/updates.py index 73ae5fcc87f..a035f1a297d 100644 --- a/src/cloudflare/resources/zero_trust/access/logs/scim/updates.py +++ b/src/cloudflare/resources/zero_trust/access/logs/scim/updates.py @@ -9,7 +9,7 @@ import httpx from ......_types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> UpdatesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, idp_id: SequenceNotStr[str], cf_resource_id: str | Omit = omit, direction: Literal["desc", "asc"] | Omit = omit, @@ -115,10 +115,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/logs/scim/updates", + path_template("/accounts/{account_id}/access/logs/scim/updates", account_id=account_id), page=SyncV4PagePaginationArray[UpdateListResponse], options=make_request_options( extra_headers=extra_headers, @@ -172,7 +174,7 @@ def with_streaming_response(self) -> AsyncUpdatesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, idp_id: SequenceNotStr[str], cf_resource_id: str | Omit = omit, direction: Literal["desc", "asc"] | Omit = omit, @@ -238,10 +240,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/logs/scim/updates", + path_template("/accounts/{account_id}/access/logs/scim/updates", account_id=account_id), page=AsyncV4PagePaginationArray[UpdateListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/access/policies.py b/src/cloudflare/resources/zero_trust/access/policies.py index 691667fd3bc..258618f1081 100644 --- a/src/cloudflare/resources/zero_trust/access/policies.py +++ b/src/cloudflare/resources/zero_trust/access/policies.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -55,7 +55,7 @@ def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, decision: Decision, include: Iterable[AccessRuleParam], name: str, @@ -126,10 +126,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/policies", + path_template("/accounts/{account_id}/access/policies", account_id=account_id), body=maybe_transform( { "decision": decision, @@ -162,7 +164,7 @@ def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, decision: Decision, include: Iterable[AccessRuleParam], name: str, @@ -235,12 +237,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._put( - f"/accounts/{account_id}/access/policies/{policy_id}", + path_template( + "/accounts/{account_id}/access/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), body=maybe_transform( { "decision": decision, @@ -272,7 +278,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -300,10 +306,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/policies", + path_template("/accounts/{account_id}/access/policies", account_id=account_id), page=SyncV4PagePaginationArray[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, @@ -325,7 +333,7 @@ def delete( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -349,12 +357,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._delete( - f"/accounts/{account_id}/access/policies/{policy_id}", + path_template( + "/accounts/{account_id}/access/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -369,7 +381,7 @@ def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -393,12 +405,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get( - f"/accounts/{account_id}/access/policies/{policy_id}", + path_template( + "/accounts/{account_id}/access/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -433,7 +449,7 @@ def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, decision: Decision, include: Iterable[AccessRuleParam], name: str, @@ -504,10 +520,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/policies", + path_template("/accounts/{account_id}/access/policies", account_id=account_id), body=await async_maybe_transform( { "decision": decision, @@ -540,7 +558,7 @@ async def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, decision: Decision, include: Iterable[AccessRuleParam], name: str, @@ -613,12 +631,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._put( - f"/accounts/{account_id}/access/policies/{policy_id}", + path_template( + "/accounts/{account_id}/access/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), body=await async_maybe_transform( { "decision": decision, @@ -650,7 +672,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -678,10 +700,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/policies", + path_template("/accounts/{account_id}/access/policies", account_id=account_id), page=AsyncV4PagePaginationArray[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, @@ -703,7 +727,7 @@ async def delete( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -727,12 +751,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._delete( - f"/accounts/{account_id}/access/policies/{policy_id}", + path_template( + "/accounts/{account_id}/access/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -747,7 +775,7 @@ async def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -771,12 +799,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._get( - f"/accounts/{account_id}/access/policies/{policy_id}", + path_template( + "/accounts/{account_id}/access/policies/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/service_tokens.py b/src/cloudflare/resources/zero_trust/access/service_tokens.py index c08436ab5ab..9fce2e1d1a5 100644 --- a/src/cloudflare/resources/zero_trust/access/service_tokens.py +++ b/src/cloudflare/resources/zero_trust/access/service_tokens.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -57,8 +57,8 @@ def create( self, *, name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, client_secret_version: float | Omit = omit, duration: str | Omit = omit, previous_client_secret_expires_at: Union[str, datetime] | Omit = omit, @@ -104,6 +104,10 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -117,7 +121,11 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "name": name, @@ -141,8 +149,8 @@ def update( self, service_token_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, client_secret_version: float | Omit = omit, duration: str | Omit = omit, name: str | Omit = omit, @@ -190,6 +198,10 @@ def update( """ if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -203,7 +215,12 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + service_token_id=service_token_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "client_secret_version": client_secret_version, @@ -226,8 +243,8 @@ def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, name: str | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -263,6 +280,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -276,7 +297,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncV4PagePaginationArray[ServiceToken], options=make_request_options( extra_headers=extra_headers, @@ -300,8 +325,8 @@ def delete( self, service_token_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -329,6 +354,10 @@ def delete( """ if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -342,7 +371,12 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + service_token_id=service_token_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -357,8 +391,8 @@ def get( self, service_token_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -386,6 +420,10 @@ def get( """ if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -399,7 +437,12 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + service_token_id=service_token_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -414,7 +457,7 @@ def refresh( self, service_token_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -438,12 +481,18 @@ def refresh( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") return self._post( - f"/accounts/{account_id}/access/service_tokens/{service_token_id}/refresh", + path_template( + "/accounts/{account_id}/access/service_tokens/{service_token_id}/refresh", + account_id=account_id, + service_token_id=service_token_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -458,7 +507,7 @@ def rotate( self, service_token_id: str, *, - account_id: str, + account_id: str | None = None, previous_client_secret_expires_at: 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. @@ -486,12 +535,18 @@ def rotate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") return self._post( - f"/accounts/{account_id}/access/service_tokens/{service_token_id}/rotate", + path_template( + "/accounts/{account_id}/access/service_tokens/{service_token_id}/rotate", + account_id=account_id, + service_token_id=service_token_id, + ), body=maybe_transform( {"previous_client_secret_expires_at": previous_client_secret_expires_at}, service_token_rotate_params.ServiceTokenRotateParams, @@ -531,8 +586,8 @@ async def create( self, *, name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, client_secret_version: float | Omit = omit, duration: str | Omit = omit, previous_client_secret_expires_at: Union[str, datetime] | Omit = omit, @@ -578,6 +633,10 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -591,7 +650,11 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "name": name, @@ -615,8 +678,8 @@ async def update( self, service_token_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, client_secret_version: float | Omit = omit, duration: str | Omit = omit, name: str | Omit = omit, @@ -664,6 +727,10 @@ async def update( """ if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -677,7 +744,12 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + service_token_id=service_token_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "client_secret_version": client_secret_version, @@ -700,8 +772,8 @@ async def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, name: str | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, @@ -737,6 +809,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -750,7 +826,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncV4PagePaginationArray[ServiceToken], options=make_request_options( extra_headers=extra_headers, @@ -774,8 +854,8 @@ async def delete( self, service_token_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -803,6 +883,10 @@ async def delete( """ if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -816,7 +900,12 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + service_token_id=service_token_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -831,8 +920,8 @@ async def get( self, service_token_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -860,6 +949,10 @@ async def get( """ if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -873,7 +966,12 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + service_token_id=service_token_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -888,7 +986,7 @@ async def refresh( self, service_token_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -912,12 +1010,18 @@ async def refresh( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") return await self._post( - f"/accounts/{account_id}/access/service_tokens/{service_token_id}/refresh", + path_template( + "/accounts/{account_id}/access/service_tokens/{service_token_id}/refresh", + account_id=account_id, + service_token_id=service_token_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -932,7 +1036,7 @@ async def rotate( self, service_token_id: str, *, - account_id: str, + account_id: str | None = None, previous_client_secret_expires_at: 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. @@ -960,12 +1064,18 @@ async def rotate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not service_token_id: raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") return await self._post( - f"/accounts/{account_id}/access/service_tokens/{service_token_id}/rotate", + path_template( + "/accounts/{account_id}/access/service_tokens/{service_token_id}/rotate", + account_id=account_id, + service_token_id=service_token_id, + ), body=await async_maybe_transform( {"previous_client_secret_expires_at": previous_client_secret_expires_at}, service_token_rotate_params.ServiceTokenRotateParams, diff --git a/src/cloudflare/resources/zero_trust/access/tags.py b/src/cloudflare/resources/zero_trust/access/tags.py index 869d3e13bff..e7d0e9c83da 100644 --- a/src/cloudflare/resources/zero_trust/access/tags.py +++ b/src/cloudflare/resources/zero_trust/access/tags.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> TagsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -74,10 +74,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/tags", + path_template("/accounts/{account_id}/access/tags", account_id=account_id), body=maybe_transform({"name": name}, tag_create_params.TagCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -93,7 +95,7 @@ def update( self, tag_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -120,12 +122,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tag_name: raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") return self._put( - f"/accounts/{account_id}/access/tags/{tag_name}", + path_template("/accounts/{account_id}/access/tags/{tag_name}", account_id=account_id, tag_name=tag_name), body=maybe_transform({"name": name}, tag_update_params.TagUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -140,7 +144,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -168,10 +172,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/tags", + path_template("/accounts/{account_id}/access/tags", account_id=account_id), page=SyncV4PagePaginationArray[Tag], options=make_request_options( extra_headers=extra_headers, @@ -193,7 +199,7 @@ def delete( self, tag_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -217,12 +223,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tag_name: raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") return self._delete( - f"/accounts/{account_id}/access/tags/{tag_name}", + path_template("/accounts/{account_id}/access/tags/{tag_name}", account_id=account_id, tag_name=tag_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -237,7 +245,7 @@ def get( self, tag_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -261,12 +269,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tag_name: raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") return self._get( - f"/accounts/{account_id}/access/tags/{tag_name}", + path_template("/accounts/{account_id}/access/tags/{tag_name}", account_id=account_id, tag_name=tag_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -301,7 +311,7 @@ def with_streaming_response(self) -> AsyncTagsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -326,10 +336,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/tags", + path_template("/accounts/{account_id}/access/tags", account_id=account_id), body=await async_maybe_transform({"name": name}, tag_create_params.TagCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -345,7 +357,7 @@ async def update( self, tag_name: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -372,12 +384,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tag_name: raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") return await self._put( - f"/accounts/{account_id}/access/tags/{tag_name}", + path_template("/accounts/{account_id}/access/tags/{tag_name}", account_id=account_id, tag_name=tag_name), body=await async_maybe_transform({"name": name}, tag_update_params.TagUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -392,7 +406,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -420,10 +434,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/tags", + path_template("/accounts/{account_id}/access/tags", account_id=account_id), page=AsyncV4PagePaginationArray[Tag], options=make_request_options( extra_headers=extra_headers, @@ -445,7 +461,7 @@ async def delete( self, tag_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -469,12 +485,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tag_name: raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") return await self._delete( - f"/accounts/{account_id}/access/tags/{tag_name}", + path_template("/accounts/{account_id}/access/tags/{tag_name}", account_id=account_id, tag_name=tag_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -489,7 +507,7 @@ async def get( self, tag_name: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -513,12 +531,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tag_name: raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") return await self._get( - f"/accounts/{account_id}/access/tags/{tag_name}", + path_template("/accounts/{account_id}/access/tags/{tag_name}", account_id=account_id, tag_name=tag_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/users/active_sessions.py b/src/cloudflare/resources/zero_trust/access/users/active_sessions.py index fba9194b251..a01b95d37fb 100644 --- a/src/cloudflare/resources/zero_trust/access/users/active_sessions.py +++ b/src/cloudflare/resources/zero_trust/access/users/active_sessions.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,7 +49,7 @@ def list( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -72,12 +73,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._get_api_list( - f"/accounts/{account_id}/access/users/{user_id}/active_sessions", + path_template( + "/accounts/{account_id}/access/users/{user_id}/active_sessions", account_id=account_id, user_id=user_id + ), page=SyncSinglePage[ActiveSessionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -89,7 +94,7 @@ def get( self, nonce: str, *, - account_id: str, + account_id: str | None = None, user_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. @@ -114,6 +119,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: @@ -121,7 +128,12 @@ def get( if not nonce: raise ValueError(f"Expected a non-empty value for `nonce` but received {nonce!r}") return self._get( - f"/accounts/{account_id}/access/users/{user_id}/active_sessions/{nonce}", + path_template( + "/accounts/{account_id}/access/users/{user_id}/active_sessions/{nonce}", + account_id=account_id, + user_id=user_id, + nonce=nonce, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -157,7 +169,7 @@ def list( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -181,12 +193,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._get_api_list( - f"/accounts/{account_id}/access/users/{user_id}/active_sessions", + path_template( + "/accounts/{account_id}/access/users/{user_id}/active_sessions", account_id=account_id, user_id=user_id + ), page=AsyncSinglePage[ActiveSessionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -198,7 +214,7 @@ async def get( self, nonce: str, *, - account_id: str, + account_id: str | None = None, user_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. @@ -223,6 +239,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: @@ -230,7 +248,12 @@ async def get( if not nonce: raise ValueError(f"Expected a non-empty value for `nonce` but received {nonce!r}") return await self._get( - f"/accounts/{account_id}/access/users/{user_id}/active_sessions/{nonce}", + path_template( + "/accounts/{account_id}/access/users/{user_id}/active_sessions/{nonce}", + account_id=account_id, + user_id=user_id, + nonce=nonce, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/users/failed_logins.py b/src/cloudflare/resources/zero_trust/access/users/failed_logins.py index 34131b36ae4..c0bf624dceb 100644 --- a/src/cloudflare/resources/zero_trust/access/users/failed_logins.py +++ b/src/cloudflare/resources/zero_trust/access/users/failed_logins.py @@ -5,6 +5,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -44,7 +45,7 @@ def list( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,12 +69,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._get_api_list( - f"/accounts/{account_id}/access/users/{user_id}/failed_logins", + path_template( + "/accounts/{account_id}/access/users/{user_id}/failed_logins", account_id=account_id, user_id=user_id + ), page=SyncSinglePage[FailedLoginListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -106,7 +111,7 @@ def list( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -130,12 +135,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._get_api_list( - f"/accounts/{account_id}/access/users/{user_id}/failed_logins", + path_template( + "/accounts/{account_id}/access/users/{user_id}/failed_logins", account_id=account_id, user_id=user_id + ), page=AsyncSinglePage[FailedLoginListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py b/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py index 8ed147fdd5d..bfda21b721b 100644 --- a/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py +++ b/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def get( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -70,12 +71,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._get( - f"/accounts/{account_id}/access/users/{user_id}/last_seen_identity", + path_template( + "/accounts/{account_id}/access/users/{user_id}/last_seen_identity", + account_id=account_id, + user_id=user_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -111,7 +118,7 @@ async def get( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -135,12 +142,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return await self._get( - f"/accounts/{account_id}/access/users/{user_id}/last_seen_identity", + path_template( + "/accounts/{account_id}/access/users/{user_id}/last_seen_identity", + account_id=account_id, + user_id=user_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/access/users/users.py b/src/cloudflare/resources/zero_trust/access/users/users.py index 2a0b9cc6a98..3a0fd27d4ef 100644 --- a/src/cloudflare/resources/zero_trust/access/users/users.py +++ b/src/cloudflare/resources/zero_trust/access/users/users.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -87,7 +87,7 @@ def with_streaming_response(self) -> UsersResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, email: str, name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -115,10 +115,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/users", + path_template("/accounts/{account_id}/access/users", account_id=account_id), body=maybe_transform( { "email": email, @@ -140,7 +142,7 @@ def update( self, user_id: str, *, - account_id: str, + account_id: str | None = None, email: str, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -172,12 +174,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._put( - f"/accounts/{account_id}/access/users/{user_id}", + path_template("/accounts/{account_id}/access/users/{user_id}", account_id=account_id, user_id=user_id), body=maybe_transform( { "email": email, @@ -198,7 +202,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, email: str | Omit = omit, name: str | Omit = omit, page: int | Omit = omit, @@ -235,10 +239,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/users", + path_template("/accounts/{account_id}/access/users", account_id=account_id), page=SyncV4PagePaginationArray[UserListResponse], options=make_request_options( extra_headers=extra_headers, @@ -263,7 +269,7 @@ def delete( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -289,12 +295,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._delete( - f"/accounts/{account_id}/access/users/{user_id}", + path_template("/accounts/{account_id}/access/users/{user_id}", account_id=account_id, user_id=user_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -309,7 +317,7 @@ def get( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -333,12 +341,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._get( - f"/accounts/{account_id}/access/users/{user_id}", + path_template("/accounts/{account_id}/access/users/{user_id}", account_id=account_id, user_id=user_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -385,7 +395,7 @@ def with_streaming_response(self) -> AsyncUsersResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, email: str, name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -413,10 +423,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/users", + path_template("/accounts/{account_id}/access/users", account_id=account_id), body=await async_maybe_transform( { "email": email, @@ -438,7 +450,7 @@ async def update( self, user_id: str, *, - account_id: str, + account_id: str | None = None, email: str, name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -470,12 +482,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return await self._put( - f"/accounts/{account_id}/access/users/{user_id}", + path_template("/accounts/{account_id}/access/users/{user_id}", account_id=account_id, user_id=user_id), body=await async_maybe_transform( { "email": email, @@ -496,7 +510,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, email: str | Omit = omit, name: str | Omit = omit, page: int | Omit = omit, @@ -533,10 +547,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/users", + path_template("/accounts/{account_id}/access/users", account_id=account_id), page=AsyncV4PagePaginationArray[UserListResponse], options=make_request_options( extra_headers=extra_headers, @@ -561,7 +577,7 @@ async def delete( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -587,12 +603,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return await self._delete( - f"/accounts/{account_id}/access/users/{user_id}", + path_template("/accounts/{account_id}/access/users/{user_id}", account_id=account_id, user_id=user_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -607,7 +625,7 @@ async def get( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -631,12 +649,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return await self._get( - f"/accounts/{account_id}/access/users/{user_id}", + path_template("/accounts/{account_id}/access/users/{user_id}", account_id=account_id, user_id=user_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/api.md b/src/cloudflare/resources/zero_trust/api.md new file mode 100644 index 00000000000..cedf199e090 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/api.md @@ -0,0 +1,1964 @@ +# 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] + +### IPProfiles + +Types: + +```python +from cloudflare.types.zero_trust.devices import IPProfile, IPProfileDeleteResponse +``` + +Methods: + +- client.zero_trust.devices.ip_profiles.create(\*, account_id, \*\*params) -> IPProfile +- client.zero_trust.devices.ip_profiles.update(profile_id, \*, account_id, \*\*params) -> IPProfile +- client.zero_trust.devices.ip_profiles.list(\*, account_id, \*\*params) -> SyncSinglePage[IPProfile] +- client.zero_trust.devices.ip_profiles.delete(profile_id, \*, account_id) -> IPProfileDeleteResponse +- client.zero_trust.devices.ip_profiles.get(profile_id, \*, account_id) -> IPProfile + +### 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, + UserCreateResponse, + UserUpdateResponse, + UserListResponse, + UserGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.users.create(\*, account_id, \*\*params) -> Optional[UserCreateResponse] +- client.zero_trust.access.users.update(user_id, \*, account_id, \*\*params) -> Optional[UserUpdateResponse] +- client.zero_trust.access.users.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[UserListResponse] +- client.zero_trust.access.users.delete(user_id, \*, account_id) -> object +- client.zero_trust.access.users.get(user_id, \*, account_id) -> Optional[UserGetResponse] + +#### 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] + +### Rules + +Types: + +```python +from cloudflare.types.zero_trust.dex import ( + RuleCreateResponse, + RuleUpdateResponse, + RuleListResponse, + RuleDeleteResponse, + RuleGetResponse, +) +``` + +Methods: + +- client.zero_trust.dex.rules.create(\*, account_id, \*\*params) -> Optional[RuleCreateResponse] +- client.zero_trust.dex.rules.update(rule_id, \*, account_id, \*\*params) -> Optional[RuleUpdateResponse] +- client.zero_trust.dex.rules.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[RuleListResponse]] +- client.zero_trust.dex.rules.delete(rule_id, \*, account_id) -> Optional[RuleDeleteResponse] +- client.zero_trust.dex.rules.get(rule_id, \*, account_id) -> Optional[RuleGetResponse] + +## 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 + +#### Connections + +Types: + +```python +from cloudflare.types.zero_trust.tunnels.warp_connector import ConnectionGetResponse +``` + +Methods: + +- client.zero_trust.tunnels.warp_connector.connections.get(tunnel_id, \*, account_id) -> SyncSinglePage[ConnectionGetResponse] + +#### Connectors + +Types: + +```python +from cloudflare.types.zero_trust.tunnels.warp_connector import ConnectorGetResponse +``` + +Methods: + +- client.zero_trust.tunnels.warp_connector.connectors.get(connector_id, \*, account_id, tunnel_id) -> ConnectorGetResponse + +#### Failover + +Methods: + +- client.zero_trust.tunnels.warp_connector.failover.update(tunnel_id, \*, account_id, \*\*params) -> object + +## 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 +``` + +Methods: + +- client.zero_trust.dlp.datasets.create(\*, account_id, \*\*params) -> Optional[DatasetCreation] +- client.zero_trust.dlp.datasets.update(dataset_id, \*, account_id, \*\*params) -> Optional[Dataset] +- 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[Dataset] + +#### Upload + +Types: + +```python +from cloudflare.types.zero_trust.dlp.datasets import NewVersion +``` + +Methods: + +- client.zero_trust.dlp.datasets.upload.create(dataset_id, \*, account_id) -> Optional[NewVersion] +- client.zero_trust.dlp.datasets.upload.edit(version, dataset, \*, account_id, dataset_id, \*\*params) -> Optional[Dataset] + +#### 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] + +### Settings + +Types: + +```python +from cloudflare.types.zero_trust.dlp import DLPSettings +``` + +Methods: + +- client.zero_trust.dlp.settings.update(\*, account_id, \*\*params) -> Optional[DLPSettings] +- client.zero_trust.dlp.settings.delete(\*, account_id) -> Optional[DLPSettings] +- client.zero_trust.dlp.settings.edit(\*, account_id, \*\*params) -> Optional[DLPSettings] +- client.zero_trust.dlp.settings.get(\*, account_id) -> Optional[DLPSettings] + +### 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 +``` + +Methods: + +- client.zero_trust.dlp.profiles.list(\*, account_id, \*\*params) -> SyncSinglePage[Profile] +- client.zero_trust.dlp.profiles.get(profile_id, \*, account_id) -> Optional[Profile] + +#### Custom + +Types: + +```python +from cloudflare.types.zero_trust.dlp.profiles import CustomProfile, Pattern +``` + +Methods: + +- client.zero_trust.dlp.profiles.custom.create(\*, account_id, \*\*params) -> Optional[Profile] +- client.zero_trust.dlp.profiles.custom.update(profile_id, \*, account_id, \*\*params) -> Optional[Profile] +- client.zero_trust.dlp.profiles.custom.delete(profile_id, \*, account_id) -> object +- client.zero_trust.dlp.profiles.custom.get(profile_id, \*, account_id) -> Optional[Profile] + +#### Predefined + +Types: + +```python +from cloudflare.types.zero_trust.dlp.profiles import PredefinedProfile +``` + +Methods: + +- client.zero_trust.dlp.profiles.predefined.update(profile_id, \*, account_id, \*\*params) -> Optional[PredefinedProfile] +- client.zero_trust.dlp.profiles.predefined.delete(profile_id, \*, account_id) -> object +- client.zero_trust.dlp.profiles.predefined.get(profile_id, \*, account_id) -> Optional[PredefinedProfile] + +### 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] + +### Pacfiles + +Types: + +```python +from cloudflare.types.zero_trust.gateway import ( + PacfileCreateResponse, + PacfileUpdateResponse, + PacfileListResponse, + PacfileGetResponse, +) +``` + +Methods: + +- client.zero_trust.gateway.pacfiles.create(\*, account_id, \*\*params) -> Optional[PacfileCreateResponse] +- client.zero_trust.gateway.pacfiles.update(pacfile_id, \*, account_id, \*\*params) -> Optional[PacfileUpdateResponse] +- client.zero_trust.gateway.pacfiles.list(\*, account_id) -> SyncSinglePage[PacfileListResponse] +- client.zero_trust.gateway.pacfiles.delete(pacfile_id, \*, account_id) -> object +- client.zero_trust.gateway.pacfiles.get(pacfile_id, \*, account_id) -> Optional[PacfileGetResponse] + +## 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 + +Methods: + +- client.zero_trust.networks.subnets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Subnet] + +#### WARP + +Types: + +```python +from cloudflare.types.zero_trust.networks.subnets import Subnet, WARPDeleteResponse +``` + +Methods: + +- client.zero_trust.networks.subnets.warp.create(\*, account_id, \*\*params) -> Subnet +- client.zero_trust.networks.subnets.warp.delete(subnet_id, \*, account_id) -> Optional[WARPDeleteResponse] +- client.zero_trust.networks.subnets.warp.edit(subnet_id, \*, account_id, \*\*params) -> Subnet +- client.zero_trust.networks.subnets.warp.get(subnet_id, \*, account_id) -> Subnet + +#### CloudflareSource + +Methods: + +- client.zero_trust.networks.subnets.cloudflare_source.update(address_family, \*, account_id, \*\*params) -> Subnet + +### 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] diff --git a/src/cloudflare/resources/zero_trust/connectivity_settings.py b/src/cloudflare/resources/zero_trust/connectivity_settings.py index 5e91980161b..34a5b7840b1 100644 --- a/src/cloudflare/resources/zero_trust/connectivity_settings.py +++ b/src/cloudflare/resources/zero_trust/connectivity_settings.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> ConnectivitySettingsResourceWithStreamingRe def edit( self, *, - account_id: str, + account_id: str | None = None, icmp_proxy_enabled: bool | Omit = omit, offramp_warp_enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -76,10 +76,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/zerotrust/connectivity_settings", + path_template("/accounts/{account_id}/zerotrust/connectivity_settings", account_id=account_id), body=maybe_transform( { "icmp_proxy_enabled": icmp_proxy_enabled, @@ -100,7 +102,7 @@ def edit( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -122,10 +124,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/connectivity_settings", + path_template("/accounts/{account_id}/zerotrust/connectivity_settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -160,7 +164,7 @@ def with_streaming_response(self) -> AsyncConnectivitySettingsResourceWithStream async def edit( self, *, - account_id: str, + account_id: str | None = None, icmp_proxy_enabled: bool | Omit = omit, offramp_warp_enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -188,10 +192,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/zerotrust/connectivity_settings", + path_template("/accounts/{account_id}/zerotrust/connectivity_settings", account_id=account_id), body=await async_maybe_transform( { "icmp_proxy_enabled": icmp_proxy_enabled, @@ -212,7 +218,7 @@ async def edit( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -234,10 +240,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/connectivity_settings", + path_template("/accounts/{account_id}/zerotrust/connectivity_settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/devices.py b/src/cloudflare/resources/zero_trust/devices/devices.py index 0127c723960..16f8ddcf0a1 100644 --- a/src/cloudflare/resources/zero_trust/devices/devices.py +++ b/src/cloudflare/resources/zero_trust/devices/devices.py @@ -41,6 +41,7 @@ AsyncUnrevokeResourceWithStreamingResponse, ) from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from .dex_tests import ( DEXTestsResource, AsyncDEXTestsResource, @@ -198,7 +199,7 @@ def with_streaming_response(self) -> DevicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -226,10 +227,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices", + path_template("/accounts/{account_id}/devices", account_id=account_id), page=SyncSinglePage[Device], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -242,7 +245,7 @@ def get( self, device_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -273,12 +276,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return self._get( - f"/accounts/{account_id}/devices/{device_id}", + path_template("/accounts/{account_id}/devices/{device_id}", account_id=account_id, device_id=device_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -366,7 +371,7 @@ def with_streaming_response(self) -> AsyncDevicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -394,10 +399,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices", + path_template("/accounts/{account_id}/devices", account_id=account_id), page=AsyncSinglePage[Device], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -410,7 +417,7 @@ async def get( self, device_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -441,12 +448,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return await self._get( - f"/accounts/{account_id}/devices/{device_id}", + path_template("/accounts/{account_id}/devices/{device_id}", account_id=account_id, device_id=device_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/devices_.py b/src/cloudflare/resources/zero_trust/devices/devices_.py index 68ceefcdf58..a92df9b2c59 100644 --- a/src/cloudflare/resources/zero_trust/devices/devices_.py +++ b/src/cloudflare/resources/zero_trust/devices/devices_.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> DevicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, id: SequenceNotStr[str] | Omit = omit, active_registrations: Literal["include", "only", "exclude"] | Omit = omit, cursor: str | Omit = omit, @@ -110,10 +110,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/physical-devices", + path_template("/accounts/{account_id}/devices/physical-devices", account_id=account_id), page=SyncCursorPagination[DeviceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -144,7 +146,7 @@ def delete( self, device_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -164,12 +166,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return self._delete( - f"/accounts/{account_id}/devices/physical-devices/{device_id}", + path_template( + "/accounts/{account_id}/devices/physical-devices/{device_id}", + account_id=account_id, + device_id=device_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -184,7 +192,7 @@ def get( self, device_id: str, *, - account_id: str, + account_id: str | None = None, include: 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. @@ -208,12 +216,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return self._get( - f"/accounts/{account_id}/devices/physical-devices/{device_id}", + path_template( + "/accounts/{account_id}/devices/physical-devices/{device_id}", + account_id=account_id, + device_id=device_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,7 +243,7 @@ def revoke( self, device_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -249,12 +263,18 @@ def revoke( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return self._post( - f"/accounts/{account_id}/devices/physical-devices/{device_id}/revoke", + path_template( + "/accounts/{account_id}/devices/physical-devices/{device_id}/revoke", + account_id=account_id, + device_id=device_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -289,7 +309,7 @@ def with_streaming_response(self) -> AsyncDevicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, id: SequenceNotStr[str] | Omit = omit, active_registrations: Literal["include", "only", "exclude"] | Omit = omit, cursor: str | Omit = omit, @@ -349,10 +369,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/physical-devices", + path_template("/accounts/{account_id}/devices/physical-devices", account_id=account_id), page=AsyncCursorPagination[DeviceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -383,7 +405,7 @@ async def delete( self, device_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -403,12 +425,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return await self._delete( - f"/accounts/{account_id}/devices/physical-devices/{device_id}", + path_template( + "/accounts/{account_id}/devices/physical-devices/{device_id}", + account_id=account_id, + device_id=device_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -423,7 +451,7 @@ async def get( self, device_id: str, *, - account_id: str, + account_id: str | None = None, include: 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. @@ -447,12 +475,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return await self._get( - f"/accounts/{account_id}/devices/physical-devices/{device_id}", + path_template( + "/accounts/{account_id}/devices/physical-devices/{device_id}", + account_id=account_id, + device_id=device_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -468,7 +502,7 @@ async def revoke( self, device_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -488,12 +522,18 @@ async def revoke( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return await self._post( - f"/accounts/{account_id}/devices/physical-devices/{device_id}/revoke", + path_template( + "/accounts/{account_id}/devices/physical-devices/{device_id}/revoke", + account_id=account_id, + device_id=device_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/dex_tests.py b/src/cloudflare/resources/zero_trust/devices/dex_tests.py index a2d657bcbcb..a1709c3f528 100644 --- a/src/cloudflare/resources/zero_trust/devices/dex_tests.py +++ b/src/cloudflare/resources/zero_trust/devices/dex_tests.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> DEXTestsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, data: dex_test_create_params.Data, enabled: bool, interval: str, @@ -93,10 +93,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/devices/dex_tests", + path_template("/accounts/{account_id}/dex/devices/dex_tests", account_id=account_id), body=maybe_transform( { "data": data, @@ -123,7 +125,7 @@ def update( self, dex_test_id: str, *, - account_id: str, + account_id: str | None = None, data: dex_test_update_params.Data, enabled: bool, interval: str, @@ -165,12 +167,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dex_test_id: raise ValueError(f"Expected a non-empty value for `dex_test_id` but received {dex_test_id!r}") return self._put( - f"/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + path_template( + "/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + account_id=account_id, + dex_test_id=dex_test_id, + ), body=maybe_transform( { "data": data, @@ -196,7 +204,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, kind: Literal["http", "traceroute"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -228,10 +236,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/devices/dex_tests", + path_template("/accounts/{account_id}/dex/devices/dex_tests", account_id=account_id), page=SyncV4PagePaginationArray[DEXTestListResponse], options=make_request_options( extra_headers=extra_headers, @@ -255,7 +265,7 @@ def delete( self, dex_test_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -279,12 +289,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dex_test_id: raise ValueError(f"Expected a non-empty value for `dex_test_id` but received {dex_test_id!r}") return self._delete( - f"/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + path_template( + "/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + account_id=account_id, + dex_test_id=dex_test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -299,7 +315,7 @@ def get( self, dex_test_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -321,12 +337,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dex_test_id: raise ValueError(f"Expected a non-empty value for `dex_test_id` but received {dex_test_id!r}") return self._get( - f"/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + path_template( + "/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + account_id=account_id, + dex_test_id=dex_test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -361,7 +383,7 @@ def with_streaming_response(self) -> AsyncDEXTestsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, data: dex_test_create_params.Data, enabled: bool, interval: str, @@ -401,10 +423,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/devices/dex_tests", + path_template("/accounts/{account_id}/dex/devices/dex_tests", account_id=account_id), body=await async_maybe_transform( { "data": data, @@ -431,7 +455,7 @@ async def update( self, dex_test_id: str, *, - account_id: str, + account_id: str | None = None, data: dex_test_update_params.Data, enabled: bool, interval: str, @@ -473,12 +497,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dex_test_id: raise ValueError(f"Expected a non-empty value for `dex_test_id` but received {dex_test_id!r}") return await self._put( - f"/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + path_template( + "/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + account_id=account_id, + dex_test_id=dex_test_id, + ), body=await async_maybe_transform( { "data": data, @@ -504,7 +534,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, kind: Literal["http", "traceroute"] | Omit = omit, page: float | Omit = omit, per_page: float | Omit = omit, @@ -536,10 +566,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/devices/dex_tests", + path_template("/accounts/{account_id}/dex/devices/dex_tests", account_id=account_id), page=AsyncV4PagePaginationArray[DEXTestListResponse], options=make_request_options( extra_headers=extra_headers, @@ -563,7 +595,7 @@ async def delete( self, dex_test_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -587,12 +619,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dex_test_id: raise ValueError(f"Expected a non-empty value for `dex_test_id` but received {dex_test_id!r}") return await self._delete( - f"/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + path_template( + "/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + account_id=account_id, + dex_test_id=dex_test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -607,7 +645,7 @@ async def get( self, dex_test_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -629,12 +667,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dex_test_id: raise ValueError(f"Expected a non-empty value for `dex_test_id` but received {dex_test_id!r}") return await self._get( - f"/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + path_template( + "/accounts/{account_id}/dex/devices/dex_tests/{dex_test_id}", + account_id=account_id, + dex_test_id=dex_test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/fleet_status.py b/src/cloudflare/resources/zero_trust/devices/fleet_status.py index 993e9e1cb1b..e9cb4a8b7f1 100644 --- a/src/cloudflare/resources/zero_trust/devices/fleet_status.py +++ b/src/cloudflare/resources/zero_trust/devices/fleet_status.py @@ -5,7 +5,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +45,7 @@ def get( self, device_id: str, *, - account_id: str, + account_id: str | None = None, since_minutes: float, colo: str | Omit = omit, time_now: str | Omit = omit, @@ -77,12 +77,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return self._get( - f"/accounts/{account_id}/dex/devices/{device_id}/fleet-status/live", + path_template( + "/accounts/{account_id}/dex/devices/{device_id}/fleet-status/live", + account_id=account_id, + device_id=device_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -125,7 +131,7 @@ async def get( self, device_id: str, *, - account_id: str, + account_id: str | None = None, since_minutes: float, colo: str | Omit = omit, time_now: str | Omit = omit, @@ -157,12 +163,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return await self._get( - f"/accounts/{account_id}/dex/devices/{device_id}/fleet-status/live", + path_template( + "/accounts/{account_id}/dex/devices/{device_id}/fleet-status/live", + account_id=account_id, + device_id=device_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/ip_profiles.py b/src/cloudflare/resources/zero_trust/devices/ip_profiles.py index 413013cd2f0..d48e85f8da6 100644 --- a/src/cloudflare/resources/zero_trust/devices/ip_profiles.py +++ b/src/cloudflare/resources/zero_trust/devices/ip_profiles.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> IPProfilesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, match: str, name: str, precedence: int, @@ -94,10 +94,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/ip-profiles", + path_template("/accounts/{account_id}/devices/ip-profiles", account_id=account_id), body=maybe_transform( { "match": match, @@ -123,7 +125,7 @@ def update( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, enabled: bool | Omit = omit, match: str | Omit = omit, @@ -168,12 +170,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return self._patch( - f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + path_template( + "/accounts/{account_id}/devices/ip-profiles/{profile_id}", account_id=account_id, profile_id=profile_id + ), body=maybe_transform( { "description": description, @@ -198,7 +204,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -221,10 +227,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/ip-profiles", + path_template("/accounts/{account_id}/devices/ip-profiles", account_id=account_id), page=SyncSinglePage[IPProfile], options=make_request_options( extra_headers=extra_headers, @@ -240,7 +248,7 @@ def delete( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -260,12 +268,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return self._delete( - f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + path_template( + "/accounts/{account_id}/devices/ip-profiles/{profile_id}", account_id=account_id, profile_id=profile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -280,7 +292,7 @@ def get( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -300,12 +312,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return self._get( - f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + path_template( + "/accounts/{account_id}/devices/ip-profiles/{profile_id}", account_id=account_id, profile_id=profile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -340,7 +356,7 @@ def with_streaming_response(self) -> AsyncIPProfilesResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, match: str, name: str, precedence: int, @@ -385,10 +401,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/ip-profiles", + path_template("/accounts/{account_id}/devices/ip-profiles", account_id=account_id), body=await async_maybe_transform( { "match": match, @@ -414,7 +432,7 @@ async def update( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, enabled: bool | Omit = omit, match: str | Omit = omit, @@ -459,12 +477,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return await self._patch( - f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + path_template( + "/accounts/{account_id}/devices/ip-profiles/{profile_id}", account_id=account_id, profile_id=profile_id + ), body=await async_maybe_transform( { "description": description, @@ -489,7 +511,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, 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. @@ -512,10 +534,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/ip-profiles", + path_template("/accounts/{account_id}/devices/ip-profiles", account_id=account_id), page=AsyncSinglePage[IPProfile], options=make_request_options( extra_headers=extra_headers, @@ -531,7 +555,7 @@ async def delete( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -551,12 +575,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return await self._delete( - f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + path_template( + "/accounts/{account_id}/devices/ip-profiles/{profile_id}", account_id=account_id, profile_id=profile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -571,7 +599,7 @@ async def get( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -591,12 +619,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return await self._get( - f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + path_template( + "/accounts/{account_id}/devices/ip-profiles/{profile_id}", account_id=account_id, profile_id=profile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/networks.py b/src/cloudflare/resources/zero_trust/devices/networks.py index 51be71ecb74..045e278d08f 100644 --- a/src/cloudflare/resources/zero_trust/devices/networks.py +++ b/src/cloudflare/resources/zero_trust/devices/networks.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> NetworksResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, config: network_create_params.Config, name: str, type: Literal["tls"], @@ -79,10 +79,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/networks", + path_template("/accounts/{account_id}/devices/networks", account_id=account_id), body=maybe_transform( { "config": config, @@ -105,7 +107,7 @@ def update( self, network_id: str, *, - account_id: str, + account_id: str | None = None, config: network_update_params.Config | Omit = omit, name: str | Omit = omit, type: Literal["tls"] | Omit = omit, @@ -137,12 +139,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not network_id: raise ValueError(f"Expected a non-empty value for `network_id` but received {network_id!r}") return self._put( - f"/accounts/{account_id}/devices/networks/{network_id}", + path_template( + "/accounts/{account_id}/devices/networks/{network_id}", account_id=account_id, network_id=network_id + ), body=maybe_transform( { "config": config, @@ -164,7 +170,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -184,10 +190,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/networks", + path_template("/accounts/{account_id}/devices/networks", account_id=account_id), page=SyncSinglePage[DeviceNetwork], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -199,7 +207,7 @@ def delete( self, network_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -222,12 +230,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not network_id: raise ValueError(f"Expected a non-empty value for `network_id` but received {network_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/networks/{network_id}", + path_template( + "/accounts/{account_id}/devices/networks/{network_id}", account_id=account_id, network_id=network_id + ), page=SyncSinglePage[DeviceNetwork], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -240,7 +252,7 @@ def get( self, network_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -262,12 +274,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not network_id: raise ValueError(f"Expected a non-empty value for `network_id` but received {network_id!r}") return self._get( - f"/accounts/{account_id}/devices/networks/{network_id}", + path_template( + "/accounts/{account_id}/devices/networks/{network_id}", account_id=account_id, network_id=network_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -302,7 +318,7 @@ def with_streaming_response(self) -> AsyncNetworksResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, config: network_create_params.Config, name: str, type: Literal["tls"], @@ -332,10 +348,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/networks", + path_template("/accounts/{account_id}/devices/networks", account_id=account_id), body=await async_maybe_transform( { "config": config, @@ -358,7 +376,7 @@ async def update( self, network_id: str, *, - account_id: str, + account_id: str | None = None, config: network_update_params.Config | Omit = omit, name: str | Omit = omit, type: Literal["tls"] | Omit = omit, @@ -390,12 +408,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not network_id: raise ValueError(f"Expected a non-empty value for `network_id` but received {network_id!r}") return await self._put( - f"/accounts/{account_id}/devices/networks/{network_id}", + path_template( + "/accounts/{account_id}/devices/networks/{network_id}", account_id=account_id, network_id=network_id + ), body=await async_maybe_transform( { "config": config, @@ -417,7 +439,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -437,10 +459,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/networks", + path_template("/accounts/{account_id}/devices/networks", account_id=account_id), page=AsyncSinglePage[DeviceNetwork], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -452,7 +476,7 @@ def delete( self, network_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -475,12 +499,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not network_id: raise ValueError(f"Expected a non-empty value for `network_id` but received {network_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/networks/{network_id}", + path_template( + "/accounts/{account_id}/devices/networks/{network_id}", account_id=account_id, network_id=network_id + ), page=AsyncSinglePage[DeviceNetwork], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -493,7 +521,7 @@ async def get( self, network_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -515,12 +543,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not network_id: raise ValueError(f"Expected a non-empty value for `network_id` but received {network_id!r}") return await self._get( - f"/accounts/{account_id}/devices/networks/{network_id}", + path_template( + "/accounts/{account_id}/devices/networks/{network_id}", account_id=account_id, network_id=network_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/override_codes.py b/src/cloudflare/resources/zero_trust/devices/override_codes.py index 405cd081c63..0d3c2cf3dc3 100644 --- a/src/cloudflare/resources/zero_trust/devices/override_codes.py +++ b/src/cloudflare/resources/zero_trust/devices/override_codes.py @@ -8,6 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +50,7 @@ def list( self, device_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -79,12 +80,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/{device_id}/override_codes", + path_template( + "/accounts/{account_id}/devices/{device_id}/override_codes", account_id=account_id, device_id=device_id + ), page=SyncSinglePage[object], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -96,7 +101,7 @@ def get( self, registration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -118,12 +123,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not registration_id: raise ValueError(f"Expected a non-empty value for `registration_id` but received {registration_id!r}") return self._get( - f"/accounts/{account_id}/devices/registrations/{registration_id}/override_codes", + path_template( + "/accounts/{account_id}/devices/registrations/{registration_id}/override_codes", + account_id=account_id, + registration_id=registration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -160,7 +171,7 @@ def list( self, device_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -190,12 +201,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not device_id: raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/{device_id}/override_codes", + path_template( + "/accounts/{account_id}/devices/{device_id}/override_codes", account_id=account_id, device_id=device_id + ), page=AsyncSinglePage[object], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -207,7 +222,7 @@ async def get( self, registration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -229,12 +244,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not registration_id: raise ValueError(f"Expected a non-empty value for `registration_id` but received {registration_id!r}") return await self._get( - f"/accounts/{account_id}/devices/registrations/{registration_id}/override_codes", + path_template( + "/accounts/{account_id}/devices/registrations/{registration_id}/override_codes", + account_id=account_id, + registration_id=registration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/policies/custom/custom.py b/src/cloudflare/resources/zero_trust/devices/policies/custom/custom.py index 23dcd074d92..b55890e03cd 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/custom/custom.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/custom/custom.py @@ -23,7 +23,7 @@ AsyncIncludesResourceWithStreamingResponse, ) from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -86,7 +86,7 @@ def with_streaming_response(self) -> CustomResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, match: str, name: str, precedence: float, @@ -186,10 +186,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy", + path_template("/accounts/{account_id}/devices/policy", account_id=account_id), body=maybe_transform( { "match": match, @@ -230,7 +232,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -250,10 +252,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policies", + path_template("/accounts/{account_id}/devices/policies", account_id=account_id), page=SyncSinglePage[SettingsPolicy], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -265,7 +269,7 @@ def delete( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -286,12 +290,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}", account_id=account_id, policy_id=policy_id + ), page=SyncSinglePage[SettingsPolicy], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -304,7 +312,7 @@ def edit( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, allow_mode_switch: bool | Omit = omit, allow_updates: bool | Omit = omit, allowed_to_leave: bool | Omit = omit, @@ -403,12 +411,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._patch( - f"/accounts/{account_id}/devices/policy/{policy_id}", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}", account_id=account_id, policy_id=policy_id + ), body=maybe_transform( { "allow_mode_switch": allow_mode_switch, @@ -450,7 +462,7 @@ def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -470,12 +482,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get( - f"/accounts/{account_id}/devices/policy/{policy_id}", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -522,7 +538,7 @@ def with_streaming_response(self) -> AsyncCustomResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, match: str, name: str, precedence: float, @@ -622,10 +638,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy", + path_template("/accounts/{account_id}/devices/policy", account_id=account_id), body=await async_maybe_transform( { "match": match, @@ -666,7 +684,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -686,10 +704,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policies", + path_template("/accounts/{account_id}/devices/policies", account_id=account_id), page=AsyncSinglePage[SettingsPolicy], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -701,7 +721,7 @@ def delete( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -722,12 +742,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}", account_id=account_id, policy_id=policy_id + ), page=AsyncSinglePage[SettingsPolicy], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -740,7 +764,7 @@ async def edit( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, allow_mode_switch: bool | Omit = omit, allow_updates: bool | Omit = omit, allowed_to_leave: bool | Omit = omit, @@ -839,12 +863,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._patch( - f"/accounts/{account_id}/devices/policy/{policy_id}", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}", account_id=account_id, policy_id=policy_id + ), body=await async_maybe_transform( { "allow_mode_switch": allow_mode_switch, @@ -886,7 +914,7 @@ async def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -906,12 +934,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._get( - f"/accounts/{account_id}/devices/policy/{policy_id}", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}", account_id=account_id, policy_id=policy_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/policies/custom/excludes.py b/src/cloudflare/resources/zero_trust/devices/policies/custom/excludes.py index d9ad788b570..db0818778eb 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/custom/excludes.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/custom/excludes.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -48,7 +48,7 @@ def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[SplitTunnelExcludeParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -70,12 +70,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/exclude", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/exclude", account_id=account_id, policy_id=policy_id + ), page=SyncSinglePage[SplitTunnelExclude], body=maybe_transform(body, Iterable[SplitTunnelExcludeParam]), options=make_request_options( @@ -89,7 +93,7 @@ def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -110,12 +114,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/exclude", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/exclude", account_id=account_id, policy_id=policy_id + ), page=SyncSinglePage[SplitTunnelExclude], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -148,7 +156,7 @@ def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[SplitTunnelExcludeParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -170,12 +178,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/exclude", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/exclude", account_id=account_id, policy_id=policy_id + ), page=AsyncSinglePage[SplitTunnelExclude], body=maybe_transform(body, Iterable[SplitTunnelExcludeParam]), options=make_request_options( @@ -189,7 +201,7 @@ def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -210,12 +222,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/exclude", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/exclude", account_id=account_id, policy_id=policy_id + ), page=AsyncSinglePage[SplitTunnelExclude], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/devices/policies/custom/fallback_domains.py b/src/cloudflare/resources/zero_trust/devices/policies/custom/fallback_domains.py index 1cde309592c..66f19dd32f0 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/custom/fallback_domains.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/custom/fallback_domains.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -48,7 +48,7 @@ def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, domains: Iterable[FallbackDomainParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -72,12 +72,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/fallback_domains", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/fallback_domains", + account_id=account_id, + policy_id=policy_id, + ), page=SyncSinglePage[FallbackDomain], body=maybe_transform(domains, Iterable[FallbackDomainParam]), options=make_request_options( @@ -91,7 +97,7 @@ def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -113,12 +119,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/fallback_domains", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/fallback_domains", + account_id=account_id, + policy_id=policy_id, + ), page=SyncSinglePage[FallbackDomain], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -151,7 +163,7 @@ def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, domains: Iterable[FallbackDomainParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -175,12 +187,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/fallback_domains", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/fallback_domains", + account_id=account_id, + policy_id=policy_id, + ), page=AsyncSinglePage[FallbackDomain], body=maybe_transform(domains, Iterable[FallbackDomainParam]), options=make_request_options( @@ -194,7 +212,7 @@ def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -216,12 +234,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/fallback_domains", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/fallback_domains", + account_id=account_id, + policy_id=policy_id, + ), page=AsyncSinglePage[FallbackDomain], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/devices/policies/custom/includes.py b/src/cloudflare/resources/zero_trust/devices/policies/custom/includes.py index dff40cf931c..a0da203718b 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/custom/includes.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/custom/includes.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -48,7 +48,7 @@ def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[SplitTunnelIncludeParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -70,12 +70,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/include", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/include", account_id=account_id, policy_id=policy_id + ), page=SyncSinglePage[SplitTunnelInclude], body=maybe_transform(body, Iterable[SplitTunnelIncludeParam]), options=make_request_options( @@ -89,7 +93,7 @@ def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -110,12 +114,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/include", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/include", account_id=account_id, policy_id=policy_id + ), page=SyncSinglePage[SplitTunnelInclude], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -148,7 +156,7 @@ def update( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, body: Iterable[SplitTunnelIncludeParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -170,12 +178,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/include", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/include", account_id=account_id, policy_id=policy_id + ), page=AsyncSinglePage[SplitTunnelInclude], body=maybe_transform(body, Iterable[SplitTunnelIncludeParam]), options=make_request_options( @@ -189,7 +201,7 @@ def get( self, policy_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -210,12 +222,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get_api_list( - f"/accounts/{account_id}/devices/policy/{policy_id}/include", + path_template( + "/accounts/{account_id}/devices/policy/{policy_id}/include", account_id=account_id, policy_id=policy_id + ), page=AsyncSinglePage[SplitTunnelInclude], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/certificates.py b/src/cloudflare/resources/zero_trust/devices/policies/default/certificates.py index 1237c6a47bc..38c6429be44 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/default/certificates.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/certificates.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> CertificatesResourceWithStreamingResponse: def edit( self, *, - zone_id: str, + zone_id: str | None = None, enabled: 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. @@ -73,10 +73,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/devices/policy/certificates", + path_template("/zones/{zone_id}/devices/policy/certificates", zone_id=zone_id), body=maybe_transform({"enabled": enabled}, certificate_edit_params.CertificateEditParams), options=make_request_options( extra_headers=extra_headers, @@ -91,7 +93,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -111,10 +113,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/devices/policy/certificates", + path_template("/zones/{zone_id}/devices/policy/certificates", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -149,7 +153,7 @@ def with_streaming_response(self) -> AsyncCertificatesResourceWithStreamingRespo async def edit( self, *, - zone_id: str, + zone_id: str | None = None, enabled: 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. @@ -175,10 +179,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/devices/policy/certificates", + path_template("/zones/{zone_id}/devices/policy/certificates", zone_id=zone_id), body=await async_maybe_transform({"enabled": enabled}, certificate_edit_params.CertificateEditParams), options=make_request_options( extra_headers=extra_headers, @@ -193,7 +199,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -213,10 +219,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/devices/policy/certificates", + path_template("/zones/{zone_id}/devices/policy/certificates", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/default.py b/src/cloudflare/resources/zero_trust/devices/policies/default/default.py index 15d3c7fec8f..cdae21e89c0 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/default/default.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/default.py @@ -23,7 +23,7 @@ AsyncIncludesResourceWithStreamingResponse, ) from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ......_utils import maybe_transform, async_maybe_transform +from ......_utils import path_template, maybe_transform, async_maybe_transform from ......_compat import cached_property from .certificates import ( CertificatesResource, @@ -98,7 +98,7 @@ def with_streaming_response(self) -> DefaultResourceWithStreamingResponse: def edit( self, *, - account_id: str, + account_id: str | None = None, allow_mode_switch: bool | Omit = omit, allow_updates: bool | Omit = omit, allowed_to_leave: bool | Omit = omit, @@ -178,10 +178,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/devices/policy", + path_template("/accounts/{account_id}/devices/policy", account_id=account_id), body=maybe_transform( { "allow_mode_switch": allow_mode_switch, @@ -217,7 +219,7 @@ def edit( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -237,10 +239,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy", + path_template("/accounts/{account_id}/devices/policy", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -291,7 +295,7 @@ def with_streaming_response(self) -> AsyncDefaultResourceWithStreamingResponse: async def edit( self, *, - account_id: str, + account_id: str | None = None, allow_mode_switch: bool | Omit = omit, allow_updates: bool | Omit = omit, allowed_to_leave: bool | Omit = omit, @@ -371,10 +375,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/devices/policy", + path_template("/accounts/{account_id}/devices/policy", account_id=account_id), body=await async_maybe_transform( { "allow_mode_switch": allow_mode_switch, @@ -410,7 +416,7 @@ async def edit( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -430,10 +436,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy", + path_template("/accounts/{account_id}/devices/policy", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/excludes.py b/src/cloudflare/resources/zero_trust/devices/policies/default/excludes.py index 67461b4415a..2bbec11e3da 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/default/excludes.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/excludes.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> ExcludesResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[SplitTunnelExcludeParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -68,10 +68,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/exclude", + path_template("/accounts/{account_id}/devices/policy/exclude", account_id=account_id), page=SyncSinglePage[SplitTunnelExclude], body=maybe_transform(body, Iterable[SplitTunnelExcludeParam]), options=make_request_options( @@ -84,7 +86,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -104,10 +106,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/exclude", + path_template("/accounts/{account_id}/devices/policy/exclude", account_id=account_id), page=SyncSinglePage[SplitTunnelExclude], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -139,7 +143,7 @@ def with_streaming_response(self) -> AsyncExcludesResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[SplitTunnelExcludeParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -160,10 +164,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/exclude", + path_template("/accounts/{account_id}/devices/policy/exclude", account_id=account_id), page=AsyncSinglePage[SplitTunnelExclude], body=maybe_transform(body, Iterable[SplitTunnelExcludeParam]), options=make_request_options( @@ -176,7 +182,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -196,10 +202,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/exclude", + path_template("/accounts/{account_id}/devices/policy/exclude", account_id=account_id), page=AsyncSinglePage[SplitTunnelExclude], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/fallback_domains.py b/src/cloudflare/resources/zero_trust/devices/policies/default/fallback_domains.py index bb8d5f0c2a9..3d4b5dc2ef2 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/default/fallback_domains.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/fallback_domains.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> FallbackDomainsResourceWithStreamingRespons def update( self, *, - account_id: str, + account_id: str | None = None, domains: Iterable[FallbackDomainParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -70,10 +70,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/fallback_domains", + path_template("/accounts/{account_id}/devices/policy/fallback_domains", account_id=account_id), page=SyncSinglePage[FallbackDomain], body=maybe_transform(domains, Iterable[FallbackDomainParam]), options=make_request_options( @@ -86,7 +88,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -108,10 +110,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/fallback_domains", + path_template("/accounts/{account_id}/devices/policy/fallback_domains", account_id=account_id), page=SyncSinglePage[FallbackDomain], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -143,7 +147,7 @@ def with_streaming_response(self) -> AsyncFallbackDomainsResourceWithStreamingRe def update( self, *, - account_id: str, + account_id: str | None = None, domains: Iterable[FallbackDomainParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -166,10 +170,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/fallback_domains", + path_template("/accounts/{account_id}/devices/policy/fallback_domains", account_id=account_id), page=AsyncSinglePage[FallbackDomain], body=maybe_transform(domains, Iterable[FallbackDomainParam]), options=make_request_options( @@ -182,7 +188,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -204,10 +210,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/fallback_domains", + path_template("/accounts/{account_id}/devices/policy/fallback_domains", account_id=account_id), page=AsyncSinglePage[FallbackDomain], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/includes.py b/src/cloudflare/resources/zero_trust/devices/policies/default/includes.py index 1e0fcd34b8a..072652a7855 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/default/includes.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/includes.py @@ -7,7 +7,7 @@ import httpx from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> IncludesResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[SplitTunnelIncludeParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -68,10 +68,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/include", + path_template("/accounts/{account_id}/devices/policy/include", account_id=account_id), page=SyncSinglePage[SplitTunnelInclude], body=maybe_transform(body, Iterable[SplitTunnelIncludeParam]), options=make_request_options( @@ -84,7 +86,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -104,10 +106,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/include", + path_template("/accounts/{account_id}/devices/policy/include", account_id=account_id), page=SyncSinglePage[SplitTunnelInclude], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -139,7 +143,7 @@ def with_streaming_response(self) -> AsyncIncludesResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[SplitTunnelIncludeParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -160,10 +164,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/include", + path_template("/accounts/{account_id}/devices/policy/include", account_id=account_id), page=AsyncSinglePage[SplitTunnelInclude], body=maybe_transform(body, Iterable[SplitTunnelIncludeParam]), options=make_request_options( @@ -176,7 +182,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -196,10 +202,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/policy/include", + path_template("/accounts/{account_id}/devices/policy/include", account_id=account_id), page=AsyncSinglePage[SplitTunnelInclude], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/devices/posture/integrations.py b/src/cloudflare/resources/zero_trust/devices/posture/integrations.py index 233d4828cc0..9615f230fa8 100644 --- a/src/cloudflare/resources/zero_trust/devices/posture/integrations.py +++ b/src/cloudflare/resources/zero_trust/devices/posture/integrations.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> IntegrationsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, config: integration_create_params.Config, interval: str, name: str, @@ -92,10 +92,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/posture/integration", + path_template("/accounts/{account_id}/devices/posture/integration", account_id=account_id), body=maybe_transform( { "config": config, @@ -118,7 +120,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -138,10 +140,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/posture/integration", + path_template("/accounts/{account_id}/devices/posture/integration", account_id=account_id), page=SyncSinglePage[Integration], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -153,7 +157,7 @@ def delete( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -175,6 +179,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: @@ -182,7 +188,11 @@ def delete( return cast( Optional[IntegrationDeleteResponse], self._delete( - f"/accounts/{account_id}/devices/posture/integration/{integration_id}", + path_template( + "/accounts/{account_id}/devices/posture/integration/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -200,7 +210,7 @@ def edit( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, config: integration_edit_params.Config | Omit = omit, interval: str | Omit = omit, name: str | Omit = omit, @@ -245,12 +255,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return self._patch( - f"/accounts/{account_id}/devices/posture/integration/{integration_id}", + path_template( + "/accounts/{account_id}/devices/posture/integration/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), body=maybe_transform( { "config": config, @@ -274,7 +290,7 @@ def get( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -296,12 +312,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return self._get( - f"/accounts/{account_id}/devices/posture/integration/{integration_id}", + path_template( + "/accounts/{account_id}/devices/posture/integration/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -336,7 +358,7 @@ def with_streaming_response(self) -> AsyncIntegrationsResourceWithStreamingRespo async def create( self, *, - account_id: str, + account_id: str | None = None, config: integration_create_params.Config, interval: str, name: str, @@ -378,10 +400,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/posture/integration", + path_template("/accounts/{account_id}/devices/posture/integration", account_id=account_id), body=await async_maybe_transform( { "config": config, @@ -404,7 +428,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -424,10 +448,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/posture/integration", + path_template("/accounts/{account_id}/devices/posture/integration", account_id=account_id), page=AsyncSinglePage[Integration], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -439,7 +465,7 @@ async def delete( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -461,6 +487,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: @@ -468,7 +496,11 @@ async def delete( return cast( Optional[IntegrationDeleteResponse], await self._delete( - f"/accounts/{account_id}/devices/posture/integration/{integration_id}", + path_template( + "/accounts/{account_id}/devices/posture/integration/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -486,7 +518,7 @@ async def edit( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, config: integration_edit_params.Config | Omit = omit, interval: str | Omit = omit, name: str | Omit = omit, @@ -531,12 +563,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return await self._patch( - f"/accounts/{account_id}/devices/posture/integration/{integration_id}", + path_template( + "/accounts/{account_id}/devices/posture/integration/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), body=await async_maybe_transform( { "config": config, @@ -560,7 +598,7 @@ async def get( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -582,12 +620,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return await self._get( - f"/accounts/{account_id}/devices/posture/integration/{integration_id}", + path_template( + "/accounts/{account_id}/devices/posture/integration/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/posture/posture.py b/src/cloudflare/resources/zero_trust/devices/posture/posture.py index 4f6a0894c86..ab2f7d6cb81 100644 --- a/src/cloudflare/resources/zero_trust/devices/posture/posture.py +++ b/src/cloudflare/resources/zero_trust/devices/posture/posture.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from .integrations import ( IntegrationsResource, @@ -64,7 +64,7 @@ def with_streaming_response(self) -> PostureResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, type: Literal[ "file", @@ -131,10 +131,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/posture", + path_template("/accounts/{account_id}/devices/posture", account_id=account_id), body=maybe_transform( { "name": name, @@ -161,7 +163,7 @@ def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, name: str, type: Literal[ "file", @@ -230,12 +232,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._put( - f"/accounts/{account_id}/devices/posture/{rule_id}", + path_template("/accounts/{account_id}/devices/posture/{rule_id}", account_id=account_id, rule_id=rule_id), body=maybe_transform( { "name": name, @@ -261,7 +265,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -281,10 +285,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/posture", + path_template("/accounts/{account_id}/devices/posture", account_id=account_id), page=SyncSinglePage[DevicePostureRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -296,7 +302,7 @@ def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -318,12 +324,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._delete( - f"/accounts/{account_id}/devices/posture/{rule_id}", + path_template("/accounts/{account_id}/devices/posture/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -338,7 +346,7 @@ def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -360,12 +368,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get( - f"/accounts/{account_id}/devices/posture/{rule_id}", + path_template("/accounts/{account_id}/devices/posture/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -404,7 +414,7 @@ def with_streaming_response(self) -> AsyncPostureResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, type: Literal[ "file", @@ -471,10 +481,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/posture", + path_template("/accounts/{account_id}/devices/posture", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -501,7 +513,7 @@ async def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, name: str, type: Literal[ "file", @@ -570,12 +582,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._put( - f"/accounts/{account_id}/devices/posture/{rule_id}", + path_template("/accounts/{account_id}/devices/posture/{rule_id}", account_id=account_id, rule_id=rule_id), body=await async_maybe_transform( { "name": name, @@ -601,7 +615,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -621,10 +635,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/posture", + path_template("/accounts/{account_id}/devices/posture", account_id=account_id), page=AsyncSinglePage[DevicePostureRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -636,7 +652,7 @@ async def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -658,12 +674,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._delete( - f"/accounts/{account_id}/devices/posture/{rule_id}", + path_template("/accounts/{account_id}/devices/posture/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -678,7 +696,7 @@ async def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -700,12 +718,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._get( - f"/accounts/{account_id}/devices/posture/{rule_id}", + path_template("/accounts/{account_id}/devices/posture/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/registrations.py b/src/cloudflare/resources/zero_trust/devices/registrations.py index c1a7c477403..2e6bfed5c19 100644 --- a/src/cloudflare/resources/zero_trust/devices/registrations.py +++ b/src/cloudflare/resources/zero_trust/devices/registrations.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -56,7 +56,7 @@ def with_streaming_response(self) -> RegistrationsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, id: SequenceNotStr[str] | Omit = omit, cursor: str | Omit = omit, device: registration_list_params.Device | Omit = omit, @@ -113,10 +113,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/registrations", + path_template("/accounts/{account_id}/devices/registrations", account_id=account_id), page=SyncCursorPagination[RegistrationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -148,7 +150,7 @@ def delete( self, registration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -168,12 +170,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not registration_id: raise ValueError(f"Expected a non-empty value for `registration_id` but received {registration_id!r}") return self._delete( - f"/accounts/{account_id}/devices/registrations/{registration_id}", + path_template( + "/accounts/{account_id}/devices/registrations/{registration_id}", + account_id=account_id, + registration_id=registration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -187,7 +195,7 @@ def delete( def bulk_delete( self, *, - account_id: str, + account_id: str | None = None, id: 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. @@ -210,10 +218,12 @@ def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/registrations", + path_template("/accounts/{account_id}/devices/registrations", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,7 +239,7 @@ def get( self, registration_id: str, *, - account_id: str, + account_id: str | None = None, include: 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. @@ -253,12 +263,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not registration_id: raise ValueError(f"Expected a non-empty value for `registration_id` but received {registration_id!r}") return self._get( - f"/accounts/{account_id}/devices/registrations/{registration_id}", + path_template( + "/accounts/{account_id}/devices/registrations/{registration_id}", + account_id=account_id, + registration_id=registration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -273,7 +289,7 @@ def get( def revoke( self, *, - account_id: str, + account_id: str | None = None, id: 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. @@ -296,10 +312,12 @@ def revoke( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/registrations/revoke", + path_template("/accounts/{account_id}/devices/registrations/revoke", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -314,7 +332,7 @@ def revoke( def unrevoke( self, *, - account_id: str, + account_id: str | None = None, id: 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. @@ -337,10 +355,12 @@ def unrevoke( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/registrations/unrevoke", + path_template("/accounts/{account_id}/devices/registrations/unrevoke", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -376,7 +396,7 @@ def with_streaming_response(self) -> AsyncRegistrationsResourceWithStreamingResp def list( self, *, - account_id: str, + account_id: str | None = None, id: SequenceNotStr[str] | Omit = omit, cursor: str | Omit = omit, device: registration_list_params.Device | Omit = omit, @@ -433,10 +453,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/registrations", + path_template("/accounts/{account_id}/devices/registrations", account_id=account_id), page=AsyncCursorPagination[RegistrationListResponse], options=make_request_options( extra_headers=extra_headers, @@ -468,7 +490,7 @@ async def delete( self, registration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -488,12 +510,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not registration_id: raise ValueError(f"Expected a non-empty value for `registration_id` but received {registration_id!r}") return await self._delete( - f"/accounts/{account_id}/devices/registrations/{registration_id}", + path_template( + "/accounts/{account_id}/devices/registrations/{registration_id}", + account_id=account_id, + registration_id=registration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -507,7 +535,7 @@ async def delete( async def bulk_delete( self, *, - account_id: str, + account_id: str | None = None, id: 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. @@ -530,10 +558,12 @@ async def bulk_delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/registrations", + path_template("/accounts/{account_id}/devices/registrations", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -551,7 +581,7 @@ async def get( self, registration_id: str, *, - account_id: str, + account_id: str | None = None, include: 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. @@ -575,12 +605,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not registration_id: raise ValueError(f"Expected a non-empty value for `registration_id` but received {registration_id!r}") return await self._get( - f"/accounts/{account_id}/devices/registrations/{registration_id}", + path_template( + "/accounts/{account_id}/devices/registrations/{registration_id}", + account_id=account_id, + registration_id=registration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -595,7 +631,7 @@ async def get( async def revoke( self, *, - account_id: str, + account_id: str | None = None, id: 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. @@ -618,10 +654,12 @@ async def revoke( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/registrations/revoke", + path_template("/accounts/{account_id}/devices/registrations/revoke", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -636,7 +674,7 @@ async def revoke( async def unrevoke( self, *, - account_id: str, + account_id: str | None = None, id: 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. @@ -659,10 +697,12 @@ async def unrevoke( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/registrations/unrevoke", + path_template("/accounts/{account_id}/devices/registrations/unrevoke", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/resilience/global_warp_override.py b/src/cloudflare/resources/zero_trust/devices/resilience/global_warp_override.py index 33f8cf8650e..a686a99a1d4 100644 --- a/src/cloudflare/resources/zero_trust/devices/resilience/global_warp_override.py +++ b/src/cloudflare/resources/zero_trust/devices/resilience/global_warp_override.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -50,7 +50,7 @@ def with_streaming_response(self) -> GlobalWARPOverrideResourceWithStreamingResp def create( self, *, - account_id: str, + account_id: str | None = None, disconnect: bool, justification: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -77,10 +77,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/resilience/disconnect", + path_template("/accounts/{account_id}/devices/resilience/disconnect", account_id=account_id), body=maybe_transform( { "disconnect": disconnect, @@ -103,7 +105,7 @@ def create( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,10 +125,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/resilience/disconnect", + path_template("/accounts/{account_id}/devices/resilience/disconnect", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -161,7 +165,7 @@ def with_streaming_response(self) -> AsyncGlobalWARPOverrideResourceWithStreamin async def create( self, *, - account_id: str, + account_id: str | None = None, disconnect: bool, justification: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -188,10 +192,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/resilience/disconnect", + path_template("/accounts/{account_id}/devices/resilience/disconnect", account_id=account_id), body=await async_maybe_transform( { "disconnect": disconnect, @@ -214,7 +220,7 @@ async def create( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -234,10 +240,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/resilience/disconnect", + path_template("/accounts/{account_id}/devices/resilience/disconnect", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/revoke.py b/src/cloudflare/resources/zero_trust/devices/revoke.py index b1fc0267ac5..7b29dee00b3 100644 --- a/src/cloudflare/resources/zero_trust/devices/revoke.py +++ b/src/cloudflare/resources/zero_trust/devices/revoke.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> RevokeResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -77,12 +77,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[RevokeCreateResponse], self._post( - f"/accounts/{account_id}/devices/revoke", + path_template("/accounts/{account_id}/devices/revoke", account_id=account_id), body=maybe_transform(body, SequenceNotStr[str]), options=make_request_options( extra_headers=extra_headers, @@ -122,7 +124,7 @@ def with_streaming_response(self) -> AsyncRevokeResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -151,12 +153,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[RevokeCreateResponse], await self._post( - f"/accounts/{account_id}/devices/revoke", + path_template("/accounts/{account_id}/devices/revoke", account_id=account_id), body=await async_maybe_transform(body, SequenceNotStr[str]), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/devices/settings.py b/src/cloudflare/resources/zero_trust/devices/settings.py index 9b745ab93e6..9484eea885d 100644 --- a/src/cloudflare/resources/zero_trust/devices/settings.py +++ b/src/cloudflare/resources/zero_trust/devices/settings.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, disable_for_time: float | Omit = omit, external_emergency_signal_enabled: bool | Omit = omit, external_emergency_signal_fingerprint: str | Omit = omit, @@ -101,10 +101,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/settings", + path_template("/accounts/{account_id}/devices/settings", account_id=account_id), body=maybe_transform( { "disable_for_time": disable_for_time, @@ -132,7 +134,7 @@ def update( def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -152,10 +154,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/settings", + path_template("/accounts/{account_id}/devices/settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -169,7 +173,7 @@ def delete( def edit( self, *, - account_id: str, + account_id: str | None = None, disable_for_time: float | Omit = omit, external_emergency_signal_enabled: bool | Omit = omit, external_emergency_signal_fingerprint: str | Omit = omit, @@ -223,10 +227,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/devices/settings", + path_template("/accounts/{account_id}/devices/settings", account_id=account_id), body=maybe_transform( { "disable_for_time": disable_for_time, @@ -254,7 +260,7 @@ def edit( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -274,10 +280,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/settings", + path_template("/accounts/{account_id}/devices/settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -312,7 +320,7 @@ def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: async def update( self, *, - account_id: str, + account_id: str | None = None, disable_for_time: float | Omit = omit, external_emergency_signal_enabled: bool | Omit = omit, external_emergency_signal_fingerprint: str | Omit = omit, @@ -366,10 +374,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/settings", + path_template("/accounts/{account_id}/devices/settings", account_id=account_id), body=await async_maybe_transform( { "disable_for_time": disable_for_time, @@ -397,7 +407,7 @@ async def update( async def delete( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -417,10 +427,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/settings", + path_template("/accounts/{account_id}/devices/settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -434,7 +446,7 @@ async def delete( async def edit( self, *, - account_id: str, + account_id: str | None = None, disable_for_time: float | Omit = omit, external_emergency_signal_enabled: bool | Omit = omit, external_emergency_signal_fingerprint: str | Omit = omit, @@ -488,10 +500,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/devices/settings", + path_template("/accounts/{account_id}/devices/settings", account_id=account_id), body=await async_maybe_transform( { "disable_for_time": disable_for_time, @@ -519,7 +533,7 @@ async def edit( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -539,10 +553,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/devices/settings", + path_template("/accounts/{account_id}/devices/settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/devices/unrevoke.py b/src/cloudflare/resources/zero_trust/devices/unrevoke.py index c2763bff599..ea114c46602 100644 --- a/src/cloudflare/resources/zero_trust/devices/unrevoke.py +++ b/src/cloudflare/resources/zero_trust/devices/unrevoke.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> UnrevokeResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -77,12 +77,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[UnrevokeCreateResponse], self._post( - f"/accounts/{account_id}/devices/unrevoke", + path_template("/accounts/{account_id}/devices/unrevoke", account_id=account_id), body=maybe_transform(body, SequenceNotStr[str]), options=make_request_options( extra_headers=extra_headers, @@ -122,7 +124,7 @@ def with_streaming_response(self) -> AsyncUnrevokeResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, body: 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. @@ -151,12 +153,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[UnrevokeCreateResponse], await self._post( - f"/accounts/{account_id}/devices/unrevoke", + path_template("/accounts/{account_id}/devices/unrevoke", account_id=account_id), body=await async_maybe_transform(body, SequenceNotStr[str]), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/dex/colos.py b/src/cloudflare/resources/zero_trust/dex/colos.py index b7040e0eabb..7782a35ff01 100644 --- a/src/cloudflare/resources/zero_trust/dex/colos.py +++ b/src/cloudflare/resources/zero_trust/dex/colos.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> ColosResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, from_: str, to: str, sort_by: Literal["fleet-status-usage", "application-tests-usage"] | Omit = omit, @@ -79,10 +79,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/colos", + path_template("/accounts/{account_id}/dex/colos", account_id=account_id), page=SyncSinglePage[ColoListResponse], options=make_request_options( extra_headers=extra_headers, @@ -125,7 +127,7 @@ def with_streaming_response(self) -> AsyncColosResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, from_: str, to: str, sort_by: Literal["fleet-status-usage", "application-tests-usage"] | Omit = omit, @@ -157,10 +159,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/colos", + path_template("/accounts/{account_id}/dex/colos", account_id=account_id), page=AsyncSinglePage[ColoListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/dex/commands/commands.py b/src/cloudflare/resources/zero_trust/dex/commands/commands.py index 67a335103cc..cda34c55732 100644 --- a/src/cloudflare/resources/zero_trust/dex/commands/commands.py +++ b/src/cloudflare/resources/zero_trust/dex/commands/commands.py @@ -33,7 +33,7 @@ AsyncDownloadsResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -87,7 +87,7 @@ def with_streaming_response(self) -> CommandsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, commands: Iterable[command_create_params.Command], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -110,10 +110,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/commands", + path_template("/accounts/{account_id}/dex/commands", account_id=account_id), body=maybe_transform({"commands": commands}, command_create_params.CommandCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -128,7 +130,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, page: float, per_page: float, command_type: str | Omit = omit, @@ -173,10 +175,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/commands", + path_template("/accounts/{account_id}/dex/commands", account_id=account_id), page=SyncV4PagePagination[Optional[CommandListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -236,7 +240,7 @@ def with_streaming_response(self) -> AsyncCommandsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, commands: Iterable[command_create_params.Command], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -259,10 +263,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/commands", + path_template("/accounts/{account_id}/dex/commands", account_id=account_id), body=await async_maybe_transform({"commands": commands}, command_create_params.CommandCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -277,7 +283,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, page: float, per_page: float, command_type: str | Omit = omit, @@ -322,10 +328,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/commands", + path_template("/accounts/{account_id}/dex/commands", account_id=account_id), page=AsyncV4PagePagination[Optional[CommandListResponse]], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/dex/commands/devices.py b/src/cloudflare/resources/zero_trust/dex/commands/devices.py index f48131bf7ee..1f9e7b84f6c 100644 --- a/src/cloudflare/resources/zero_trust/dex/commands/devices.py +++ b/src/cloudflare/resources/zero_trust/dex/commands/devices.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> DevicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, page: float, per_page: float, search: str | Omit = omit, @@ -77,10 +77,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/commands/devices", + path_template("/accounts/{account_id}/dex/commands/devices", account_id=account_id), page=SyncV4PagePagination[Optional[DeviceListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -123,7 +125,7 @@ def with_streaming_response(self) -> AsyncDevicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, page: float, per_page: float, search: str | Omit = omit, @@ -153,10 +155,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/commands/devices", + path_template("/accounts/{account_id}/dex/commands/devices", account_id=account_id), page=AsyncV4PagePagination[Optional[DeviceListResponse]], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/dex/commands/downloads.py b/src/cloudflare/resources/zero_trust/dex/commands/downloads.py index 49d4323cba3..7638e1506e7 100644 --- a/src/cloudflare/resources/zero_trust/dex/commands/downloads.py +++ b/src/cloudflare/resources/zero_trust/dex/commands/downloads.py @@ -5,6 +5,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def get( self, filename: str, *, - account_id: str, + account_id: str | None = None, command_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. @@ -70,6 +71,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not command_id: @@ -78,7 +81,12 @@ def get( raise ValueError(f"Expected a non-empty value for `filename` but received {filename!r}") extra_headers = {"Accept": "application/zip", **(extra_headers or {})} return self._get( - f"/accounts/{account_id}/dex/commands/{command_id}/downloads/{filename}", + path_template( + "/accounts/{account_id}/dex/commands/{command_id}/downloads/{filename}", + account_id=account_id, + command_id=command_id, + filename=filename, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -110,7 +118,7 @@ async def get( self, filename: str, *, - account_id: str, + account_id: str | None = None, command_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. @@ -134,6 +142,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not command_id: @@ -142,7 +152,12 @@ async def get( raise ValueError(f"Expected a non-empty value for `filename` but received {filename!r}") extra_headers = {"Accept": "application/zip", **(extra_headers or {})} return await self._get( - f"/accounts/{account_id}/dex/commands/{command_id}/downloads/{filename}", + path_template( + "/accounts/{account_id}/dex/commands/{command_id}/downloads/{filename}", + account_id=account_id, + command_id=command_id, + filename=filename, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/zero_trust/dex/commands/quota.py b/src/cloudflare/resources/zero_trust/dex/commands/quota.py index 196340864a5..86505bf8048 100644 --- a/src/cloudflare/resources/zero_trust/dex/commands/quota.py +++ b/src/cloudflare/resources/zero_trust/dex/commands/quota.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> QuotaResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,10 +67,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/commands/quota", + path_template("/accounts/{account_id}/dex/commands/quota", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -104,7 +107,7 @@ def with_streaming_response(self) -> AsyncQuotaResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -125,10 +128,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/commands/quota", + path_template("/accounts/{account_id}/dex/commands/quota", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py b/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py index 79c163979d1..c066bee2c87 100644 --- a/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py +++ b/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> DevicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, from_: str, page: float, per_page: float, @@ -110,10 +110,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/fleet-status/devices", + path_template("/accounts/{account_id}/dex/fleet-status/devices", account_id=account_id), page=SyncV4PagePaginationArray[DeviceListResponse], options=make_request_options( extra_headers=extra_headers, @@ -165,7 +167,7 @@ def with_streaming_response(self) -> AsyncDevicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, from_: str, page: float, per_page: float, @@ -228,10 +230,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/fleet-status/devices", + path_template("/accounts/{account_id}/dex/fleet-status/devices", account_id=account_id), page=AsyncV4PagePaginationArray[DeviceListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py b/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py index 96010460e44..82cf490b159 100644 --- a/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py +++ b/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py @@ -15,7 +15,7 @@ AsyncDevicesResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -60,7 +60,7 @@ def with_streaming_response(self) -> FleetStatusResourceWithStreamingResponse: def live( self, *, - account_id: str, + account_id: str | None = None, since_minutes: 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. @@ -83,10 +83,12 @@ def live( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/fleet-status/live", + path_template("/accounts/{account_id}/dex/fleet-status/live", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -101,7 +103,7 @@ def live( def over_time( self, *, - account_id: str, + account_id: str | None = None, from_: str, to: str, colo: str | Omit = omit, @@ -133,10 +135,12 @@ def over_time( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/fleet-status/over-time", + path_template("/accounts/{account_id}/dex/fleet-status/over-time", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -184,7 +188,7 @@ def with_streaming_response(self) -> AsyncFleetStatusResourceWithStreamingRespon async def live( self, *, - account_id: str, + account_id: str | None = None, since_minutes: 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. @@ -207,10 +211,12 @@ async def live( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/fleet-status/live", + path_template("/accounts/{account_id}/dex/fleet-status/live", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -227,7 +233,7 @@ async def live( async def over_time( self, *, - account_id: str, + account_id: str | None = None, from_: str, to: str, colo: str | Omit = omit, @@ -259,10 +265,12 @@ async def over_time( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/fleet-status/over-time", + path_template("/accounts/{account_id}/dex/fleet-status/over-time", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py b/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py index 58ce0db4487..466d21b40a2 100644 --- a/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py +++ b/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from .percentiles import ( PercentilesResource, @@ -61,7 +61,7 @@ def get( self, test_id: str, *, - account_id: str, + account_id: str | None = None, from_: str, interval: Literal["minute", "hour"], to: str, @@ -101,12 +101,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return self._get( - f"/accounts/{account_id}/dex/http-tests/{test_id}", + path_template("/accounts/{account_id}/dex/http-tests/{test_id}", account_id=account_id, test_id=test_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -156,7 +158,7 @@ async def get( self, test_id: str, *, - account_id: str, + account_id: str | None = None, from_: str, interval: Literal["minute", "hour"], to: str, @@ -196,12 +198,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return await self._get( - f"/accounts/{account_id}/dex/http-tests/{test_id}", + path_template("/accounts/{account_id}/dex/http-tests/{test_id}", account_id=account_id, test_id=test_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py b/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py index 9416da48657..6ae59ef9f9b 100644 --- a/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py +++ b/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,7 +48,7 @@ def get( self, test_id: str, *, - account_id: str, + account_id: str | None = None, from_: str, to: str, colo: str | Omit = omit, @@ -85,12 +85,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return self._get( - f"/accounts/{account_id}/dex/http-tests/{test_id}/percentiles", + path_template( + "/accounts/{account_id}/dex/http-tests/{test_id}/percentiles", account_id=account_id, test_id=test_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -135,7 +139,7 @@ async def get( self, test_id: str, *, - account_id: str, + account_id: str | None = None, from_: str, to: str, colo: str | Omit = omit, @@ -172,12 +176,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return await self._get( - f"/accounts/{account_id}/dex/http-tests/{test_id}/percentiles", + path_template( + "/accounts/{account_id}/dex/http-tests/{test_id}/percentiles", account_id=account_id, test_id=test_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dex/rules.py b/src/cloudflare/resources/zero_trust/dex/rules.py index bfc1fab8624..503a8a567e4 100644 --- a/src/cloudflare/resources/zero_trust/dex/rules.py +++ b/src/cloudflare/resources/zero_trust/dex/rules.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> RulesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, match: str, name: str, description: str | Omit = omit, @@ -80,10 +80,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/rules", + path_template("/accounts/{account_id}/dex/rules", account_id=account_id), body=maybe_transform( { "match": match, @@ -106,7 +108,7 @@ def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, match: str | Omit = omit, name: str | Omit = omit, @@ -135,12 +137,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._patch( - f"/accounts/{account_id}/dex/rules/{rule_id}", + path_template("/accounts/{account_id}/dex/rules/{rule_id}", account_id=account_id, rule_id=rule_id), body=maybe_transform( { "description": description, @@ -162,7 +166,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: float, per_page: float, name: str | Omit = omit, @@ -197,10 +201,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/rules", + path_template("/accounts/{account_id}/dex/rules", account_id=account_id), page=SyncV4PagePagination[Optional[RuleListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -225,7 +231,7 @@ def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -247,12 +253,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._delete( - f"/accounts/{account_id}/dex/rules/{rule_id}", + path_template("/accounts/{account_id}/dex/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -267,7 +275,7 @@ def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -289,12 +297,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get( - f"/accounts/{account_id}/dex/rules/{rule_id}", + path_template("/accounts/{account_id}/dex/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -329,7 +339,7 @@ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, match: str, name: str, description: str | Omit = omit, @@ -356,10 +366,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/rules", + path_template("/accounts/{account_id}/dex/rules", account_id=account_id), body=await async_maybe_transform( { "match": match, @@ -382,7 +394,7 @@ async def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, description: str | Omit = omit, match: str | Omit = omit, name: str | Omit = omit, @@ -411,12 +423,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._patch( - f"/accounts/{account_id}/dex/rules/{rule_id}", + path_template("/accounts/{account_id}/dex/rules/{rule_id}", account_id=account_id, rule_id=rule_id), body=await async_maybe_transform( { "description": description, @@ -438,7 +452,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, page: float, per_page: float, name: str | Omit = omit, @@ -473,10 +487,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/rules", + path_template("/accounts/{account_id}/dex/rules", account_id=account_id), page=AsyncV4PagePagination[Optional[RuleListResponse]], options=make_request_options( extra_headers=extra_headers, @@ -501,7 +517,7 @@ async def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -523,12 +539,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._delete( - f"/accounts/{account_id}/dex/rules/{rule_id}", + path_template("/accounts/{account_id}/dex/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -543,7 +561,7 @@ async def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -565,12 +583,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._get( - f"/accounts/{account_id}/dex/rules/{rule_id}", + path_template("/accounts/{account_id}/dex/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dex/tests/tests.py b/src/cloudflare/resources/zero_trust/dex/tests/tests.py index 1333052426b..054db0cb00d 100644 --- a/src/cloudflare/resources/zero_trust/dex/tests/tests.py +++ b/src/cloudflare/resources/zero_trust/dex/tests/tests.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -62,7 +62,7 @@ def with_streaming_response(self) -> TestsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, colo: str | Omit = omit, device_id: SequenceNotStr[str] | Omit = omit, kind: Literal["http", "traceroute"] | Omit = omit, @@ -106,10 +106,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/tests/overview", + path_template("/accounts/{account_id}/dex/tests/overview", account_id=account_id), page=SyncV4PagePagination[Optional[Tests]], options=make_request_options( extra_headers=extra_headers, @@ -160,7 +162,7 @@ def with_streaming_response(self) -> AsyncTestsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, colo: str | Omit = omit, device_id: SequenceNotStr[str] | Omit = omit, kind: Literal["http", "traceroute"] | Omit = omit, @@ -204,10 +206,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/tests/overview", + path_template("/accounts/{account_id}/dex/tests/overview", account_id=account_id), page=AsyncV4PagePagination[Optional[Tests]], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/dex/tests/unique_devices.py b/src/cloudflare/resources/zero_trust/dex/tests/unique_devices.py index 0cc5b6647ed..9e6559cbf39 100644 --- a/src/cloudflare/resources/zero_trust/dex/tests/unique_devices.py +++ b/src/cloudflare/resources/zero_trust/dex/tests/unique_devices.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> UniqueDevicesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, device_id: SequenceNotStr[str] | Omit = omit, test_name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -75,10 +75,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/tests/unique-devices", + path_template("/accounts/{account_id}/dex/tests/unique-devices", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -120,7 +122,7 @@ def with_streaming_response(self) -> AsyncUniqueDevicesResourceWithStreamingResp async def list( self, *, - account_id: str, + account_id: str | None = None, device_id: SequenceNotStr[str] | Omit = omit, test_name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -148,10 +150,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/tests/unique-devices", + path_template("/accounts/{account_id}/dex/tests/unique-devices", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dex/traceroute_test_results/network_path.py b/src/cloudflare/resources/zero_trust/dex/traceroute_test_results/network_path.py index 2d01628d26f..2e768a9f1bf 100644 --- a/src/cloudflare/resources/zero_trust/dex/traceroute_test_results/network_path.py +++ b/src/cloudflare/resources/zero_trust/dex/traceroute_test_results/network_path.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def get( self, test_result_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -69,12 +70,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_result_id: raise ValueError(f"Expected a non-empty value for `test_result_id` but received {test_result_id!r}") return self._get( - f"/accounts/{account_id}/dex/traceroute-test-results/{test_result_id}/network-path", + path_template( + "/accounts/{account_id}/dex/traceroute-test-results/{test_result_id}/network-path", + account_id=account_id, + test_result_id=test_result_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -110,7 +117,7 @@ async def get( self, test_result_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -133,12 +140,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_result_id: raise ValueError(f"Expected a non-empty value for `test_result_id` but received {test_result_id!r}") return await self._get( - f"/accounts/{account_id}/dex/traceroute-test-results/{test_result_id}/network-path", + path_template( + "/accounts/{account_id}/dex/traceroute-test-results/{test_result_id}/network-path", + account_id=account_id, + test_result_id=test_result_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py b/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py index 474ce3f2362..e64746956c1 100644 --- a/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py +++ b/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -55,7 +55,7 @@ def get( self, test_id: str, *, - account_id: str, + account_id: str | None = None, from_: str, interval: Literal["minute", "hour"], to: str, @@ -95,12 +95,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return self._get( - f"/accounts/{account_id}/dex/traceroute-tests/{test_id}", + path_template( + "/accounts/{account_id}/dex/traceroute-tests/{test_id}", account_id=account_id, test_id=test_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -125,7 +129,7 @@ def network_path( self, test_id: str, *, - account_id: str, + account_id: str | None = None, device_id: str, from_: str, interval: Literal["minute", "hour"], @@ -159,12 +163,18 @@ def network_path( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return self._get( - f"/accounts/{account_id}/dex/traceroute-tests/{test_id}/network-path", + path_template( + "/accounts/{account_id}/dex/traceroute-tests/{test_id}/network-path", + account_id=account_id, + test_id=test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -188,7 +198,7 @@ def percentiles( self, test_id: str, *, - account_id: str, + account_id: str | None = None, from_: str, to: str, colo: str | Omit = omit, @@ -225,12 +235,18 @@ def percentiles( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return self._get( - f"/accounts/{account_id}/dex/traceroute-tests/{test_id}/percentiles", + path_template( + "/accounts/{account_id}/dex/traceroute-tests/{test_id}/percentiles", + account_id=account_id, + test_id=test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -277,7 +293,7 @@ async def get( self, test_id: str, *, - account_id: str, + account_id: str | None = None, from_: str, interval: Literal["minute", "hour"], to: str, @@ -317,12 +333,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return await self._get( - f"/accounts/{account_id}/dex/traceroute-tests/{test_id}", + path_template( + "/accounts/{account_id}/dex/traceroute-tests/{test_id}", account_id=account_id, test_id=test_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -347,7 +367,7 @@ async def network_path( self, test_id: str, *, - account_id: str, + account_id: str | None = None, device_id: str, from_: str, interval: Literal["minute", "hour"], @@ -381,12 +401,18 @@ async def network_path( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return await self._get( - f"/accounts/{account_id}/dex/traceroute-tests/{test_id}/network-path", + path_template( + "/accounts/{account_id}/dex/traceroute-tests/{test_id}/network-path", + account_id=account_id, + test_id=test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -410,7 +436,7 @@ async def percentiles( self, test_id: str, *, - account_id: str, + account_id: str | None = None, from_: str, to: str, colo: str | Omit = omit, @@ -447,12 +473,18 @@ async def percentiles( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not test_id: raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}") return await self._get( - f"/accounts/{account_id}/dex/traceroute-tests/{test_id}/percentiles", + path_template( + "/accounts/{account_id}/dex/traceroute-tests/{test_id}/percentiles", + account_id=account_id, + test_id=test_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dex/warp_change_events.py b/src/cloudflare/resources/zero_trust/dex/warp_change_events.py index 0b2630a813d..63bc471f62f 100644 --- a/src/cloudflare/resources/zero_trust/dex/warp_change_events.py +++ b/src/cloudflare/resources/zero_trust/dex/warp_change_events.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> WARPChangeEventsResourceWithStreamingRespon def get( self, *, - account_id: str, + account_id: str | None = None, from_: str, page: float, per_page: float, @@ -96,10 +96,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/warp-change-events", + path_template("/accounts/{account_id}/dex/warp-change-events", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -148,7 +150,7 @@ def with_streaming_response(self) -> AsyncWARPChangeEventsResourceWithStreamingR async def get( self, *, - account_id: str, + account_id: str | None = None, from_: str, page: float, per_page: float, @@ -196,10 +198,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dex/warp-change-events", + path_template("/accounts/{account_id}/dex/warp-change-events", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/__init__.py b/src/cloudflare/resources/zero_trust/dlp/__init__.py index 03f7e960404..b4bcee02e5d 100644 --- a/src/cloudflare/resources/zero_trust/dlp/__init__.py +++ b/src/cloudflare/resources/zero_trust/dlp/__init__.py @@ -56,6 +56,14 @@ ProfilesResourceWithStreamingResponse, AsyncProfilesResourceWithStreamingResponse, ) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) from .payload_logs import ( PayloadLogsResource, AsyncPayloadLogsResource, @@ -84,6 +92,12 @@ "AsyncPayloadLogsResourceWithRawResponse", "PayloadLogsResourceWithStreamingResponse", "AsyncPayloadLogsResourceWithStreamingResponse", + "SettingsResource", + "AsyncSettingsResource", + "SettingsResourceWithRawResponse", + "AsyncSettingsResourceWithRawResponse", + "SettingsResourceWithStreamingResponse", + "AsyncSettingsResourceWithStreamingResponse", "EmailResource", "AsyncEmailResource", "EmailResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/dlp/datasets/datasets.py b/src/cloudflare/resources/zero_trust/dlp/datasets/datasets.py index 8a558f1b5a4..5cfcf433421 100644 --- a/src/cloudflare/resources/zero_trust/dlp/datasets/datasets.py +++ b/src/cloudflare/resources/zero_trust/dlp/datasets/datasets.py @@ -15,7 +15,7 @@ AsyncUploadResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -73,7 +73,7 @@ def with_streaming_response(self) -> DatasetsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, case_sensitive: bool | Omit = omit, description: Optional[str] | Omit = omit, @@ -117,10 +117,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/datasets", + path_template("/accounts/{account_id}/dlp/datasets", account_id=account_id), body=maybe_transform( { "name": name, @@ -145,7 +147,7 @@ def update( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, case_sensitive: bool | Omit = omit, description: Optional[str] | Omit = omit, name: Optional[str] | Omit = omit, @@ -177,12 +179,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return self._put( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}", account_id=account_id, dataset_id=dataset_id + ), body=maybe_transform( { "case_sensitive": case_sensitive, @@ -204,7 +210,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -225,10 +231,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/datasets", + path_template("/accounts/{account_id}/dlp/datasets", account_id=account_id), page=SyncSinglePage[Dataset], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -240,7 +248,7 @@ def delete( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -260,13 +268,17 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}", account_id=account_id, dataset_id=dataset_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -277,7 +289,7 @@ def get( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -297,12 +309,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return self._get( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}", account_id=account_id, dataset_id=dataset_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -345,7 +361,7 @@ def with_streaming_response(self) -> AsyncDatasetsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, case_sensitive: bool | Omit = omit, description: Optional[str] | Omit = omit, @@ -389,10 +405,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/datasets", + path_template("/accounts/{account_id}/dlp/datasets", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -417,7 +435,7 @@ async def update( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, case_sensitive: bool | Omit = omit, description: Optional[str] | Omit = omit, name: Optional[str] | Omit = omit, @@ -449,12 +467,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return await self._put( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}", account_id=account_id, dataset_id=dataset_id + ), body=await async_maybe_transform( { "case_sensitive": case_sensitive, @@ -476,7 +498,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -497,10 +519,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/datasets", + path_template("/accounts/{account_id}/dlp/datasets", account_id=account_id), page=AsyncSinglePage[Dataset], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -512,7 +536,7 @@ async def delete( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -532,13 +556,17 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}", account_id=account_id, dataset_id=dataset_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -549,7 +577,7 @@ async def get( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -569,12 +597,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return await self._get( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}", account_id=account_id, dataset_id=dataset_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/datasets/upload.py b/src/cloudflare/resources/zero_trust/dlp/datasets/upload.py index 225767adeeb..a0605a01400 100644 --- a/src/cloudflare/resources/zero_trust/dlp/datasets/upload.py +++ b/src/cloudflare/resources/zero_trust/dlp/datasets/upload.py @@ -18,6 +18,7 @@ AsyncBinaryTypes, not_given, ) +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -58,7 +59,7 @@ def create( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -79,12 +80,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return self._post( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}/upload", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}/upload", account_id=account_id, dataset_id=dataset_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -100,7 +105,7 @@ def edit( version: int, dataset: FileContent | BinaryTypes, *, - account_id: str, + account_id: str | None = None, dataset_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. @@ -125,13 +130,20 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}/upload/{version}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}/upload/{version}", + account_id=account_id, + dataset_id=dataset_id, + version=version, + ), content=read_file_content(dataset) if isinstance(dataset, os.PathLike) else dataset, options=make_request_options( extra_headers=extra_headers, @@ -168,7 +180,7 @@ async def create( self, dataset_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -189,12 +201,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return await self._post( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}/upload", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}/upload", account_id=account_id, dataset_id=dataset_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -210,7 +226,7 @@ async def edit( version: int, dataset: FileContent | AsyncBinaryTypes, *, - account_id: str, + account_id: str | None = None, dataset_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. @@ -235,13 +251,20 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}/upload/{version}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}/upload/{version}", + account_id=account_id, + dataset_id=dataset_id, + version=version, + ), content=await async_read_file_content(dataset) if isinstance(dataset, os.PathLike) else dataset, options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/dlp/datasets/versions/entries.py b/src/cloudflare/resources/zero_trust/dlp/datasets/versions/entries.py index 46cdde41056..d12613f0ce8 100755 --- a/src/cloudflare/resources/zero_trust/dlp/datasets/versions/entries.py +++ b/src/cloudflare/resources/zero_trust/dlp/datasets/versions/entries.py @@ -18,6 +18,7 @@ AsyncBinaryTypes, not_given, ) +from ......_utils import path_template from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -58,7 +59,7 @@ def create( entry_id: str, dataset_version_entry: FileContent | BinaryTypes, *, - account_id: str, + account_id: str | None = None, dataset_id: str, version: int, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -82,6 +83,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: @@ -90,7 +93,13 @@ def create( raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})} return self._post( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}/versions/{version}/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}/versions/{version}/entries/{entry_id}", + account_id=account_id, + dataset_id=dataset_id, + version=version, + entry_id=entry_id, + ), content=read_file_content(dataset_version_entry) if isinstance(dataset_version_entry, os.PathLike) else dataset_version_entry, @@ -130,7 +139,7 @@ async def create( entry_id: str, dataset_version_entry: FileContent | AsyncBinaryTypes, *, - account_id: str, + account_id: str | None = None, dataset_id: str, version: int, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -154,6 +163,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: @@ -162,7 +173,13 @@ async def create( raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") extra_headers = {"Content-Type": "application/octet-stream", **(extra_headers or {})} return await self._post( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}/versions/{version}/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}/versions/{version}/entries/{entry_id}", + account_id=account_id, + dataset_id=dataset_id, + version=version, + entry_id=entry_id, + ), content=await async_read_file_content(dataset_version_entry) if isinstance(dataset_version_entry, os.PathLike) else dataset_version_entry, diff --git a/src/cloudflare/resources/zero_trust/dlp/datasets/versions/versions.py b/src/cloudflare/resources/zero_trust/dlp/datasets/versions/versions.py index 90b562051a9..b29e0151103 100755 --- a/src/cloudflare/resources/zero_trust/dlp/datasets/versions/versions.py +++ b/src/cloudflare/resources/zero_trust/dlp/datasets/versions/versions.py @@ -15,7 +15,7 @@ AsyncEntriesResourceWithStreamingResponse, ) from ......_types import Body, Query, Headers, NotGiven, not_given -from ......_utils import maybe_transform +from ......_utils import path_template, maybe_transform from ......_compat import cached_property from ......_resource import SyncAPIResource, AsyncAPIResource from ......_response import ( @@ -60,7 +60,7 @@ def create( self, version: int, *, - account_id: str, + account_id: str | None = None, dataset_id: str, body: Iterable[version_create_params.Body], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -85,12 +85,19 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return self._get_api_list( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}/versions/{version}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}/versions/{version}", + account_id=account_id, + dataset_id=dataset_id, + version=version, + ), page=SyncSinglePage[VersionCreateResponse], body=maybe_transform(body, Iterable[version_create_params.Body]), options=make_request_options( @@ -129,7 +136,7 @@ def create( self, version: int, *, - account_id: str, + account_id: str | None = None, dataset_id: str, body: Iterable[version_create_params.Body], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -154,12 +161,19 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") return self._get_api_list( - f"/accounts/{account_id}/dlp/datasets/{dataset_id}/versions/{version}", + path_template( + "/accounts/{account_id}/dlp/datasets/{dataset_id}/versions/{version}", + account_id=account_id, + dataset_id=dataset_id, + version=version, + ), page=AsyncSinglePage[VersionCreateResponse], body=maybe_transform(body, Iterable[version_create_params.Body]), options=make_request_options( diff --git a/src/cloudflare/resources/zero_trust/dlp/dlp.py b/src/cloudflare/resources/zero_trust/dlp/dlp.py index 7444c2b17de..0b1776e59d3 100644 --- a/src/cloudflare/resources/zero_trust/dlp/dlp.py +++ b/src/cloudflare/resources/zero_trust/dlp/dlp.py @@ -18,6 +18,14 @@ PatternsResourceWithStreamingResponse, AsyncPatternsResourceWithStreamingResponse, ) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) from ...._compat import cached_property from .email.email import ( EmailResource, @@ -77,6 +85,10 @@ def patterns(self) -> PatternsResource: def payload_logs(self) -> PayloadLogsResource: return PayloadLogsResource(self._client) + @cached_property + def settings(self) -> SettingsResource: + return SettingsResource(self._client) + @cached_property def email(self) -> EmailResource: return EmailResource(self._client) @@ -126,6 +138,10 @@ def patterns(self) -> AsyncPatternsResource: def payload_logs(self) -> AsyncPayloadLogsResource: return AsyncPayloadLogsResource(self._client) + @cached_property + def settings(self) -> AsyncSettingsResource: + return AsyncSettingsResource(self._client) + @cached_property def email(self) -> AsyncEmailResource: return AsyncEmailResource(self._client) @@ -178,6 +194,10 @@ def patterns(self) -> PatternsResourceWithRawResponse: def payload_logs(self) -> PayloadLogsResourceWithRawResponse: return PayloadLogsResourceWithRawResponse(self._dlp.payload_logs) + @cached_property + def settings(self) -> SettingsResourceWithRawResponse: + return SettingsResourceWithRawResponse(self._dlp.settings) + @cached_property def email(self) -> EmailResourceWithRawResponse: return EmailResourceWithRawResponse(self._dlp.email) @@ -211,6 +231,10 @@ def patterns(self) -> AsyncPatternsResourceWithRawResponse: def payload_logs(self) -> AsyncPayloadLogsResourceWithRawResponse: return AsyncPayloadLogsResourceWithRawResponse(self._dlp.payload_logs) + @cached_property + def settings(self) -> AsyncSettingsResourceWithRawResponse: + return AsyncSettingsResourceWithRawResponse(self._dlp.settings) + @cached_property def email(self) -> AsyncEmailResourceWithRawResponse: return AsyncEmailResourceWithRawResponse(self._dlp.email) @@ -244,6 +268,10 @@ def patterns(self) -> PatternsResourceWithStreamingResponse: def payload_logs(self) -> PayloadLogsResourceWithStreamingResponse: return PayloadLogsResourceWithStreamingResponse(self._dlp.payload_logs) + @cached_property + def settings(self) -> SettingsResourceWithStreamingResponse: + return SettingsResourceWithStreamingResponse(self._dlp.settings) + @cached_property def email(self) -> EmailResourceWithStreamingResponse: return EmailResourceWithStreamingResponse(self._dlp.email) @@ -277,6 +305,10 @@ def patterns(self) -> AsyncPatternsResourceWithStreamingResponse: def payload_logs(self) -> AsyncPayloadLogsResourceWithStreamingResponse: return AsyncPayloadLogsResourceWithStreamingResponse(self._dlp.payload_logs) + @cached_property + def settings(self) -> AsyncSettingsResourceWithStreamingResponse: + return AsyncSettingsResourceWithStreamingResponse(self._dlp.settings) + @cached_property def email(self) -> AsyncEmailResourceWithStreamingResponse: return AsyncEmailResourceWithStreamingResponse(self._dlp.email) diff --git a/src/cloudflare/resources/zero_trust/dlp/email/account_mapping.py b/src/cloudflare/resources/zero_trust/dlp/email/account_mapping.py index 553590a48e8..8ede4b5110e 100644 --- a/src/cloudflare/resources/zero_trust/dlp/email/account_mapping.py +++ b/src/cloudflare/resources/zero_trust/dlp/email/account_mapping.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> AccountMappingResourceWithStreamingResponse def create( self, *, - account_id: str, + account_id: str | None = None, auth_requirements: account_mapping_create_params.AuthRequirements, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -70,10 +70,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/email/account_mapping", + path_template("/accounts/{account_id}/dlp/email/account_mapping", account_id=account_id), body=maybe_transform( {"auth_requirements": auth_requirements}, account_mapping_create_params.AccountMappingCreateParams ), @@ -90,7 +92,7 @@ def create( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -110,10 +112,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/email/account_mapping", + path_template("/accounts/{account_id}/dlp/email/account_mapping", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -148,7 +152,7 @@ def with_streaming_response(self) -> AsyncAccountMappingResourceWithStreamingRes async def create( self, *, - account_id: str, + account_id: str | None = None, auth_requirements: account_mapping_create_params.AuthRequirements, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -170,10 +174,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/email/account_mapping", + path_template("/accounts/{account_id}/dlp/email/account_mapping", account_id=account_id), body=await async_maybe_transform( {"auth_requirements": auth_requirements}, account_mapping_create_params.AccountMappingCreateParams ), @@ -190,7 +196,7 @@ async def create( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -210,10 +216,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/email/account_mapping", + path_template("/accounts/{account_id}/dlp/email/account_mapping", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/email/rules.py b/src/cloudflare/resources/zero_trust/dlp/email/rules.py index c52537968aa..12272b39c5d 100644 --- a/src/cloudflare/resources/zero_trust/dlp/email/rules.py +++ b/src/cloudflare/resources/zero_trust/dlp/email/rules.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -53,7 +53,7 @@ def with_streaming_response(self) -> RulesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, action: rule_create_params.Action, conditions: Iterable[rule_create_params.Condition], enabled: bool, @@ -81,10 +81,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/email/rules", + path_template("/accounts/{account_id}/dlp/email/rules", account_id=account_id), body=maybe_transform( { "action": action, @@ -109,7 +111,7 @@ def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, action: rule_update_params.Action, conditions: Iterable[rule_update_params.Condition], enabled: bool, @@ -136,12 +138,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._put( - f"/accounts/{account_id}/dlp/email/rules/{rule_id}", + path_template("/accounts/{account_id}/dlp/email/rules/{rule_id}", account_id=account_id, rule_id=rule_id), body=maybe_transform( { "action": action, @@ -165,7 +169,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -185,10 +189,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/email/rules", + path_template("/accounts/{account_id}/dlp/email/rules", account_id=account_id), page=SyncSinglePage[RuleListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -200,7 +206,7 @@ def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -222,12 +228,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._delete( - f"/accounts/{account_id}/dlp/email/rules/{rule_id}", + path_template("/accounts/{account_id}/dlp/email/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -241,7 +249,7 @@ def delete( def bulk_edit( self, *, - account_id: str, + account_id: str | None = None, new_priorities: Dict[str, int], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -264,10 +272,12 @@ def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/dlp/email/rules", + path_template("/accounts/{account_id}/dlp/email/rules", account_id=account_id), body=maybe_transform({"new_priorities": new_priorities}, rule_bulk_edit_params.RuleBulkEditParams), options=make_request_options( extra_headers=extra_headers, @@ -283,7 +293,7 @@ def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -304,12 +314,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get( - f"/accounts/{account_id}/dlp/email/rules/{rule_id}", + path_template("/accounts/{account_id}/dlp/email/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -344,7 +356,7 @@ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, action: rule_create_params.Action, conditions: Iterable[rule_create_params.Condition], enabled: bool, @@ -372,10 +384,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/email/rules", + path_template("/accounts/{account_id}/dlp/email/rules", account_id=account_id), body=await async_maybe_transform( { "action": action, @@ -400,7 +414,7 @@ async def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, action: rule_update_params.Action, conditions: Iterable[rule_update_params.Condition], enabled: bool, @@ -427,12 +441,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._put( - f"/accounts/{account_id}/dlp/email/rules/{rule_id}", + path_template("/accounts/{account_id}/dlp/email/rules/{rule_id}", account_id=account_id, rule_id=rule_id), body=await async_maybe_transform( { "action": action, @@ -456,7 +472,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -476,10 +492,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/email/rules", + path_template("/accounts/{account_id}/dlp/email/rules", account_id=account_id), page=AsyncSinglePage[RuleListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -491,7 +509,7 @@ async def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -513,12 +531,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._delete( - f"/accounts/{account_id}/dlp/email/rules/{rule_id}", + path_template("/accounts/{account_id}/dlp/email/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -532,7 +552,7 @@ async def delete( async def bulk_edit( self, *, - account_id: str, + account_id: str | None = None, new_priorities: Dict[str, int], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -555,10 +575,12 @@ async def bulk_edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/dlp/email/rules", + path_template("/accounts/{account_id}/dlp/email/rules", account_id=account_id), body=await async_maybe_transform( {"new_priorities": new_priorities}, rule_bulk_edit_params.RuleBulkEditParams ), @@ -576,7 +598,7 @@ async def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -597,12 +619,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._get( - f"/accounts/{account_id}/dlp/email/rules/{rule_id}", + path_template("/accounts/{account_id}/dlp/email/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/entries/custom.py b/src/cloudflare/resources/zero_trust/dlp/entries/custom.py index 12e290917de..0d53d68b0c9 100644 --- a/src/cloudflare/resources/zero_trust/dlp/entries/custom.py +++ b/src/cloudflare/resources/zero_trust/dlp/entries/custom.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> CustomResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, enabled: bool, name: str, pattern: PatternParam, @@ -77,10 +77,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), body=maybe_transform( { "enabled": enabled, @@ -105,7 +107,7 @@ def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, enabled: bool, name: str, pattern: PatternParam, @@ -129,12 +131,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._put( - f"/accounts/{account_id}/dlp/entries/custom/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/custom/{entry_id}", account_id=account_id, entry_id=entry_id + ), body=maybe_transform( { "enabled": enabled, @@ -157,7 +163,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -177,10 +183,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), page=SyncSinglePage[CustomListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -192,7 +200,7 @@ def delete( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -212,12 +220,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._delete( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template("/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -232,7 +242,7 @@ def get( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -252,6 +262,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -259,7 +271,9 @@ def get( return cast( Optional[CustomGetResponse], self._get( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -297,7 +311,7 @@ def with_streaming_response(self) -> AsyncCustomResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, enabled: bool, name: str, pattern: PatternParam, @@ -322,10 +336,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), body=await async_maybe_transform( { "enabled": enabled, @@ -350,7 +366,7 @@ async def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, enabled: bool, name: str, pattern: PatternParam, @@ -374,12 +390,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._put( - f"/accounts/{account_id}/dlp/entries/custom/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/custom/{entry_id}", account_id=account_id, entry_id=entry_id + ), body=await async_maybe_transform( { "enabled": enabled, @@ -402,7 +422,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -422,10 +442,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), page=AsyncSinglePage[CustomListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -437,7 +459,7 @@ async def delete( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -457,12 +479,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._delete( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template("/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -477,7 +501,7 @@ async def get( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -497,6 +521,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -504,7 +530,9 @@ async def get( return cast( Optional[CustomGetResponse], await self._get( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/entries/entries.py b/src/cloudflare/resources/zero_trust/dlp/entries/entries.py index 619df5a3f6a..40348da9b0f 100644 --- a/src/cloudflare/resources/zero_trust/dlp/entries/entries.py +++ b/src/cloudflare/resources/zero_trust/dlp/entries/entries.py @@ -16,7 +16,7 @@ AsyncCustomResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import required_args, maybe_transform, async_maybe_transform +from ....._utils import path_template, required_args, maybe_transform, async_maybe_transform from .predefined import ( PredefinedResource, AsyncPredefinedResource, @@ -89,7 +89,7 @@ def with_streaming_response(self) -> EntriesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, enabled: bool, name: str, pattern: PatternParam, @@ -114,10 +114,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), body=maybe_transform( { "enabled": enabled, @@ -143,7 +145,7 @@ def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, name: str, pattern: PatternParam, type: Literal["custom"], @@ -175,7 +177,7 @@ def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, type: Literal["predefined"], enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -204,7 +206,7 @@ def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, type: Literal["integration"], enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -228,12 +230,12 @@ def update( """ ... - @required_args(["account_id", "name", "pattern", "type"], ["account_id", "type"]) + @required_args(["name", "pattern", "type"], ["type"]) def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, pattern: PatternParam | Omit = omit, type: Literal["custom"] | Literal["predefined"] | Literal["integration"], @@ -246,6 +248,8 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[EntryUpdateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -253,7 +257,9 @@ def update( return cast( Optional[EntryUpdateResponse], self._put( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), body=maybe_transform( { "name": name, @@ -280,7 +286,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -300,10 +306,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), page=SyncSinglePage[EntryListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -315,7 +323,7 @@ def delete( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -335,12 +343,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._delete( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template("/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -355,7 +365,7 @@ def get( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -375,6 +385,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -382,7 +394,9 @@ def get( return cast( Optional[EntryGetResponse], self._get( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -432,7 +446,7 @@ def with_streaming_response(self) -> AsyncEntriesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, enabled: bool, name: str, pattern: PatternParam, @@ -457,10 +471,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), body=await async_maybe_transform( { "enabled": enabled, @@ -486,7 +502,7 @@ async def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, name: str, pattern: PatternParam, type: Literal["custom"], @@ -518,7 +534,7 @@ async def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, type: Literal["predefined"], enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -547,7 +563,7 @@ async def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, type: Literal["integration"], enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -571,12 +587,12 @@ async def update( """ ... - @required_args(["account_id", "name", "pattern", "type"], ["account_id", "type"]) + @required_args(["name", "pattern", "type"], ["type"]) async def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, pattern: PatternParam | Omit = omit, type: Literal["custom"] | Literal["predefined"] | Literal["integration"], @@ -589,6 +605,8 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[EntryUpdateResponse]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -596,7 +614,9 @@ async def update( return cast( Optional[EntryUpdateResponse], await self._put( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), body=await async_maybe_transform( { "name": name, @@ -623,7 +643,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -643,10 +663,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), page=AsyncSinglePage[EntryListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -658,7 +680,7 @@ async def delete( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -678,12 +700,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._delete( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template("/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -698,7 +722,7 @@ async def get( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -718,6 +742,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -725,7 +751,9 @@ async def get( return cast( Optional[EntryGetResponse], await self._get( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/entries/integration.py b/src/cloudflare/resources/zero_trust/dlp/entries/integration.py index 442bc7ed1ea..2ed6f3a18d5 100644 --- a/src/cloudflare/resources/zero_trust/dlp/entries/integration.py +++ b/src/cloudflare/resources/zero_trust/dlp/entries/integration.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> IntegrationResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, enabled: bool, entry_id: str, profile_id: Optional[str] | Omit = omit, @@ -78,10 +78,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries/integration", + path_template("/accounts/{account_id}/dlp/entries/integration", account_id=account_id), body=maybe_transform( { "enabled": enabled, @@ -104,7 +106,7 @@ def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, enabled: 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. @@ -125,12 +127,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._put( - f"/accounts/{account_id}/dlp/entries/integration/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/integration/{entry_id}", account_id=account_id, entry_id=entry_id + ), body=maybe_transform({"enabled": enabled}, integration_update_params.IntegrationUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -145,7 +151,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -165,10 +171,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), page=SyncSinglePage[IntegrationListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -180,7 +188,7 @@ def delete( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -201,12 +209,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._delete( - f"/accounts/{account_id}/dlp/entries/integration/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/integration/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -221,7 +233,7 @@ def get( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -241,6 +253,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -248,7 +262,9 @@ def get( return cast( Optional[IntegrationGetResponse], self._get( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +302,7 @@ def with_streaming_response(self) -> AsyncIntegrationResourceWithStreamingRespon async def create( self, *, - account_id: str, + account_id: str | None = None, enabled: bool, entry_id: str, profile_id: Optional[str] | Omit = omit, @@ -313,10 +329,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries/integration", + path_template("/accounts/{account_id}/dlp/entries/integration", account_id=account_id), body=await async_maybe_transform( { "enabled": enabled, @@ -339,7 +357,7 @@ async def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, enabled: 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. @@ -360,12 +378,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._put( - f"/accounts/{account_id}/dlp/entries/integration/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/integration/{entry_id}", account_id=account_id, entry_id=entry_id + ), body=await async_maybe_transform({"enabled": enabled}, integration_update_params.IntegrationUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -380,7 +402,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -400,10 +422,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), page=AsyncSinglePage[IntegrationListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -415,7 +439,7 @@ async def delete( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -436,12 +460,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._delete( - f"/accounts/{account_id}/dlp/entries/integration/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/integration/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -456,7 +484,7 @@ async def get( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -476,6 +504,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -483,7 +513,9 @@ async def get( return cast( Optional[IntegrationGetResponse], await self._get( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/entries/predefined.py b/src/cloudflare/resources/zero_trust/dlp/entries/predefined.py index 023948dac57..82b26669caf 100644 --- a/src/cloudflare/resources/zero_trust/dlp/entries/predefined.py +++ b/src/cloudflare/resources/zero_trust/dlp/entries/predefined.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> PredefinedResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, enabled: bool, entry_id: str, profile_id: Optional[str] | Omit = omit, @@ -78,10 +78,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries/predefined", + path_template("/accounts/{account_id}/dlp/entries/predefined", account_id=account_id), body=maybe_transform( { "enabled": enabled, @@ -104,7 +106,7 @@ def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, enabled: 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. @@ -125,12 +127,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._put( - f"/accounts/{account_id}/dlp/entries/predefined/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/predefined/{entry_id}", account_id=account_id, entry_id=entry_id + ), body=maybe_transform({"enabled": enabled}, predefined_update_params.PredefinedUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -145,7 +151,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -165,10 +171,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), page=SyncSinglePage[PredefinedListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -180,7 +188,7 @@ def delete( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -201,12 +209,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._delete( - f"/accounts/{account_id}/dlp/entries/predefined/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/predefined/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -221,7 +233,7 @@ def get( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -241,6 +253,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -248,7 +262,9 @@ def get( return cast( Optional[PredefinedGetResponse], self._get( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -286,7 +302,7 @@ def with_streaming_response(self) -> AsyncPredefinedResourceWithStreamingRespons async def create( self, *, - account_id: str, + account_id: str | None = None, enabled: bool, entry_id: str, profile_id: Optional[str] | Omit = omit, @@ -313,10 +329,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries/predefined", + path_template("/accounts/{account_id}/dlp/entries/predefined", account_id=account_id), body=await async_maybe_transform( { "enabled": enabled, @@ -339,7 +357,7 @@ async def update( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, enabled: 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. @@ -360,12 +378,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._put( - f"/accounts/{account_id}/dlp/entries/predefined/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/predefined/{entry_id}", account_id=account_id, entry_id=entry_id + ), body=await async_maybe_transform({"enabled": enabled}, predefined_update_params.PredefinedUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -380,7 +402,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -400,10 +422,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/entries", + path_template("/accounts/{account_id}/dlp/entries", account_id=account_id), page=AsyncSinglePage[PredefinedListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -415,7 +439,7 @@ async def delete( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -436,12 +460,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._delete( - f"/accounts/{account_id}/dlp/entries/predefined/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/predefined/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -456,7 +484,7 @@ async def get( self, entry_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -476,6 +504,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not entry_id: @@ -483,7 +513,9 @@ async def get( return cast( Optional[PredefinedGetResponse], await self._get( - f"/accounts/{account_id}/dlp/entries/{entry_id}", + path_template( + "/accounts/{account_id}/dlp/entries/{entry_id}", account_id=account_id, entry_id=entry_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/limits.py b/src/cloudflare/resources/zero_trust/dlp/limits.py index 88912d0a500..9efbe87a354 100755 --- a/src/cloudflare/resources/zero_trust/dlp/limits.py +++ b/src/cloudflare/resources/zero_trust/dlp/limits.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> LimitsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/limits", + path_template("/accounts/{account_id}/dlp/limits", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -105,7 +108,7 @@ def with_streaming_response(self) -> AsyncLimitsResourceWithStreamingResponse: async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,10 +130,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/limits", + path_template("/accounts/{account_id}/dlp/limits", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/patterns.py b/src/cloudflare/resources/zero_trust/dlp/patterns.py index 445c21a725f..041ed9e0767 100644 --- a/src/cloudflare/resources/zero_trust/dlp/patterns.py +++ b/src/cloudflare/resources/zero_trust/dlp/patterns.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> PatternsResourceWithStreamingResponse: def validate( self, *, - account_id: str, + account_id: str | None = None, regex: str, max_match_bytes: Optional[int] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -83,10 +83,12 @@ def validate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/patterns/validate", + path_template("/accounts/{account_id}/dlp/patterns/validate", account_id=account_id), body=maybe_transform( { "regex": regex, @@ -128,7 +130,7 @@ def with_streaming_response(self) -> AsyncPatternsResourceWithStreamingResponse: async def validate( self, *, - account_id: str, + account_id: str | None = None, regex: str, max_match_bytes: Optional[int] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -164,10 +166,12 @@ async def validate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/patterns/validate", + path_template("/accounts/{account_id}/dlp/patterns/validate", account_id=account_id), body=await async_maybe_transform( { "regex": regex, diff --git a/src/cloudflare/resources/zero_trust/dlp/payload_logs.py b/src/cloudflare/resources/zero_trust/dlp/payload_logs.py index 2fb303a6d6a..a65f87d88e5 100644 --- a/src/cloudflare/resources/zero_trust/dlp/payload_logs.py +++ b/src/cloudflare/resources/zero_trust/dlp/payload_logs.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> PayloadLogsResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, masking_level: Literal["full", "partial", "clear", "default"] | Omit = omit, public_key: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -94,10 +94,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/payload_log", + path_template("/accounts/{account_id}/dlp/payload_log", account_id=account_id), body=maybe_transform( { "masking_level": masking_level, @@ -118,7 +120,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -139,10 +141,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/payload_log", + path_template("/accounts/{account_id}/dlp/payload_log", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -177,7 +181,7 @@ def with_streaming_response(self) -> AsyncPayloadLogsResourceWithStreamingRespon async def update( self, *, - account_id: str, + account_id: str | None = None, masking_level: Literal["full", "partial", "clear", "default"] | Omit = omit, public_key: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -222,10 +226,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/payload_log", + path_template("/accounts/{account_id}/dlp/payload_log", account_id=account_id), body=await async_maybe_transform( { "masking_level": masking_level, @@ -246,7 +252,7 @@ async def update( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -267,10 +273,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/payload_log", + path_template("/accounts/{account_id}/dlp/payload_log", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/profiles/custom.py b/src/cloudflare/resources/zero_trust/dlp/profiles/custom.py index 22ee9280b1c..069a84ff8e7 100644 --- a/src/cloudflare/resources/zero_trust/dlp/profiles/custom.py +++ b/src/cloudflare/resources/zero_trust/dlp/profiles/custom.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> CustomResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, ai_context_enabled: bool | Omit = omit, allowed_match_count: int | Omit = omit, @@ -96,12 +96,14 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[Profile], self._post( - f"/accounts/{account_id}/dlp/profiles/custom", + path_template("/accounts/{account_id}/dlp/profiles/custom", account_id=account_id), body=maybe_transform( { "name": name, @@ -136,7 +138,7 @@ def update( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, name: str, ai_context_enabled: bool | Omit = omit, allowed_match_count: Optional[int] | Omit = omit, @@ -187,6 +189,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: @@ -194,7 +198,11 @@ def update( return cast( Optional[Profile], self._put( - f"/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + account_id=account_id, + profile_id=profile_id, + ), body=maybe_transform( { "name": name, @@ -229,7 +237,7 @@ def delete( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -249,12 +257,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return self._delete( - f"/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/custom/{profile_id}", account_id=account_id, profile_id=profile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -269,7 +281,7 @@ def get( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -289,6 +301,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: @@ -296,7 +310,11 @@ def get( return cast( Optional[Profile], self._get( - f"/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + account_id=account_id, + profile_id=profile_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -334,7 +352,7 @@ def with_streaming_response(self) -> AsyncCustomResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, ai_context_enabled: bool | Omit = omit, allowed_match_count: int | Omit = omit, @@ -382,12 +400,14 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[Profile], await self._post( - f"/accounts/{account_id}/dlp/profiles/custom", + path_template("/accounts/{account_id}/dlp/profiles/custom", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -422,7 +442,7 @@ async def update( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, name: str, ai_context_enabled: bool | Omit = omit, allowed_match_count: Optional[int] | Omit = omit, @@ -473,6 +493,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: @@ -480,7 +502,11 @@ async def update( return cast( Optional[Profile], await self._put( - f"/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + account_id=account_id, + profile_id=profile_id, + ), body=await async_maybe_transform( { "name": name, @@ -515,7 +541,7 @@ async def delete( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -535,12 +561,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return await self._delete( - f"/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/custom/{profile_id}", account_id=account_id, profile_id=profile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -555,7 +585,7 @@ async def get( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -575,6 +605,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: @@ -582,7 +614,11 @@ async def get( return cast( Optional[Profile], await self._get( - f"/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/custom/{profile_id}", + account_id=account_id, + profile_id=profile_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/profiles/predefined.py b/src/cloudflare/resources/zero_trust/dlp/profiles/predefined.py index acd8781e73a..fcad7445f8a 100644 --- a/src/cloudflare/resources/zero_trust/dlp/profiles/predefined.py +++ b/src/cloudflare/resources/zero_trust/dlp/profiles/predefined.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,7 +48,7 @@ def update( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, ai_context_enabled: bool | Omit = omit, allowed_match_count: Optional[int] | Omit = omit, confidence_threshold: Optional[str] | Omit = omit, @@ -77,12 +77,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return self._put( - f"/accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config", + path_template( + "/accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config", + account_id=account_id, + profile_id=profile_id, + ), body=maybe_transform( { "ai_context_enabled": ai_context_enabled, @@ -108,7 +114,7 @@ def delete( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -129,12 +135,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return self._delete( - f"/accounts/{account_id}/dlp/profiles/predefined/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/predefined/{profile_id}", + account_id=account_id, + profile_id=profile_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -149,7 +161,7 @@ def get( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -170,12 +182,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return self._get( - f"/accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config", + path_template( + "/accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config", + account_id=account_id, + profile_id=profile_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -211,7 +229,7 @@ async def update( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, ai_context_enabled: bool | Omit = omit, allowed_match_count: Optional[int] | Omit = omit, confidence_threshold: Optional[str] | Omit = omit, @@ -240,12 +258,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return await self._put( - f"/accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config", + path_template( + "/accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config", + account_id=account_id, + profile_id=profile_id, + ), body=await async_maybe_transform( { "ai_context_enabled": ai_context_enabled, @@ -271,7 +295,7 @@ async def delete( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -292,12 +316,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return await self._delete( - f"/accounts/{account_id}/dlp/profiles/predefined/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/predefined/{profile_id}", + account_id=account_id, + profile_id=profile_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -312,7 +342,7 @@ async def get( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -333,12 +363,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") return await self._get( - f"/accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config", + path_template( + "/accounts/{account_id}/dlp/profiles/predefined/{profile_id}/config", + account_id=account_id, + profile_id=profile_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/profiles/profiles.py b/src/cloudflare/resources/zero_trust/dlp/profiles/profiles.py index cb224c7e480..439052c213a 100644 --- a/src/cloudflare/resources/zero_trust/dlp/profiles/profiles.py +++ b/src/cloudflare/resources/zero_trust/dlp/profiles/profiles.py @@ -15,7 +15,7 @@ AsyncCustomResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from .predefined import ( PredefinedResource, AsyncPredefinedResource, @@ -72,7 +72,7 @@ def with_streaming_response(self) -> ProfilesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, all: 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. @@ -96,10 +96,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/profiles", + path_template("/accounts/{account_id}/dlp/profiles", account_id=account_id), page=SyncSinglePage[Profile], options=make_request_options( extra_headers=extra_headers, @@ -115,7 +117,7 @@ def get( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -135,6 +137,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: @@ -142,7 +146,9 @@ def get( return cast( Optional[Profile], self._get( - f"/accounts/{account_id}/dlp/profiles/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/{profile_id}", account_id=account_id, profile_id=profile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -188,7 +194,7 @@ def with_streaming_response(self) -> AsyncProfilesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, all: 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. @@ -212,10 +218,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/dlp/profiles", + path_template("/accounts/{account_id}/dlp/profiles", account_id=account_id), page=AsyncSinglePage[Profile], options=make_request_options( extra_headers=extra_headers, @@ -231,7 +239,7 @@ async def get( self, profile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -251,6 +259,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not profile_id: @@ -258,7 +268,9 @@ async def get( return cast( Optional[Profile], await self._get( - f"/accounts/{account_id}/dlp/profiles/{profile_id}", + path_template( + "/accounts/{account_id}/dlp/profiles/{profile_id}", account_id=account_id, profile_id=profile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/dlp/settings.py b/src/cloudflare/resources/zero_trust/dlp/settings.py new file mode 100644 index 00000000000..4bea5d05912 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/dlp/settings.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, Optional, cast + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import path_template, 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.zero_trust.dlp import setting_edit_params, setting_update_params +from ....types.zero_trust.dlp.dlp_settings import DLPSettings + +__all__ = ["SettingsResource", "AsyncSettingsResource"] + + +class SettingsResource(SyncAPIResource): + @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) + + def update( + self, + *, + account_id: str | None = None, + ai_context_analysis: Optional[bool] | Omit = omit, + ocr: Optional[bool] | Omit = omit, + payload_logging: setting_update_params.PayloadLogging | 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[DLPSettings]: + """ + Missing fields are reset to initial (unconfigured) values. + + Args: + ai_context_analysis: Whether AI context analysis is enabled at the account level. + + ocr: Whether OCR is enabled at the account level. + + payload_logging: Request model for payload log settings within the DLP settings endpoint. Unlike + the legacy endpoint, null and missing are treated identically here (both mean + "not provided" for PATCH, "reset to default" for PUT). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._put( + path_template("/accounts/{account_id}/dlp/settings", account_id=account_id), + body=maybe_transform( + { + "ai_context_analysis": ai_context_analysis, + "ocr": ocr, + "payload_logging": payload_logging, + }, + setting_update_params.SettingUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DLPSettings]]._unwrapper, + ), + cast_to=cast(Type[Optional[DLPSettings]], ResultWrapper[DLPSettings]), + ) + + def delete( + self, + *, + account_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[DLPSettings]: + """ + Delete (reset) DLP account-level settings to initial values. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._delete( + path_template("/accounts/{account_id}/dlp/settings", account_id=account_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DLPSettings]]._unwrapper, + ), + cast_to=cast(Type[Optional[DLPSettings]], ResultWrapper[DLPSettings]), + ) + + def edit( + self, + *, + account_id: str | None = None, + ai_context_analysis: Optional[bool] | Omit = omit, + ocr: Optional[bool] | Omit = omit, + payload_logging: setting_edit_params.PayloadLogging | 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[DLPSettings]: + """ + Missing fields keep their existing values. + + Args: + ai_context_analysis: Whether AI context analysis is enabled at the account level. + + ocr: Whether OCR is enabled at the account level. + + payload_logging: Request model for payload log settings within the DLP settings endpoint. Unlike + the legacy endpoint, null and missing are treated identically here (both mean + "not provided" for PATCH, "reset to default" for PUT). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._patch( + path_template("/accounts/{account_id}/dlp/settings", account_id=account_id), + body=maybe_transform( + { + "ai_context_analysis": ai_context_analysis, + "ocr": ocr, + "payload_logging": payload_logging, + }, + setting_edit_params.SettingEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DLPSettings]]._unwrapper, + ), + cast_to=cast(Type[Optional[DLPSettings]], ResultWrapper[DLPSettings]), + ) + + def get( + self, + *, + account_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[DLPSettings]: + """ + Get DLP account-level settings. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + path_template("/accounts/{account_id}/dlp/settings", account_id=account_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DLPSettings]]._unwrapper, + ), + cast_to=cast(Type[Optional[DLPSettings]], ResultWrapper[DLPSettings]), + ) + + +class AsyncSettingsResource(AsyncAPIResource): + @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) + + async def update( + self, + *, + account_id: str | None = None, + ai_context_analysis: Optional[bool] | Omit = omit, + ocr: Optional[bool] | Omit = omit, + payload_logging: setting_update_params.PayloadLogging | 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[DLPSettings]: + """ + Missing fields are reset to initial (unconfigured) values. + + Args: + ai_context_analysis: Whether AI context analysis is enabled at the account level. + + ocr: Whether OCR is enabled at the account level. + + payload_logging: Request model for payload log settings within the DLP settings endpoint. Unlike + the legacy endpoint, null and missing are treated identically here (both mean + "not provided" for PATCH, "reset to default" for PUT). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._put( + path_template("/accounts/{account_id}/dlp/settings", account_id=account_id), + body=await async_maybe_transform( + { + "ai_context_analysis": ai_context_analysis, + "ocr": ocr, + "payload_logging": payload_logging, + }, + setting_update_params.SettingUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DLPSettings]]._unwrapper, + ), + cast_to=cast(Type[Optional[DLPSettings]], ResultWrapper[DLPSettings]), + ) + + async def delete( + self, + *, + account_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[DLPSettings]: + """ + Delete (reset) DLP account-level settings to initial values. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._delete( + path_template("/accounts/{account_id}/dlp/settings", account_id=account_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DLPSettings]]._unwrapper, + ), + cast_to=cast(Type[Optional[DLPSettings]], ResultWrapper[DLPSettings]), + ) + + async def edit( + self, + *, + account_id: str | None = None, + ai_context_analysis: Optional[bool] | Omit = omit, + ocr: Optional[bool] | Omit = omit, + payload_logging: setting_edit_params.PayloadLogging | 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[DLPSettings]: + """ + Missing fields keep their existing values. + + Args: + ai_context_analysis: Whether AI context analysis is enabled at the account level. + + ocr: Whether OCR is enabled at the account level. + + payload_logging: Request model for payload log settings within the DLP settings endpoint. Unlike + the legacy endpoint, null and missing are treated identically here (both mean + "not provided" for PATCH, "reset to default" for PUT). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._patch( + path_template("/accounts/{account_id}/dlp/settings", account_id=account_id), + body=await async_maybe_transform( + { + "ai_context_analysis": ai_context_analysis, + "ocr": ocr, + "payload_logging": payload_logging, + }, + setting_edit_params.SettingEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DLPSettings]]._unwrapper, + ), + cast_to=cast(Type[Optional[DLPSettings]], ResultWrapper[DLPSettings]), + ) + + async def get( + self, + *, + account_id: str | None = None, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[DLPSettings]: + """ + Get DLP account-level settings. + + 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 account_id is None: + account_id = self._client._get_account_id_path_param() + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + path_template("/accounts/{account_id}/dlp/settings", account_id=account_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DLPSettings]]._unwrapper, + ), + cast_to=cast(Type[Optional[DLPSettings]], ResultWrapper[DLPSettings]), + ) + + +class SettingsResourceWithRawResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + self.update = to_raw_response_wrapper( + settings.update, + ) + self.delete = to_raw_response_wrapper( + settings.delete, + ) + self.edit = to_raw_response_wrapper( + settings.edit, + ) + self.get = to_raw_response_wrapper( + settings.get, + ) + + +class AsyncSettingsResourceWithRawResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + self.update = async_to_raw_response_wrapper( + settings.update, + ) + self.delete = async_to_raw_response_wrapper( + settings.delete, + ) + self.edit = async_to_raw_response_wrapper( + settings.edit, + ) + self.get = async_to_raw_response_wrapper( + settings.get, + ) + + +class SettingsResourceWithStreamingResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + self.update = to_streamed_response_wrapper( + settings.update, + ) + self.delete = to_streamed_response_wrapper( + settings.delete, + ) + self.edit = to_streamed_response_wrapper( + settings.edit, + ) + self.get = to_streamed_response_wrapper( + settings.get, + ) + + +class AsyncSettingsResourceWithStreamingResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + self.update = async_to_streamed_response_wrapper( + settings.update, + ) + self.delete = async_to_streamed_response_wrapper( + settings.delete, + ) + self.edit = async_to_streamed_response_wrapper( + settings.edit, + ) + self.get = async_to_streamed_response_wrapper( + settings.get, + ) diff --git a/src/cloudflare/resources/zero_trust/gateway/app_types.py b/src/cloudflare/resources/zero_trust/gateway/app_types.py index 231d4edb066..383b817b48c 100644 --- a/src/cloudflare/resources/zero_trust/gateway/app_types.py +++ b/src/cloudflare/resources/zero_trust/gateway/app_types.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> AppTypesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -67,10 +68,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/app_types", + path_template("/accounts/{account_id}/gateway/app_types", account_id=account_id), page=SyncSinglePage[AppType], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -102,7 +105,7 @@ def with_streaming_response(self) -> AsyncAppTypesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -124,10 +127,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/app_types", + path_template("/accounts/{account_id}/gateway/app_types", account_id=account_id), page=AsyncSinglePage[AppType], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/gateway/audit_ssh_settings.py b/src/cloudflare/resources/zero_trust/gateway/audit_ssh_settings.py index 9a726288e7c..13652e47755 100644 --- a/src/cloudflare/resources/zero_trust/gateway/audit_ssh_settings.py +++ b/src/cloudflare/resources/zero_trust/gateway/audit_ssh_settings.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> AuditSSHSettingsResourceWithStreamingRespon def update( self, *, - account_id: str, + account_id: str | None = None, public_key: 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. @@ -72,10 +72,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/audit_ssh_settings", + path_template("/accounts/{account_id}/gateway/audit_ssh_settings", account_id=account_id), body=maybe_transform( {"public_key": public_key}, audit_ssh_setting_update_params.AuditSSHSettingUpdateParams ), @@ -92,7 +94,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -113,10 +115,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/audit_ssh_settings", + path_template("/accounts/{account_id}/gateway/audit_ssh_settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -130,7 +134,7 @@ def get( def rotate_seed( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -151,10 +155,12 @@ def rotate_seed( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/audit_ssh_settings/rotate_seed", + path_template("/accounts/{account_id}/gateway/audit_ssh_settings/rotate_seed", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -189,7 +195,7 @@ def with_streaming_response(self) -> AsyncAuditSSHSettingsResourceWithStreamingR async def update( self, *, - account_id: str, + account_id: str | None = None, public_key: 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. @@ -214,10 +220,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/audit_ssh_settings", + path_template("/accounts/{account_id}/gateway/audit_ssh_settings", account_id=account_id), body=await async_maybe_transform( {"public_key": public_key}, audit_ssh_setting_update_params.AuditSSHSettingUpdateParams ), @@ -234,7 +242,7 @@ async def update( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -255,10 +263,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/audit_ssh_settings", + path_template("/accounts/{account_id}/gateway/audit_ssh_settings", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -272,7 +282,7 @@ async def get( async def rotate_seed( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -293,10 +303,12 @@ async def rotate_seed( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/audit_ssh_settings/rotate_seed", + path_template("/accounts/{account_id}/gateway/audit_ssh_settings/rotate_seed", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/gateway/categories.py b/src/cloudflare/resources/zero_trust/gateway/categories.py index 4915deb1f2f..05bf664bbe8 100644 --- a/src/cloudflare/resources/zero_trust/gateway/categories.py +++ b/src/cloudflare/resources/zero_trust/gateway/categories.py @@ -5,6 +5,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -43,7 +44,7 @@ def with_streaming_response(self) -> CategoriesResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -65,10 +66,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/categories", + path_template("/accounts/{account_id}/gateway/categories", account_id=account_id), page=SyncSinglePage[Category], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -100,7 +103,7 @@ def with_streaming_response(self) -> AsyncCategoriesResourceWithStreamingRespons def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -122,10 +125,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/categories", + path_template("/accounts/{account_id}/gateway/categories", account_id=account_id), page=AsyncSinglePage[Category], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/gateway/certificates.py b/src/cloudflare/resources/zero_trust/gateway/certificates.py index e89207aa93d..14c5f82a093 100644 --- a/src/cloudflare/resources/zero_trust/gateway/certificates.py +++ b/src/cloudflare/resources/zero_trust/gateway/certificates.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -57,7 +57,7 @@ def with_streaming_response(self) -> CertificatesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, validity_period_days: 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. @@ -83,10 +83,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/certificates", + path_template("/accounts/{account_id}/gateway/certificates", account_id=account_id), body=maybe_transform( {"validity_period_days": validity_period_days}, certificate_create_params.CertificateCreateParams ), @@ -103,7 +105,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -123,10 +125,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/certificates", + path_template("/accounts/{account_id}/gateway/certificates", account_id=account_id), page=SyncSinglePage[CertificateListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -138,7 +142,7 @@ def delete( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -162,12 +166,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._delete( - f"/accounts/{account_id}/gateway/certificates/{certificate_id}", + path_template( + "/accounts/{account_id}/gateway/certificates/{certificate_id}", + account_id=account_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -182,7 +192,7 @@ def activate( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -205,12 +215,18 @@ def activate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._post( - f"/accounts/{account_id}/gateway/certificates/{certificate_id}/activate", + path_template( + "/accounts/{account_id}/gateway/certificates/{certificate_id}/activate", + account_id=account_id, + certificate_id=certificate_id, + ), body=maybe_transform(body, certificate_activate_params.CertificateActivateParams), options=make_request_options( extra_headers=extra_headers, @@ -226,7 +242,7 @@ def deactivate( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -249,12 +265,18 @@ def deactivate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._post( - f"/accounts/{account_id}/gateway/certificates/{certificate_id}/deactivate", + path_template( + "/accounts/{account_id}/gateway/certificates/{certificate_id}/deactivate", + account_id=account_id, + certificate_id=certificate_id, + ), body=maybe_transform(body, certificate_deactivate_params.CertificateDeactivateParams), options=make_request_options( extra_headers=extra_headers, @@ -270,7 +292,7 @@ def get( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -292,12 +314,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return self._get( - f"/accounts/{account_id}/gateway/certificates/{certificate_id}", + path_template( + "/accounts/{account_id}/gateway/certificates/{certificate_id}", + account_id=account_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -332,7 +360,7 @@ def with_streaming_response(self) -> AsyncCertificatesResourceWithStreamingRespo async def create( self, *, - account_id: str, + account_id: str | None = None, validity_period_days: 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. @@ -358,10 +386,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/certificates", + path_template("/accounts/{account_id}/gateway/certificates", account_id=account_id), body=await async_maybe_transform( {"validity_period_days": validity_period_days}, certificate_create_params.CertificateCreateParams ), @@ -378,7 +408,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -398,10 +428,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/certificates", + path_template("/accounts/{account_id}/gateway/certificates", account_id=account_id), page=AsyncSinglePage[CertificateListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -413,7 +445,7 @@ async def delete( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -437,12 +469,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._delete( - f"/accounts/{account_id}/gateway/certificates/{certificate_id}", + path_template( + "/accounts/{account_id}/gateway/certificates/{certificate_id}", + account_id=account_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -457,7 +495,7 @@ async def activate( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -480,12 +518,18 @@ async def activate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._post( - f"/accounts/{account_id}/gateway/certificates/{certificate_id}/activate", + path_template( + "/accounts/{account_id}/gateway/certificates/{certificate_id}/activate", + account_id=account_id, + certificate_id=certificate_id, + ), body=await async_maybe_transform(body, certificate_activate_params.CertificateActivateParams), options=make_request_options( extra_headers=extra_headers, @@ -501,7 +545,7 @@ async def deactivate( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, 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. @@ -524,12 +568,18 @@ async def deactivate( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._post( - f"/accounts/{account_id}/gateway/certificates/{certificate_id}/deactivate", + path_template( + "/accounts/{account_id}/gateway/certificates/{certificate_id}/deactivate", + account_id=account_id, + certificate_id=certificate_id, + ), body=await async_maybe_transform(body, certificate_deactivate_params.CertificateDeactivateParams), options=make_request_options( extra_headers=extra_headers, @@ -545,7 +595,7 @@ async def get( self, certificate_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -567,12 +617,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not certificate_id: raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") return await self._get( - f"/accounts/{account_id}/gateway/certificates/{certificate_id}", + path_template( + "/accounts/{account_id}/gateway/certificates/{certificate_id}", + account_id=account_id, + certificate_id=certificate_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/gateway/configurations/configurations.py b/src/cloudflare/resources/zero_trust/gateway/configurations/configurations.py index 1a19913db64..d48d5f01662 100755 --- a/src/cloudflare/resources/zero_trust/gateway/configurations/configurations.py +++ b/src/cloudflare/resources/zero_trust/gateway/configurations/configurations.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -65,7 +65,7 @@ def with_streaming_response(self) -> ConfigurationsResourceWithStreamingResponse def update( self, *, - account_id: str, + account_id: str | None = None, settings: GatewayConfigurationSettingsParam | 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. @@ -88,10 +88,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/configuration", + path_template("/accounts/{account_id}/gateway/configuration", account_id=account_id), body=maybe_transform({"settings": settings}, configuration_update_params.ConfigurationUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -106,7 +108,7 @@ def update( def edit( self, *, - account_id: str, + account_id: str | None = None, settings: GatewayConfigurationSettingsParam | 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. @@ -133,10 +135,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._patch( - f"/accounts/{account_id}/gateway/configuration", + path_template("/accounts/{account_id}/gateway/configuration", account_id=account_id), body=maybe_transform({"settings": settings}, configuration_edit_params.ConfigurationEditParams), options=make_request_options( extra_headers=extra_headers, @@ -151,7 +155,7 @@ def edit( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -171,10 +175,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/configuration", + path_template("/accounts/{account_id}/gateway/configuration", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -213,7 +219,7 @@ def with_streaming_response(self) -> AsyncConfigurationsResourceWithStreamingRes async def update( self, *, - account_id: str, + account_id: str | None = None, settings: GatewayConfigurationSettingsParam | 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. @@ -236,10 +242,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/configuration", + path_template("/accounts/{account_id}/gateway/configuration", account_id=account_id), body=await async_maybe_transform( {"settings": settings}, configuration_update_params.ConfigurationUpdateParams ), @@ -256,7 +264,7 @@ async def update( async def edit( self, *, - account_id: str, + account_id: str | None = None, settings: GatewayConfigurationSettingsParam | 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. @@ -283,10 +291,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._patch( - f"/accounts/{account_id}/gateway/configuration", + path_template("/accounts/{account_id}/gateway/configuration", account_id=account_id), body=await async_maybe_transform({"settings": settings}, configuration_edit_params.ConfigurationEditParams), options=make_request_options( extra_headers=extra_headers, @@ -301,7 +311,7 @@ async def edit( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -321,10 +331,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/configuration", + path_template("/accounts/{account_id}/gateway/configuration", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/gateway/configurations/custom_certificate.py b/src/cloudflare/resources/zero_trust/gateway/configurations/custom_certificate.py index 3107ec2510b..ff3d826b37b 100644 --- a/src/cloudflare/resources/zero_trust/gateway/configurations/custom_certificate.py +++ b/src/cloudflare/resources/zero_trust/gateway/configurations/custom_certificate.py @@ -8,6 +8,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def with_streaming_response(self) -> CustomCertificateResourceWithStreamingRespo def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,10 +67,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/configuration/custom_certificate", + path_template("/accounts/{account_id}/gateway/configuration/custom_certificate", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -101,7 +104,7 @@ def with_streaming_response(self) -> AsyncCustomCertificateResourceWithStreaming async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -121,10 +124,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/configuration/custom_certificate", + path_template("/accounts/{account_id}/gateway/configuration/custom_certificate", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/zero_trust/gateway/gateway.py b/src/cloudflare/resources/zero_trust/gateway/gateway.py index e4badcc9720..6dfa4f37913 100644 --- a/src/cloudflare/resources/zero_trust/gateway/gateway.py +++ b/src/cloudflare/resources/zero_trust/gateway/gateway.py @@ -31,6 +31,7 @@ AsyncPacfilesResourceWithStreamingResponse, ) from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from .app_types import ( AppTypesResource, AsyncAppTypesResource, @@ -178,7 +179,7 @@ def with_streaming_response(self) -> GatewayResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -198,10 +199,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway", + path_template("/accounts/{account_id}/gateway", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -215,7 +218,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -235,10 +238,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway", + path_template("/accounts/{account_id}/gateway", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -317,7 +322,7 @@ def with_streaming_response(self) -> AsyncGatewayResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -337,10 +342,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway", + path_template("/accounts/{account_id}/gateway", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -354,7 +361,7 @@ async def create( async def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -374,10 +381,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway", + path_template("/accounts/{account_id}/gateway", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/gateway/lists/items.py b/src/cloudflare/resources/zero_trust/gateway/lists/items.py index 8dcfa4d317d..2a29b1b6b26 100644 --- a/src/cloudflare/resources/zero_trust/gateway/lists/items.py +++ b/src/cloudflare/resources/zero_trust/gateway/lists/items.py @@ -5,6 +5,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -44,7 +45,7 @@ def list( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,12 +67,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._get_api_list( - f"/accounts/{account_id}/gateway/lists/{list_id}/items", + path_template( + "/accounts/{account_id}/gateway/lists/{list_id}/items", account_id=account_id, list_id=list_id + ), page=SyncSinglePage[ItemListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -104,7 +109,7 @@ def list( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -126,12 +131,16 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._get_api_list( - f"/accounts/{account_id}/gateway/lists/{list_id}/items", + path_template( + "/accounts/{account_id}/gateway/lists/{list_id}/items", account_id=account_id, list_id=list_id + ), page=AsyncSinglePage[ItemListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/gateway/lists/lists.py b/src/cloudflare/resources/zero_trust/gateway/lists/lists.py index 014a1b838cb..4706f33c4c6 100644 --- a/src/cloudflare/resources/zero_trust/gateway/lists/lists.py +++ b/src/cloudflare/resources/zero_trust/gateway/lists/lists.py @@ -16,7 +16,7 @@ AsyncItemsResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -62,7 +62,7 @@ def with_streaming_response(self) -> ListsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, type: Literal["SERIAL", "URL", "DOMAIN", "EMAIL", "IP", "CATEGORY", "LOCATION", "DEVICE"], description: str | Omit = omit, @@ -94,10 +94,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/lists", + path_template("/accounts/{account_id}/gateway/lists", account_id=account_id), body=maybe_transform( { "name": name, @@ -121,7 +123,7 @@ def update( self, list_id: str, *, - account_id: str, + account_id: str | None = None, name: str, description: str | Omit = omit, items: Iterable[list_update_params.Item] | Omit = omit, @@ -154,12 +156,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._put( - f"/accounts/{account_id}/gateway/lists/{list_id}", + path_template("/accounts/{account_id}/gateway/lists/{list_id}", account_id=account_id, list_id=list_id), body=maybe_transform( { "name": name, @@ -181,7 +185,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, type: Literal["SERIAL", "URL", "DOMAIN", "EMAIL", "IP", "CATEGORY", "LOCATION", "DEVICE"] | 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. @@ -204,10 +208,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/lists", + path_template("/accounts/{account_id}/gateway/lists", account_id=account_id), page=SyncSinglePage[GatewayList], options=make_request_options( extra_headers=extra_headers, @@ -223,7 +229,7 @@ def delete( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -245,12 +251,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._delete( - f"/accounts/{account_id}/gateway/lists/{list_id}", + path_template("/accounts/{account_id}/gateway/lists/{list_id}", account_id=account_id, list_id=list_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -265,7 +273,7 @@ def edit( self, list_id: str, *, - account_id: str, + account_id: str | None = None, append: Iterable[list_edit_params.Append] | Omit = omit, remove: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -293,12 +301,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._patch( - f"/accounts/{account_id}/gateway/lists/{list_id}", + path_template("/accounts/{account_id}/gateway/lists/{list_id}", account_id=account_id, list_id=list_id), body=maybe_transform( { "append": append, @@ -320,7 +330,7 @@ def get( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -342,12 +352,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return self._get( - f"/accounts/{account_id}/gateway/lists/{list_id}", + path_template("/accounts/{account_id}/gateway/lists/{list_id}", account_id=account_id, list_id=list_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -386,7 +398,7 @@ def with_streaming_response(self) -> AsyncListsResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, type: Literal["SERIAL", "URL", "DOMAIN", "EMAIL", "IP", "CATEGORY", "LOCATION", "DEVICE"], description: str | Omit = omit, @@ -418,10 +430,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/lists", + path_template("/accounts/{account_id}/gateway/lists", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -445,7 +459,7 @@ async def update( self, list_id: str, *, - account_id: str, + account_id: str | None = None, name: str, description: str | Omit = omit, items: Iterable[list_update_params.Item] | Omit = omit, @@ -478,12 +492,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._put( - f"/accounts/{account_id}/gateway/lists/{list_id}", + path_template("/accounts/{account_id}/gateway/lists/{list_id}", account_id=account_id, list_id=list_id), body=await async_maybe_transform( { "name": name, @@ -505,7 +521,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, type: Literal["SERIAL", "URL", "DOMAIN", "EMAIL", "IP", "CATEGORY", "LOCATION", "DEVICE"] | 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. @@ -528,10 +544,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/lists", + path_template("/accounts/{account_id}/gateway/lists", account_id=account_id), page=AsyncSinglePage[GatewayList], options=make_request_options( extra_headers=extra_headers, @@ -547,7 +565,7 @@ async def delete( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -569,12 +587,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._delete( - f"/accounts/{account_id}/gateway/lists/{list_id}", + path_template("/accounts/{account_id}/gateway/lists/{list_id}", account_id=account_id, list_id=list_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -589,7 +609,7 @@ async def edit( self, list_id: str, *, - account_id: str, + account_id: str | None = None, append: Iterable[list_edit_params.Append] | Omit = omit, remove: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -617,12 +637,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._patch( - f"/accounts/{account_id}/gateway/lists/{list_id}", + path_template("/accounts/{account_id}/gateway/lists/{list_id}", account_id=account_id, list_id=list_id), body=await async_maybe_transform( { "append": append, @@ -644,7 +666,7 @@ async def get( self, list_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -666,12 +688,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not list_id: raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}") return await self._get( - f"/accounts/{account_id}/gateway/lists/{list_id}", + path_template("/accounts/{account_id}/gateway/lists/{list_id}", account_id=account_id, list_id=list_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/gateway/locations.py b/src/cloudflare/resources/zero_trust/gateway/locations.py index c3adeec7b63..702141f159f 100644 --- a/src/cloudflare/resources/zero_trust/gateway/locations.py +++ b/src/cloudflare/resources/zero_trust/gateway/locations.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -49,7 +49,7 @@ def with_streaming_response(self) -> LocationsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, client_default: bool | Omit = omit, dns_destination_ips_id: str | Omit = omit, @@ -93,10 +93,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/locations", + path_template("/accounts/{account_id}/gateway/locations", account_id=account_id), body=maybe_transform( { "name": name, @@ -122,7 +124,7 @@ def update( self, location_id: str, *, - account_id: str, + account_id: str | None = None, name: str, client_default: bool | Omit = omit, dns_destination_ips_id: str | Omit = omit, @@ -166,12 +168,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not location_id: raise ValueError(f"Expected a non-empty value for `location_id` but received {location_id!r}") return self._put( - f"/accounts/{account_id}/gateway/locations/{location_id}", + path_template( + "/accounts/{account_id}/gateway/locations/{location_id}", account_id=account_id, location_id=location_id + ), body=maybe_transform( { "name": name, @@ -196,7 +202,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -216,10 +222,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/locations", + path_template("/accounts/{account_id}/gateway/locations", account_id=account_id), page=SyncSinglePage[Location], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -231,7 +239,7 @@ def delete( self, location_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -251,12 +259,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not location_id: raise ValueError(f"Expected a non-empty value for `location_id` but received {location_id!r}") return self._delete( - f"/accounts/{account_id}/gateway/locations/{location_id}", + path_template( + "/accounts/{account_id}/gateway/locations/{location_id}", account_id=account_id, location_id=location_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -271,7 +283,7 @@ def get( self, location_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -291,12 +303,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not location_id: raise ValueError(f"Expected a non-empty value for `location_id` but received {location_id!r}") return self._get( - f"/accounts/{account_id}/gateway/locations/{location_id}", + path_template( + "/accounts/{account_id}/gateway/locations/{location_id}", account_id=account_id, location_id=location_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -331,7 +347,7 @@ def with_streaming_response(self) -> AsyncLocationsResourceWithStreamingResponse async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, client_default: bool | Omit = omit, dns_destination_ips_id: str | Omit = omit, @@ -375,10 +391,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/locations", + path_template("/accounts/{account_id}/gateway/locations", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -404,7 +422,7 @@ async def update( self, location_id: str, *, - account_id: str, + account_id: str | None = None, name: str, client_default: bool | Omit = omit, dns_destination_ips_id: str | Omit = omit, @@ -448,12 +466,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not location_id: raise ValueError(f"Expected a non-empty value for `location_id` but received {location_id!r}") return await self._put( - f"/accounts/{account_id}/gateway/locations/{location_id}", + path_template( + "/accounts/{account_id}/gateway/locations/{location_id}", account_id=account_id, location_id=location_id + ), body=await async_maybe_transform( { "name": name, @@ -478,7 +500,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -498,10 +520,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/locations", + path_template("/accounts/{account_id}/gateway/locations", account_id=account_id), page=AsyncSinglePage[Location], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -513,7 +537,7 @@ async def delete( self, location_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -533,12 +557,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not location_id: raise ValueError(f"Expected a non-empty value for `location_id` but received {location_id!r}") return await self._delete( - f"/accounts/{account_id}/gateway/locations/{location_id}", + path_template( + "/accounts/{account_id}/gateway/locations/{location_id}", account_id=account_id, location_id=location_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -553,7 +581,7 @@ async def get( self, location_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -573,12 +601,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not location_id: raise ValueError(f"Expected a non-empty value for `location_id` but received {location_id!r}") return await self._get( - f"/accounts/{account_id}/gateway/locations/{location_id}", + path_template( + "/accounts/{account_id}/gateway/locations/{location_id}", account_id=account_id, location_id=location_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/gateway/logging.py b/src/cloudflare/resources/zero_trust/gateway/logging.py index f18afc08f91..0e324913b98 100644 --- a/src/cloudflare/resources/zero_trust/gateway/logging.py +++ b/src/cloudflare/resources/zero_trust/gateway/logging.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> LoggingResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, redact_pii: bool | Omit = omit, settings_by_rule_type: logging_update_params.SettingsByRuleType | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -75,10 +75,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/logging", + path_template("/accounts/{account_id}/gateway/logging", account_id=account_id), body=maybe_transform( { "redact_pii": redact_pii, @@ -99,7 +101,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -119,10 +121,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/logging", + path_template("/accounts/{account_id}/gateway/logging", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -157,7 +161,7 @@ def with_streaming_response(self) -> AsyncLoggingResourceWithStreamingResponse: async def update( self, *, - account_id: str, + account_id: str | None = None, redact_pii: bool | Omit = omit, settings_by_rule_type: logging_update_params.SettingsByRuleType | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -185,10 +189,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/logging", + path_template("/accounts/{account_id}/gateway/logging", account_id=account_id), body=await async_maybe_transform( { "redact_pii": redact_pii, @@ -209,7 +215,7 @@ async def update( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -229,10 +235,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/logging", + path_template("/accounts/{account_id}/gateway/logging", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/gateway/pacfiles.py b/src/cloudflare/resources/zero_trust/gateway/pacfiles.py index e35cc351c4e..87c374d45df 100644 --- a/src/cloudflare/resources/zero_trust/gateway/pacfiles.py +++ b/src/cloudflare/resources/zero_trust/gateway/pacfiles.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> PacfilesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, contents: str, name: str, description: str | Omit = omit, @@ -84,10 +84,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/pacfiles", + path_template("/accounts/{account_id}/gateway/pacfiles", account_id=account_id), body=maybe_transform( { "contents": contents, @@ -111,7 +113,7 @@ def update( self, pacfile_id: str, *, - account_id: str, + account_id: str | None = None, contents: str, description: str, name: str, @@ -140,12 +142,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pacfile_id: raise ValueError(f"Expected a non-empty value for `pacfile_id` but received {pacfile_id!r}") return self._put( - f"/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", + path_template( + "/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", account_id=account_id, pacfile_id=pacfile_id + ), body=maybe_transform( { "contents": contents, @@ -167,7 +173,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -187,10 +193,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/pacfiles", + path_template("/accounts/{account_id}/gateway/pacfiles", account_id=account_id), page=SyncSinglePage[PacfileListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -202,7 +210,7 @@ def delete( self, pacfile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -222,12 +230,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pacfile_id: raise ValueError(f"Expected a non-empty value for `pacfile_id` but received {pacfile_id!r}") return self._delete( - f"/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", + path_template( + "/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", account_id=account_id, pacfile_id=pacfile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -242,7 +254,7 @@ def get( self, pacfile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -262,12 +274,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pacfile_id: raise ValueError(f"Expected a non-empty value for `pacfile_id` but received {pacfile_id!r}") return self._get( - f"/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", + path_template( + "/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", account_id=account_id, pacfile_id=pacfile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -302,7 +318,7 @@ def with_streaming_response(self) -> AsyncPacfilesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, contents: str, name: str, description: str | Omit = omit, @@ -335,10 +351,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/pacfiles", + path_template("/accounts/{account_id}/gateway/pacfiles", account_id=account_id), body=await async_maybe_transform( { "contents": contents, @@ -362,7 +380,7 @@ async def update( self, pacfile_id: str, *, - account_id: str, + account_id: str | None = None, contents: str, description: str, name: str, @@ -391,12 +409,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pacfile_id: raise ValueError(f"Expected a non-empty value for `pacfile_id` but received {pacfile_id!r}") return await self._put( - f"/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", + path_template( + "/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", account_id=account_id, pacfile_id=pacfile_id + ), body=await async_maybe_transform( { "contents": contents, @@ -418,7 +440,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -438,10 +460,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/pacfiles", + path_template("/accounts/{account_id}/gateway/pacfiles", account_id=account_id), page=AsyncSinglePage[PacfileListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -453,7 +477,7 @@ async def delete( self, pacfile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -473,12 +497,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pacfile_id: raise ValueError(f"Expected a non-empty value for `pacfile_id` but received {pacfile_id!r}") return await self._delete( - f"/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", + path_template( + "/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", account_id=account_id, pacfile_id=pacfile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -493,7 +521,7 @@ async def get( self, pacfile_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -513,12 +541,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not pacfile_id: raise ValueError(f"Expected a non-empty value for `pacfile_id` but received {pacfile_id!r}") return await self._get( - f"/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", + path_template( + "/accounts/{account_id}/gateway/pacfiles/{pacfile_id}", account_id=account_id, pacfile_id=pacfile_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py b/src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py index 895c360e0e2..58288c2d62b 100644 --- a/src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py +++ b/src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py @@ -8,7 +8,7 @@ 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 ...._utils import path_template, required_args, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> ProxyEndpointsResourceWithStreamingResponse def create( self, *, - account_id: str, + account_id: str | None = None, name: str, kind: Literal["ip"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -83,7 +83,7 @@ def create( def create( self, *, - account_id: str, + account_id: str | None = None, kind: Literal["identity"], name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -111,11 +111,11 @@ def create( """ ... - @required_args(["account_id", "name"], ["account_id", "kind", "name"]) + @required_args(["name"], ["kind", "name"]) def create( self, *, - account_id: str, + account_id: str | None = None, name: str, kind: Literal["ip"] | Literal["identity"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -125,12 +125,14 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ProxyEndpoint]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[ProxyEndpoint], self._post( - f"/accounts/{account_id}/gateway/proxy_endpoints", + path_template("/accounts/{account_id}/gateway/proxy_endpoints", account_id=account_id), body=maybe_transform( { "name": name, @@ -154,7 +156,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -174,10 +176,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/proxy_endpoints", + path_template("/accounts/{account_id}/gateway/proxy_endpoints", account_id=account_id), page=SyncSinglePage[ProxyEndpoint], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -189,7 +193,7 @@ def delete( self, proxy_endpoint_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -209,12 +213,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not proxy_endpoint_id: raise ValueError(f"Expected a non-empty value for `proxy_endpoint_id` but received {proxy_endpoint_id!r}") return self._delete( - f"/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + path_template( + "/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + account_id=account_id, + proxy_endpoint_id=proxy_endpoint_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -229,7 +239,7 @@ def edit( self, proxy_endpoint_id: str, *, - account_id: str, + account_id: str | None = None, ips: SequenceNotStr[GatewayIPs] | 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. @@ -255,6 +265,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not proxy_endpoint_id: @@ -262,7 +274,11 @@ def edit( return cast( Optional[ProxyEndpoint], self._patch( - f"/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + path_template( + "/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + account_id=account_id, + proxy_endpoint_id=proxy_endpoint_id, + ), body=maybe_transform( { "ips": ips, @@ -287,7 +303,7 @@ def get( self, proxy_endpoint_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -307,6 +323,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not proxy_endpoint_id: @@ -314,7 +332,11 @@ def get( return cast( Optional[ProxyEndpoint], self._get( - f"/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + path_template( + "/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + account_id=account_id, + proxy_endpoint_id=proxy_endpoint_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -353,7 +375,7 @@ def with_streaming_response(self) -> AsyncProxyEndpointsResourceWithStreamingRes async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, kind: Literal["ip"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -385,7 +407,7 @@ async def create( async def create( self, *, - account_id: str, + account_id: str | None = None, kind: Literal["identity"], name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -413,11 +435,11 @@ async def create( """ ... - @required_args(["account_id", "name"], ["account_id", "kind", "name"]) + @required_args(["name"], ["kind", "name"]) async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, kind: Literal["ip"] | Literal["identity"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -427,12 +449,14 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[ProxyEndpoint]: + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( Optional[ProxyEndpoint], await self._post( - f"/accounts/{account_id}/gateway/proxy_endpoints", + path_template("/accounts/{account_id}/gateway/proxy_endpoints", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -456,7 +480,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -476,10 +500,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/proxy_endpoints", + path_template("/accounts/{account_id}/gateway/proxy_endpoints", account_id=account_id), page=AsyncSinglePage[ProxyEndpoint], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -491,7 +517,7 @@ async def delete( self, proxy_endpoint_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -511,12 +537,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not proxy_endpoint_id: raise ValueError(f"Expected a non-empty value for `proxy_endpoint_id` but received {proxy_endpoint_id!r}") return await self._delete( - f"/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + path_template( + "/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + account_id=account_id, + proxy_endpoint_id=proxy_endpoint_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -531,7 +563,7 @@ async def edit( self, proxy_endpoint_id: str, *, - account_id: str, + account_id: str | None = None, ips: SequenceNotStr[GatewayIPs] | 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. @@ -557,6 +589,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not proxy_endpoint_id: @@ -564,7 +598,11 @@ async def edit( return cast( Optional[ProxyEndpoint], await self._patch( - f"/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + path_template( + "/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + account_id=account_id, + proxy_endpoint_id=proxy_endpoint_id, + ), body=await async_maybe_transform( { "ips": ips, @@ -589,7 +627,7 @@ async def get( self, proxy_endpoint_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -609,6 +647,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not proxy_endpoint_id: @@ -616,7 +656,11 @@ async def get( return cast( Optional[ProxyEndpoint], await self._get( - f"/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + path_template( + "/accounts/{account_id}/gateway/proxy_endpoints/{proxy_endpoint_id}", + account_id=account_id, + proxy_endpoint_id=proxy_endpoint_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/gateway/rules.py b/src/cloudflare/resources/zero_trust/gateway/rules.py index 2ece837eae3..f3d4299f341 100644 --- a/src/cloudflare/resources/zero_trust/gateway/rules.py +++ b/src/cloudflare/resources/zero_trust/gateway/rules.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> RulesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, action: Literal[ "on", "off", @@ -146,10 +146,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/rules", + path_template("/accounts/{account_id}/gateway/rules", account_id=account_id), body=maybe_transform( { "action": action, @@ -181,7 +183,7 @@ def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal[ "on", "off", @@ -277,12 +279,14 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._put( - f"/accounts/{account_id}/gateway/rules/{rule_id}", + path_template("/accounts/{account_id}/gateway/rules/{rule_id}", account_id=account_id, rule_id=rule_id), body=maybe_transform( { "action": action, @@ -313,7 +317,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -333,10 +337,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/rules", + path_template("/accounts/{account_id}/gateway/rules", account_id=account_id), page=SyncSinglePage[GatewayRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -348,7 +354,7 @@ def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -370,12 +376,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._delete( - f"/accounts/{account_id}/gateway/rules/{rule_id}", + path_template("/accounts/{account_id}/gateway/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -390,7 +398,7 @@ def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -412,12 +420,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._get( - f"/accounts/{account_id}/gateway/rules/{rule_id}", + path_template("/accounts/{account_id}/gateway/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -431,7 +441,7 @@ def get( def list_tenant( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -452,10 +462,12 @@ def list_tenant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/rules/tenant", + path_template("/accounts/{account_id}/gateway/rules/tenant", account_id=account_id), page=SyncSinglePage[GatewayRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -467,7 +479,7 @@ def reset_expiration( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -491,12 +503,18 @@ def reset_expiration( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return self._post( - f"/accounts/{account_id}/gateway/rules/{rule_id}/reset_expiration", + path_template( + "/accounts/{account_id}/gateway/rules/{rule_id}/reset_expiration", + account_id=account_id, + rule_id=rule_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -531,7 +549,7 @@ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, action: Literal[ "on", "off", @@ -625,10 +643,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/rules", + path_template("/accounts/{account_id}/gateway/rules", account_id=account_id), body=await async_maybe_transform( { "action": action, @@ -660,7 +680,7 @@ async def update( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, action: Literal[ "on", "off", @@ -756,12 +776,14 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._put( - f"/accounts/{account_id}/gateway/rules/{rule_id}", + path_template("/accounts/{account_id}/gateway/rules/{rule_id}", account_id=account_id, rule_id=rule_id), body=await async_maybe_transform( { "action": action, @@ -792,7 +814,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -812,10 +834,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/rules", + path_template("/accounts/{account_id}/gateway/rules", account_id=account_id), page=AsyncSinglePage[GatewayRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -827,7 +851,7 @@ async def delete( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -849,12 +873,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._delete( - f"/accounts/{account_id}/gateway/rules/{rule_id}", + path_template("/accounts/{account_id}/gateway/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -869,7 +895,7 @@ async def get( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -891,12 +917,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._get( - f"/accounts/{account_id}/gateway/rules/{rule_id}", + path_template("/accounts/{account_id}/gateway/rules/{rule_id}", account_id=account_id, rule_id=rule_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -910,7 +938,7 @@ async def get( def list_tenant( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -931,10 +959,12 @@ def list_tenant( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/gateway/rules/tenant", + path_template("/accounts/{account_id}/gateway/rules/tenant", account_id=account_id), page=AsyncSinglePage[GatewayRule], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -946,7 +976,7 @@ async def reset_expiration( self, rule_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -970,12 +1000,18 @@ async def reset_expiration( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") return await self._post( - f"/accounts/{account_id}/gateway/rules/{rule_id}/reset_expiration", + path_template( + "/accounts/{account_id}/gateway/rules/{rule_id}/reset_expiration", + account_id=account_id, + rule_id=rule_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/identity_providers/identity_providers.py b/src/cloudflare/resources/zero_trust/identity_providers/identity_providers.py index ca7fdc64a04..506bb5d8ff1 100644 --- a/src/cloudflare/resources/zero_trust/identity_providers/identity_providers.py +++ b/src/cloudflare/resources/zero_trust/identity_providers/identity_providers.py @@ -8,7 +8,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import required_args, maybe_transform, async_maybe_transform +from ...._utils import path_template, required_args, maybe_transform, async_maybe_transform from .scim.scim import ( SCIMResource, AsyncSCIMResource, @@ -75,8 +75,8 @@ def create( config: identity_provider_create_params.AzureADConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -123,8 +123,8 @@ def create( config: identity_provider_create_params.AccessCentrifyConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -171,8 +171,8 @@ def create( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -219,8 +219,8 @@ def create( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -267,8 +267,8 @@ def create( config: identity_provider_create_params.AccessGoogleConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -315,8 +315,8 @@ def create( config: identity_provider_create_params.AccessGoogleAppsConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -363,8 +363,8 @@ def create( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -411,8 +411,8 @@ def create( config: identity_provider_create_params.AccessOIDCConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -459,8 +459,8 @@ def create( config: identity_provider_create_params.AccessOktaConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -507,8 +507,8 @@ def create( config: identity_provider_create_params.AccessOneloginConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -555,8 +555,8 @@ def create( config: identity_provider_create_params.AccessPingoneConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -603,8 +603,8 @@ def create( config: identity_provider_create_params.AccessSAMLConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -651,8 +651,8 @@ def create( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -699,8 +699,8 @@ def create( config: identity_provider_create_params.AccessOnetimepinConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -757,8 +757,8 @@ def create( | identity_provider_create_params.AccessOnetimepinConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -767,6 +767,10 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[IdentityProvider]: + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -782,7 +786,11 @@ def create( return cast( Optional[IdentityProvider], self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "config": config, @@ -813,8 +821,8 @@ def update( config: identity_provider_update_params.AzureADConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -864,8 +872,8 @@ def update( config: identity_provider_update_params.AccessCentrifyConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -915,8 +923,8 @@ def update( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -966,8 +974,8 @@ def update( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1017,8 +1025,8 @@ def update( config: identity_provider_update_params.AccessGoogleConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1068,8 +1076,8 @@ def update( config: identity_provider_update_params.AccessGoogleAppsConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1119,8 +1127,8 @@ def update( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1170,8 +1178,8 @@ def update( config: identity_provider_update_params.AccessOIDCConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1221,8 +1229,8 @@ def update( config: identity_provider_update_params.AccessOktaConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1272,8 +1280,8 @@ def update( config: identity_provider_update_params.AccessOneloginConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1323,8 +1331,8 @@ def update( config: identity_provider_update_params.AccessPingoneConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1374,8 +1382,8 @@ def update( config: identity_provider_update_params.AccessSAMLConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1425,8 +1433,8 @@ def update( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1476,8 +1484,8 @@ def update( config: identity_provider_update_params.AccessOnetimepinConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1537,8 +1545,8 @@ def update( | identity_provider_update_params.AccessOnetimepinConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1551,6 +1559,10 @@ def update( raise ValueError( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1566,7 +1578,12 @@ def update( return cast( Optional[IdentityProvider], self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + identity_provider_id=identity_provider_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "config": config, @@ -1592,8 +1609,8 @@ def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, scim_enabled: str | Omit = omit, @@ -1627,6 +1644,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1640,7 +1661,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=SyncV4PagePaginationArray[IdentityProviderListResponse], options=make_request_options( extra_headers=extra_headers, @@ -1665,8 +1690,8 @@ def delete( self, identity_provider_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1696,6 +1721,10 @@ def delete( raise ValueError( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1709,7 +1738,12 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + identity_provider_id=identity_provider_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1724,8 +1758,8 @@ def get( self, identity_provider_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -1755,6 +1789,10 @@ def get( raise ValueError( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1770,7 +1808,12 @@ def get( return cast( Optional[IdentityProvider], self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + identity_provider_id=identity_provider_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1816,8 +1859,8 @@ async def create( config: identity_provider_create_params.AzureADConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1864,8 +1907,8 @@ async def create( config: identity_provider_create_params.AccessCentrifyConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1912,8 +1955,8 @@ async def create( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -1960,8 +2003,8 @@ async def create( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2008,8 +2051,8 @@ async def create( config: identity_provider_create_params.AccessGoogleConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2056,8 +2099,8 @@ async def create( config: identity_provider_create_params.AccessGoogleAppsConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2104,8 +2147,8 @@ async def create( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2152,8 +2195,8 @@ async def create( config: identity_provider_create_params.AccessOIDCConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2200,8 +2243,8 @@ async def create( config: identity_provider_create_params.AccessOktaConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2248,8 +2291,8 @@ async def create( config: identity_provider_create_params.AccessOneloginConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2296,8 +2339,8 @@ async def create( config: identity_provider_create_params.AccessPingoneConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2344,8 +2387,8 @@ async def create( config: identity_provider_create_params.AccessSAMLConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2392,8 +2435,8 @@ async def create( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2440,8 +2483,8 @@ async def create( config: identity_provider_create_params.AccessOnetimepinConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2498,8 +2541,8 @@ async def create( | identity_provider_create_params.AccessOnetimepinConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2508,6 +2551,10 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[IdentityProvider]: + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -2523,7 +2570,11 @@ async def create( return cast( Optional[IdentityProvider], await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "config": config, @@ -2554,8 +2605,8 @@ async def update( config: identity_provider_update_params.AzureADConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2605,8 +2656,8 @@ async def update( config: identity_provider_update_params.AccessCentrifyConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2656,8 +2707,8 @@ async def update( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2707,8 +2758,8 @@ async def update( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2758,8 +2809,8 @@ async def update( config: identity_provider_update_params.AccessGoogleConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2809,8 +2860,8 @@ async def update( config: identity_provider_update_params.AccessGoogleAppsConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2860,8 +2911,8 @@ async def update( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2911,8 +2962,8 @@ async def update( config: identity_provider_update_params.AccessOIDCConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -2962,8 +3013,8 @@ async def update( config: identity_provider_update_params.AccessOktaConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -3013,8 +3064,8 @@ async def update( config: identity_provider_update_params.AccessOneloginConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -3064,8 +3115,8 @@ async def update( config: identity_provider_update_params.AccessPingoneConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -3115,8 +3166,8 @@ async def update( config: identity_provider_update_params.AccessSAMLConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -3166,8 +3217,8 @@ async def update( config: GenericOAuthConfigParam, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -3217,8 +3268,8 @@ async def update( config: identity_provider_update_params.AccessOnetimepinConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -3278,8 +3329,8 @@ async def update( | identity_provider_update_params.AccessOnetimepinConfig, name: str, type: IdentityProviderType, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, scim_config: IdentityProviderSCIMConfigParam | 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. @@ -3292,6 +3343,10 @@ async def update( raise ValueError( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3307,7 +3362,12 @@ async def update( return cast( Optional[IdentityProvider], await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + identity_provider_id=identity_provider_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "config": config, @@ -3333,8 +3393,8 @@ async def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, page: int | Omit = omit, per_page: int | Omit = omit, scim_enabled: str | Omit = omit, @@ -3368,6 +3428,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3381,7 +3445,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), page=AsyncV4PagePaginationArray[IdentityProviderListResponse], options=make_request_options( extra_headers=extra_headers, @@ -3406,8 +3474,8 @@ async def delete( self, identity_provider_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -3437,6 +3505,10 @@ async def delete( raise ValueError( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3450,7 +3522,12 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + identity_provider_id=identity_provider_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -3465,8 +3542,8 @@ async def get( self, identity_provider_id: str, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -3496,6 +3573,10 @@ async def get( raise ValueError( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3511,7 +3592,12 @@ async def get( return cast( Optional[IdentityProvider], await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + identity_provider_id=identity_provider_id, + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/identity_providers/scim/groups.py b/src/cloudflare/resources/zero_trust/identity_providers/scim/groups.py index 306e7a45343..9ff4766eb32 100644 --- a/src/cloudflare/resources/zero_trust/identity_providers/scim/groups.py +++ b/src/cloudflare/resources/zero_trust/identity_providers/scim/groups.py @@ -5,7 +5,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +46,7 @@ def list( self, identity_provider_id: str, *, - account_id: str, + account_id: str | None = None, cf_resource_id: str | Omit = omit, idp_resource_id: str | Omit = omit, name: str | Omit = omit, @@ -88,6 +88,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identity_provider_id: @@ -95,7 +97,11 @@ def list( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) return self._get_api_list( - f"/accounts/{account_id}/access/identity_providers/{identity_provider_id}/scim/groups", + path_template( + "/accounts/{account_id}/access/identity_providers/{identity_provider_id}/scim/groups", + account_id=account_id, + identity_provider_id=identity_provider_id, + ), page=SyncV4PagePaginationArray[ZeroTrustGroup], options=make_request_options( extra_headers=extra_headers, @@ -141,7 +147,7 @@ def list( self, identity_provider_id: str, *, - account_id: str, + account_id: str | None = None, cf_resource_id: str | Omit = omit, idp_resource_id: str | Omit = omit, name: str | Omit = omit, @@ -183,6 +189,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identity_provider_id: @@ -190,7 +198,11 @@ def list( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) return self._get_api_list( - f"/accounts/{account_id}/access/identity_providers/{identity_provider_id}/scim/groups", + path_template( + "/accounts/{account_id}/access/identity_providers/{identity_provider_id}/scim/groups", + account_id=account_id, + identity_provider_id=identity_provider_id, + ), page=AsyncV4PagePaginationArray[ZeroTrustGroup], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/identity_providers/scim/users.py b/src/cloudflare/resources/zero_trust/identity_providers/scim/users.py index 3f1736acb2a..46e4d4d3e12 100644 --- a/src/cloudflare/resources/zero_trust/identity_providers/scim/users.py +++ b/src/cloudflare/resources/zero_trust/identity_providers/scim/users.py @@ -5,7 +5,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +46,7 @@ def list( self, identity_provider_id: str, *, - account_id: str, + account_id: str | None = None, cf_resource_id: str | Omit = omit, email: str | Omit = omit, idp_resource_id: str | Omit = omit, @@ -93,6 +93,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identity_provider_id: @@ -100,7 +102,11 @@ def list( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) return self._get_api_list( - f"/accounts/{account_id}/access/identity_providers/{identity_provider_id}/scim/users", + path_template( + "/accounts/{account_id}/access/identity_providers/{identity_provider_id}/scim/users", + account_id=account_id, + identity_provider_id=identity_provider_id, + ), page=SyncV4PagePaginationArray[AccessUser], options=make_request_options( extra_headers=extra_headers, @@ -148,7 +154,7 @@ def list( self, identity_provider_id: str, *, - account_id: str, + account_id: str | None = None, cf_resource_id: str | Omit = omit, email: str | Omit = omit, idp_resource_id: str | Omit = omit, @@ -195,6 +201,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identity_provider_id: @@ -202,7 +210,11 @@ def list( f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" ) return self._get_api_list( - f"/accounts/{account_id}/access/identity_providers/{identity_provider_id}/scim/users", + path_template( + "/accounts/{account_id}/access/identity_providers/{identity_provider_id}/scim/users", + account_id=account_id, + identity_provider_id=identity_provider_id, + ), page=AsyncV4PagePaginationArray[AccessUser], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/networks/hostname_routes.py b/src/cloudflare/resources/zero_trust/networks/hostname_routes.py index db22dd6bdf2..f28e495da54 100644 --- a/src/cloudflare/resources/zero_trust/networks/hostname_routes.py +++ b/src/cloudflare/resources/zero_trust/networks/hostname_routes.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> HostnameRoutesResourceWithStreamingResponse def create( self, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, hostname: str | Omit = omit, tunnel_id: str | Omit = omit, @@ -83,10 +83,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/routes/hostname", + path_template("/accounts/{account_id}/zerotrust/routes/hostname", account_id=account_id), body=maybe_transform( { "comment": comment, @@ -108,7 +110,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, comment: str | Omit = omit, existed_at: str | Omit = omit, @@ -157,10 +159,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/routes/hostname", + path_template("/accounts/{account_id}/zerotrust/routes/hostname", account_id=account_id), page=SyncV4PagePaginationArray[HostnameRoute], options=make_request_options( extra_headers=extra_headers, @@ -188,7 +192,7 @@ def delete( self, hostname_route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -212,12 +216,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hostname_route_id: raise ValueError(f"Expected a non-empty value for `hostname_route_id` but received {hostname_route_id!r}") return self._delete( - f"/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + path_template( + "/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + account_id=account_id, + hostname_route_id=hostname_route_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -232,7 +242,7 @@ def edit( self, hostname_route_id: str, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, hostname: str | Omit = omit, tunnel_id: str | Omit = omit, @@ -265,12 +275,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hostname_route_id: raise ValueError(f"Expected a non-empty value for `hostname_route_id` but received {hostname_route_id!r}") return self._patch( - f"/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + path_template( + "/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + account_id=account_id, + hostname_route_id=hostname_route_id, + ), body=maybe_transform( { "comment": comment, @@ -293,7 +309,7 @@ def get( self, hostname_route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -317,12 +333,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hostname_route_id: raise ValueError(f"Expected a non-empty value for `hostname_route_id` but received {hostname_route_id!r}") return self._get( - f"/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + path_template( + "/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + account_id=account_id, + hostname_route_id=hostname_route_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -357,7 +379,7 @@ def with_streaming_response(self) -> AsyncHostnameRoutesResourceWithStreamingRes async def create( self, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, hostname: str | Omit = omit, tunnel_id: str | Omit = omit, @@ -388,10 +410,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/routes/hostname", + path_template("/accounts/{account_id}/zerotrust/routes/hostname", account_id=account_id), body=await async_maybe_transform( { "comment": comment, @@ -413,7 +437,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, comment: str | Omit = omit, existed_at: str | Omit = omit, @@ -462,10 +486,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/routes/hostname", + path_template("/accounts/{account_id}/zerotrust/routes/hostname", account_id=account_id), page=AsyncV4PagePaginationArray[HostnameRoute], options=make_request_options( extra_headers=extra_headers, @@ -493,7 +519,7 @@ async def delete( self, hostname_route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -517,12 +543,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hostname_route_id: raise ValueError(f"Expected a non-empty value for `hostname_route_id` but received {hostname_route_id!r}") return await self._delete( - f"/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + path_template( + "/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + account_id=account_id, + hostname_route_id=hostname_route_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -537,7 +569,7 @@ async def edit( self, hostname_route_id: str, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, hostname: str | Omit = omit, tunnel_id: str | Omit = omit, @@ -570,12 +602,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hostname_route_id: raise ValueError(f"Expected a non-empty value for `hostname_route_id` but received {hostname_route_id!r}") return await self._patch( - f"/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + path_template( + "/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + account_id=account_id, + hostname_route_id=hostname_route_id, + ), body=await async_maybe_transform( { "comment": comment, @@ -598,7 +636,7 @@ async def get( self, hostname_route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -622,12 +660,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not hostname_route_id: raise ValueError(f"Expected a non-empty value for `hostname_route_id` but received {hostname_route_id!r}") return await self._get( - f"/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + path_template( + "/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}", + account_id=account_id, + hostname_route_id=hostname_route_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/networks/routes/ips.py b/src/cloudflare/resources/zero_trust/networks/routes/ips.py index 9641d3eda30..15cc702a085 100644 --- a/src/cloudflare/resources/zero_trust/networks/routes/ips.py +++ b/src/cloudflare/resources/zero_trust/networks/routes/ips.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,7 +48,7 @@ def get( self, ip: str, *, - account_id: str, + account_id: str | None = None, default_virtual_network_fallback: bool | Omit = omit, virtual_network_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -79,12 +79,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ip: raise ValueError(f"Expected a non-empty value for `ip` but received {ip!r}") return self._get( - f"/accounts/{account_id}/teamnet/routes/ip/{ip}", + path_template("/accounts/{account_id}/teamnet/routes/ip/{ip}", account_id=account_id, ip=ip), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -127,7 +129,7 @@ async def get( self, ip: str, *, - account_id: str, + account_id: str | None = None, default_virtual_network_fallback: bool | Omit = omit, virtual_network_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -158,12 +160,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ip: raise ValueError(f"Expected a non-empty value for `ip` but received {ip!r}") return await self._get( - f"/accounts/{account_id}/teamnet/routes/ip/{ip}", + path_template("/accounts/{account_id}/teamnet/routes/ip/{ip}", account_id=account_id, ip=ip), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/networks/routes/networks.py b/src/cloudflare/resources/zero_trust/networks/routes/networks.py index 3b9f9249a10..86db38982d4 100644 --- a/src/cloudflare/resources/zero_trust/networks/routes/networks.py +++ b/src/cloudflare/resources/zero_trust/networks/routes/networks.py @@ -9,7 +9,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -53,7 +53,7 @@ def create( self, ip_network_encoded: str, *, - account_id: str, + account_id: str | None = None, tunnel_id: str, comment: str | Omit = omit, virtual_network_id: str | Omit = omit, @@ -88,12 +88,18 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ip_network_encoded: raise ValueError(f"Expected a non-empty value for `ip_network_encoded` but received {ip_network_encoded!r}") return self._post( - f"/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + path_template( + "/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + account_id=account_id, + ip_network_encoded=ip_network_encoded, + ), body=maybe_transform( { "tunnel_id": tunnel_id, @@ -119,7 +125,7 @@ def delete( self, ip_network_encoded: str, *, - account_id: str, + account_id: str | None = None, tun_type: Literal["cfd_tunnel", "warp_connector", "warp", "magic", "ip_sec", "gre", "cni"] | Omit = omit, tunnel_id: str | Omit = omit, virtual_network_id: str | Omit = omit, @@ -159,12 +165,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ip_network_encoded: raise ValueError(f"Expected a non-empty value for `ip_network_encoded` but received {ip_network_encoded!r}") return self._delete( - f"/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + path_template( + "/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + account_id=account_id, + ip_network_encoded=ip_network_encoded, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -190,7 +202,7 @@ def edit( self, ip_network_encoded: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -216,12 +228,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ip_network_encoded: raise ValueError(f"Expected a non-empty value for `ip_network_encoded` but received {ip_network_encoded!r}") return self._patch( - f"/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + path_template( + "/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + account_id=account_id, + ip_network_encoded=ip_network_encoded, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -260,7 +278,7 @@ async def create( self, ip_network_encoded: str, *, - account_id: str, + account_id: str | None = None, tunnel_id: str, comment: str | Omit = omit, virtual_network_id: str | Omit = omit, @@ -295,12 +313,18 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ip_network_encoded: raise ValueError(f"Expected a non-empty value for `ip_network_encoded` but received {ip_network_encoded!r}") return await self._post( - f"/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + path_template( + "/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + account_id=account_id, + ip_network_encoded=ip_network_encoded, + ), body=await async_maybe_transform( { "tunnel_id": tunnel_id, @@ -326,7 +350,7 @@ async def delete( self, ip_network_encoded: str, *, - account_id: str, + account_id: str | None = None, tun_type: Literal["cfd_tunnel", "warp_connector", "warp", "magic", "ip_sec", "gre", "cni"] | Omit = omit, tunnel_id: str | Omit = omit, virtual_network_id: str | Omit = omit, @@ -366,12 +390,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ip_network_encoded: raise ValueError(f"Expected a non-empty value for `ip_network_encoded` but received {ip_network_encoded!r}") return await self._delete( - f"/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + path_template( + "/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + account_id=account_id, + ip_network_encoded=ip_network_encoded, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -397,7 +427,7 @@ async def edit( self, ip_network_encoded: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -423,12 +453,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not ip_network_encoded: raise ValueError(f"Expected a non-empty value for `ip_network_encoded` but received {ip_network_encoded!r}") return await self._patch( - f"/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + path_template( + "/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}", + account_id=account_id, + ip_network_encoded=ip_network_encoded, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/networks/routes/routes.py b/src/cloudflare/resources/zero_trust/networks/routes/routes.py index e185d23080e..efe10473e5f 100644 --- a/src/cloudflare/resources/zero_trust/networks/routes/routes.py +++ b/src/cloudflare/resources/zero_trust/networks/routes/routes.py @@ -24,7 +24,7 @@ AsyncNetworksResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -74,7 +74,7 @@ def with_streaming_response(self) -> RoutesResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, network: str, tunnel_id: str, comment: str | Omit = omit, @@ -108,10 +108,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/teamnet/routes", + path_template("/accounts/{account_id}/teamnet/routes", account_id=account_id), body=maybe_transform( { "network": network, @@ -134,7 +136,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, existed_at: str | Omit = omit, is_deleted: bool | Omit = omit, @@ -191,10 +193,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/teamnet/routes", + path_template("/accounts/{account_id}/teamnet/routes", account_id=account_id), page=SyncV4PagePaginationArray[Teamnet], options=make_request_options( extra_headers=extra_headers, @@ -225,7 +229,7 @@ def delete( self, route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -249,12 +253,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._delete( - f"/accounts/{account_id}/teamnet/routes/{route_id}", + path_template("/accounts/{account_id}/teamnet/routes/{route_id}", account_id=account_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -269,7 +275,7 @@ def edit( self, route_id: str, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, network: str | Omit = omit, tunnel_id: str | Omit = omit, @@ -307,12 +313,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._patch( - f"/accounts/{account_id}/teamnet/routes/{route_id}", + path_template("/accounts/{account_id}/teamnet/routes/{route_id}", account_id=account_id, route_id=route_id), body=maybe_transform( { "comment": comment, @@ -336,7 +344,7 @@ def get( self, route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -360,12 +368,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._get( - f"/accounts/{account_id}/teamnet/routes/{route_id}", + path_template("/accounts/{account_id}/teamnet/routes/{route_id}", account_id=account_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -408,7 +418,7 @@ def with_streaming_response(self) -> AsyncRoutesResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, network: str, tunnel_id: str, comment: str | Omit = omit, @@ -442,10 +452,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/teamnet/routes", + path_template("/accounts/{account_id}/teamnet/routes", account_id=account_id), body=await async_maybe_transform( { "network": network, @@ -468,7 +480,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, existed_at: str | Omit = omit, is_deleted: bool | Omit = omit, @@ -525,10 +537,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/teamnet/routes", + path_template("/accounts/{account_id}/teamnet/routes", account_id=account_id), page=AsyncV4PagePaginationArray[Teamnet], options=make_request_options( extra_headers=extra_headers, @@ -559,7 +573,7 @@ async def delete( self, route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -583,12 +597,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._delete( - f"/accounts/{account_id}/teamnet/routes/{route_id}", + path_template("/accounts/{account_id}/teamnet/routes/{route_id}", account_id=account_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -603,7 +619,7 @@ async def edit( self, route_id: str, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, network: str | Omit = omit, tunnel_id: str | Omit = omit, @@ -641,12 +657,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._patch( - f"/accounts/{account_id}/teamnet/routes/{route_id}", + path_template("/accounts/{account_id}/teamnet/routes/{route_id}", account_id=account_id, route_id=route_id), body=await async_maybe_transform( { "comment": comment, @@ -670,7 +688,7 @@ async def get( self, route_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -694,12 +712,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._get( - f"/accounts/{account_id}/teamnet/routes/{route_id}", + path_template("/accounts/{account_id}/teamnet/routes/{route_id}", account_id=account_id, route_id=route_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/networks/subnets/cloudflare_source.py b/src/cloudflare/resources/zero_trust/networks/subnets/cloudflare_source.py index 568a1ac9db7..a272e7878b2 100644 --- a/src/cloudflare/resources/zero_trust/networks/subnets/cloudflare_source.py +++ b/src/cloudflare/resources/zero_trust/networks/subnets/cloudflare_source.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -49,7 +49,7 @@ def update( self, address_family: Literal["v4", "v6"], *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, name: str | Omit = omit, network: str | Omit = omit, @@ -82,12 +82,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_family: raise ValueError(f"Expected a non-empty value for `address_family` but received {address_family!r}") return self._patch( - f"/accounts/{account_id}/zerotrust/subnets/cloudflare_source/{address_family}", + path_template( + "/accounts/{account_id}/zerotrust/subnets/cloudflare_source/{address_family}", + account_id=account_id, + address_family=address_family, + ), body=maybe_transform( { "comment": comment, @@ -131,7 +137,7 @@ async def update( self, address_family: Literal["v4", "v6"], *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, name: str | Omit = omit, network: str | Omit = omit, @@ -164,12 +170,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not address_family: raise ValueError(f"Expected a non-empty value for `address_family` but received {address_family!r}") return await self._patch( - f"/accounts/{account_id}/zerotrust/subnets/cloudflare_source/{address_family}", + path_template( + "/accounts/{account_id}/zerotrust/subnets/cloudflare_source/{address_family}", + account_id=account_id, + address_family=address_family, + ), body=await async_maybe_transform( { "comment": comment, diff --git a/src/cloudflare/resources/zero_trust/networks/subnets/subnets.py b/src/cloudflare/resources/zero_trust/networks/subnets/subnets.py index 799ea74893e..6c3a1ebf0ef 100644 --- a/src/cloudflare/resources/zero_trust/networks/subnets/subnets.py +++ b/src/cloudflare/resources/zero_trust/networks/subnets/subnets.py @@ -15,7 +15,7 @@ AsyncWARPResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform +from ....._utils import path_template, maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -71,7 +71,7 @@ def with_streaming_response(self) -> SubnetsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, address_family: Literal["v4", "v6"] | Omit = omit, comment: str | Omit = omit, existed_at: str | Omit = omit, @@ -130,10 +130,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/subnets", + path_template("/accounts/{account_id}/zerotrust/subnets", account_id=account_id), page=SyncV4PagePaginationArray[Subnet], options=make_request_options( extra_headers=extra_headers, @@ -192,7 +194,7 @@ def with_streaming_response(self) -> AsyncSubnetsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, address_family: Literal["v4", "v6"] | Omit = omit, comment: str | Omit = omit, existed_at: str | Omit = omit, @@ -251,10 +253,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/subnets", + path_template("/accounts/{account_id}/zerotrust/subnets", account_id=account_id), page=AsyncV4PagePaginationArray[Subnet], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/networks/subnets/warp.py b/src/cloudflare/resources/zero_trust/networks/subnets/warp.py index fd964d37ac4..1db2485eba5 100644 --- a/src/cloudflare/resources/zero_trust/networks/subnets/warp.py +++ b/src/cloudflare/resources/zero_trust/networks/subnets/warp.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> WARPResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, network: str, comment: str | Omit = omit, @@ -94,10 +94,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/subnets/warp", + path_template("/accounts/{account_id}/zerotrust/subnets/warp", account_id=account_id), body=maybe_transform( { "name": name, @@ -121,7 +123,7 @@ def delete( self, subnet_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -147,12 +149,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subnet_id: raise ValueError(f"Expected a non-empty value for `subnet_id` but received {subnet_id!r}") return self._delete( - f"/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", + path_template( + "/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", account_id=account_id, subnet_id=subnet_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -167,7 +173,7 @@ def edit( self, subnet_id: str, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, is_default_network: bool | Omit = omit, name: str | Omit = omit, @@ -210,12 +216,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subnet_id: raise ValueError(f"Expected a non-empty value for `subnet_id` but received {subnet_id!r}") return self._patch( - f"/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", + path_template( + "/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", account_id=account_id, subnet_id=subnet_id + ), body=maybe_transform( { "comment": comment, @@ -239,7 +249,7 @@ def get( self, subnet_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -263,12 +273,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subnet_id: raise ValueError(f"Expected a non-empty value for `subnet_id` but received {subnet_id!r}") return self._get( - f"/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", + path_template( + "/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", account_id=account_id, subnet_id=subnet_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -303,7 +317,7 @@ def with_streaming_response(self) -> AsyncWARPResourceWithStreamingResponse: async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, network: str, comment: str | Omit = omit, @@ -349,10 +363,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zerotrust/subnets/warp", + path_template("/accounts/{account_id}/zerotrust/subnets/warp", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -376,7 +392,7 @@ async def delete( self, subnet_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -402,12 +418,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subnet_id: raise ValueError(f"Expected a non-empty value for `subnet_id` but received {subnet_id!r}") return await self._delete( - f"/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", + path_template( + "/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", account_id=account_id, subnet_id=subnet_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -422,7 +442,7 @@ async def edit( self, subnet_id: str, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, is_default_network: bool | Omit = omit, name: str | Omit = omit, @@ -465,12 +485,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subnet_id: raise ValueError(f"Expected a non-empty value for `subnet_id` but received {subnet_id!r}") return await self._patch( - f"/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", + path_template( + "/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", account_id=account_id, subnet_id=subnet_id + ), body=await async_maybe_transform( { "comment": comment, @@ -494,7 +518,7 @@ async def get( self, subnet_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -518,12 +542,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not subnet_id: raise ValueError(f"Expected a non-empty value for `subnet_id` but received {subnet_id!r}") return await self._get( - f"/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", + path_template( + "/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}", account_id=account_id, subnet_id=subnet_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/networks/virtual_networks.py b/src/cloudflare/resources/zero_trust/networks/virtual_networks.py index f89bf422286..41aab662a14 100644 --- a/src/cloudflare/resources/zero_trust/networks/virtual_networks.py +++ b/src/cloudflare/resources/zero_trust/networks/virtual_networks.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> VirtualNetworksResourceWithStreamingRespons def create( self, *, - account_id: str, + account_id: str | None = None, name: str, comment: str | Omit = omit, is_default: bool | Omit = omit, @@ -86,10 +86,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/teamnet/virtual_networks", + path_template("/accounts/{account_id}/teamnet/virtual_networks", account_id=account_id), body=maybe_transform( { "name": name, @@ -112,7 +114,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, is_default: bool | Omit = omit, is_default_network: bool | Omit = omit, @@ -152,10 +154,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/teamnet/virtual_networks", + path_template("/accounts/{account_id}/teamnet/virtual_networks", account_id=account_id), page=SyncSinglePage[VirtualNetwork], options=make_request_options( extra_headers=extra_headers, @@ -180,7 +184,7 @@ def delete( self, virtual_network_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -204,12 +208,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not virtual_network_id: raise ValueError(f"Expected a non-empty value for `virtual_network_id` but received {virtual_network_id!r}") return self._delete( - f"/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + path_template( + "/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + account_id=account_id, + virtual_network_id=virtual_network_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -224,7 +234,7 @@ def edit( self, virtual_network_id: str, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, is_default_network: bool | Omit = omit, name: str | Omit = omit, @@ -257,12 +267,18 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not virtual_network_id: raise ValueError(f"Expected a non-empty value for `virtual_network_id` but received {virtual_network_id!r}") return self._patch( - f"/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + path_template( + "/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + account_id=account_id, + virtual_network_id=virtual_network_id, + ), body=maybe_transform( { "comment": comment, @@ -285,7 +301,7 @@ def get( self, virtual_network_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -309,12 +325,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not virtual_network_id: raise ValueError(f"Expected a non-empty value for `virtual_network_id` but received {virtual_network_id!r}") return self._get( - f"/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + path_template( + "/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + account_id=account_id, + virtual_network_id=virtual_network_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -349,7 +371,7 @@ def with_streaming_response(self) -> AsyncVirtualNetworksResourceWithStreamingRe async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, comment: str | Omit = omit, is_default: bool | Omit = omit, @@ -383,10 +405,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/teamnet/virtual_networks", + path_template("/accounts/{account_id}/teamnet/virtual_networks", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -409,7 +433,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, id: str | Omit = omit, is_default: bool | Omit = omit, is_default_network: bool | Omit = omit, @@ -449,10 +473,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/teamnet/virtual_networks", + path_template("/accounts/{account_id}/teamnet/virtual_networks", account_id=account_id), page=AsyncSinglePage[VirtualNetwork], options=make_request_options( extra_headers=extra_headers, @@ -477,7 +503,7 @@ async def delete( self, virtual_network_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -501,12 +527,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not virtual_network_id: raise ValueError(f"Expected a non-empty value for `virtual_network_id` but received {virtual_network_id!r}") return await self._delete( - f"/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + path_template( + "/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + account_id=account_id, + virtual_network_id=virtual_network_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -521,7 +553,7 @@ async def edit( self, virtual_network_id: str, *, - account_id: str, + account_id: str | None = None, comment: str | Omit = omit, is_default_network: bool | Omit = omit, name: str | Omit = omit, @@ -554,12 +586,18 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not virtual_network_id: raise ValueError(f"Expected a non-empty value for `virtual_network_id` but received {virtual_network_id!r}") return await self._patch( - f"/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + path_template( + "/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + account_id=account_id, + virtual_network_id=virtual_network_id, + ), body=await async_maybe_transform( { "comment": comment, @@ -582,7 +620,7 @@ async def get( self, virtual_network_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -606,12 +644,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not virtual_network_id: raise ValueError(f"Expected a non-empty value for `virtual_network_id` but received {virtual_network_id!r}") return await self._get( - f"/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + path_template( + "/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}", + account_id=account_id, + virtual_network_id=virtual_network_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/organizations/doh.py b/src/cloudflare/resources/zero_trust/organizations/doh.py index 61e2ccdb031..ef7778068e9 100644 --- a/src/cloudflare/resources/zero_trust/organizations/doh.py +++ b/src/cloudflare/resources/zero_trust/organizations/doh.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> DOHResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, doh_jwt_duration: str | Omit = omit, service_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. @@ -79,10 +79,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/organizations/doh", + path_template("/accounts/{account_id}/access/organizations/doh", account_id=account_id), body=maybe_transform( { "doh_jwt_duration": doh_jwt_duration, @@ -103,7 +105,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -125,10 +127,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/organizations/doh", + path_template("/accounts/{account_id}/access/organizations/doh", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -163,7 +167,7 @@ def with_streaming_response(self) -> AsyncDOHResourceWithStreamingResponse: async def update( self, *, - account_id: str, + account_id: str | None = None, doh_jwt_duration: str | Omit = omit, service_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. @@ -194,10 +198,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/organizations/doh", + path_template("/accounts/{account_id}/access/organizations/doh", account_id=account_id), body=await async_maybe_transform( { "doh_jwt_duration": doh_jwt_duration, @@ -218,7 +224,7 @@ async def update( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -240,10 +246,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/organizations/doh", + path_template("/accounts/{account_id}/access/organizations/doh", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/organizations/organizations.py b/src/cloudflare/resources/zero_trust/organizations/organizations.py index 605f8dd5729..fce39c1b0f9 100644 --- a/src/cloudflare/resources/zero_trust/organizations/organizations.py +++ b/src/cloudflare/resources/zero_trust/organizations/organizations.py @@ -15,7 +15,7 @@ AsyncDOHResourceWithStreamingResponse, ) from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -67,8 +67,8 @@ def create( *, auth_domain: str, name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, deny_unmatched_requests: bool | Omit = omit, @@ -152,6 +152,10 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -165,7 +169,11 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/organizations", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/organizations", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "auth_domain": auth_domain, @@ -199,8 +207,8 @@ def create( def update( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, auth_domain: str | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -287,6 +295,10 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -300,7 +312,11 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/organizations", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/organizations", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "allow_authenticate_via_warp": allow_authenticate_via_warp, @@ -335,8 +351,8 @@ def update( def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -360,6 +376,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -373,7 +393,11 @@ def list( account_or_zone = "zones" account_or_zone_id = zone_id return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/organizations", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/organizations", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -388,8 +412,8 @@ def revoke_users( self, *, email: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, query_devices: bool | Omit = omit, body_devices: bool | Omit = omit, user_uid: str | Omit = omit, @@ -429,6 +453,10 @@ def revoke_users( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -442,7 +470,11 @@ def revoke_users( account_or_zone = "zones" account_or_zone_id = zone_id return self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/organizations/revoke_user", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/organizations/revoke_user", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=maybe_transform( { "email": email, @@ -497,8 +529,8 @@ async def create( *, auth_domain: str, name: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, deny_unmatched_requests: bool | Omit = omit, @@ -582,6 +614,10 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -595,7 +631,11 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/organizations", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/organizations", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "auth_domain": auth_domain, @@ -629,8 +669,8 @@ async def create( async def update( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, allow_authenticate_via_warp: bool | Omit = omit, auth_domain: str | Omit = omit, auto_redirect_to_identity: bool | Omit = omit, @@ -717,6 +757,10 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -730,7 +774,11 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/organizations", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/organizations", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "allow_authenticate_via_warp": allow_authenticate_via_warp, @@ -765,8 +813,8 @@ async def update( async def list( self, *, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -790,6 +838,10 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -803,7 +855,11 @@ async def list( account_or_zone = "zones" account_or_zone_id = zone_id return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/organizations", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/organizations", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -818,8 +874,8 @@ async def revoke_users( self, *, email: str, - account_id: str | Omit = omit, - zone_id: str | Omit = omit, + account_id: str | None = None, + zone_id: str | None = None, query_devices: bool | Omit = omit, body_devices: bool | Omit = omit, user_uid: str | Omit = omit, @@ -859,6 +915,10 @@ async def revoke_users( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -872,7 +932,11 @@ async def revoke_users( account_or_zone = "zones" account_or_zone_id = zone_id return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/organizations/revoke_user", + path_template( + "/{account_or_zone}/{account_or_zone_id}/access/organizations/revoke_user", + account_or_zone=account_or_zone, + account_or_zone_id=account_or_zone_id, + ), body=await async_maybe_transform( { "email": email, diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/behaviours.py b/src/cloudflare/resources/zero_trust/risk_scoring/behaviours.py index d583411ead4..584759cc3e4 100644 --- a/src/cloudflare/resources/zero_trust/risk_scoring/behaviours.py +++ b/src/cloudflare/resources/zero_trust/risk_scoring/behaviours.py @@ -7,7 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given -from ...._utils import maybe_transform, async_maybe_transform +from ...._utils import path_template, maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -48,7 +48,7 @@ def with_streaming_response(self) -> BehavioursResourceWithStreamingResponse: def update( self, *, - account_id: str, + account_id: str | None = None, behaviors: Dict[str, behaviour_update_params.Behaviors], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -70,10 +70,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/behaviors", + path_template("/accounts/{account_id}/zt_risk_scoring/behaviors", account_id=account_id), body=maybe_transform({"behaviors": behaviors}, behaviour_update_params.BehaviourUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -88,7 +90,7 @@ def update( def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -109,10 +111,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/behaviors", + path_template("/accounts/{account_id}/zt_risk_scoring/behaviors", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -147,7 +151,7 @@ def with_streaming_response(self) -> AsyncBehavioursResourceWithStreamingRespons async def update( self, *, - account_id: str, + account_id: str | None = None, behaviors: Dict[str, behaviour_update_params.Behaviors], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -169,10 +173,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/behaviors", + path_template("/accounts/{account_id}/zt_risk_scoring/behaviors", account_id=account_id), body=await async_maybe_transform({"behaviors": behaviors}, behaviour_update_params.BehaviourUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -187,7 +193,7 @@ async def update( async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -208,10 +214,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/behaviors", + path_template("/accounts/{account_id}/zt_risk_scoring/behaviors", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/integrations/integrations.py b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/integrations.py index a4c101cc906..0e0219d4109 100644 --- a/src/cloudflare/resources/zero_trust/risk_scoring/integrations/integrations.py +++ b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/integrations.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from .references import ( ReferencesResource, AsyncReferencesResource, @@ -64,7 +64,7 @@ def with_streaming_response(self) -> IntegrationsResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, integration_type: Literal["Okta"], tenant_url: str, reference_id: Optional[str] | Omit = omit, @@ -94,10 +94,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/integrations", + path_template("/accounts/{account_id}/zt_risk_scoring/integrations", account_id=account_id), body=maybe_transform( { "integration_type": integration_type, @@ -120,7 +122,7 @@ def update( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, active: bool, tenant_url: str, reference_id: Optional[str] | Omit = omit, @@ -153,12 +155,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return self._put( - f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + path_template( + "/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), body=maybe_transform( { "active": active, @@ -180,7 +188,7 @@ def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -200,10 +208,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/integrations", + path_template("/accounts/{account_id}/zt_risk_scoring/integrations", account_id=account_id), page=SyncSinglePage[IntegrationListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -215,7 +225,7 @@ def delete( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -236,12 +246,18 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return self._delete( - f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + path_template( + "/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -256,7 +272,7 @@ def get( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -276,12 +292,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return self._get( - f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + path_template( + "/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -320,7 +342,7 @@ def with_streaming_response(self) -> AsyncIntegrationsResourceWithStreamingRespo async def create( self, *, - account_id: str, + account_id: str | None = None, integration_type: Literal["Okta"], tenant_url: str, reference_id: Optional[str] | Omit = omit, @@ -350,10 +372,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/integrations", + path_template("/accounts/{account_id}/zt_risk_scoring/integrations", account_id=account_id), body=await async_maybe_transform( { "integration_type": integration_type, @@ -376,7 +400,7 @@ async def update( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, active: bool, tenant_url: str, reference_id: Optional[str] | Omit = omit, @@ -409,12 +433,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return await self._put( - f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + path_template( + "/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), body=await async_maybe_transform( { "active": active, @@ -436,7 +466,7 @@ async def update( def list( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -456,10 +486,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/integrations", + path_template("/accounts/{account_id}/zt_risk_scoring/integrations", account_id=account_id), page=AsyncSinglePage[IntegrationListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -471,7 +503,7 @@ async def delete( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -492,12 +524,18 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return await self._delete( - f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + path_template( + "/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -512,7 +550,7 @@ async def get( self, integration_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -532,12 +570,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not integration_id: raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") return await self._get( - f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + path_template( + "/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + account_id=account_id, + integration_id=integration_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/integrations/references.py b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/references.py index b6b7b760fb2..3e656564654 100644 --- a/src/cloudflare/resources/zero_trust/risk_scoring/integrations/references.py +++ b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/references.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def get( self, reference_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,12 +67,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not reference_id: raise ValueError(f"Expected a non-empty value for `reference_id` but received {reference_id!r}") return self._get( - f"/accounts/{account_id}/zt_risk_scoring/integrations/reference_id/{reference_id}", + path_template( + "/accounts/{account_id}/zt_risk_scoring/integrations/reference_id/{reference_id}", + account_id=account_id, + reference_id=reference_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -107,7 +114,7 @@ async def get( self, reference_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -127,12 +134,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not reference_id: raise ValueError(f"Expected a non-empty value for `reference_id` but received {reference_id!r}") return await self._get( - f"/accounts/{account_id}/zt_risk_scoring/integrations/reference_id/{reference_id}", + path_template( + "/accounts/{account_id}/zt_risk_scoring/integrations/reference_id/{reference_id}", + account_id=account_id, + reference_id=reference_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py b/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py index 1311808b28e..75daf868585 100644 --- a/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py +++ b/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py @@ -15,6 +15,7 @@ AsyncSummaryResourceWithStreamingResponse, ) from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from .behaviours import ( BehavioursResource, @@ -82,7 +83,7 @@ def get( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -103,12 +104,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._get( - f"/accounts/{account_id}/zt_risk_scoring/{user_id}", + path_template("/accounts/{account_id}/zt_risk_scoring/{user_id}", account_id=account_id, user_id=user_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -123,7 +126,7 @@ def reset( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -143,12 +146,16 @@ def reset( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return self._post( - f"/accounts/{account_id}/zt_risk_scoring/{user_id}/reset", + path_template( + "/accounts/{account_id}/zt_risk_scoring/{user_id}/reset", account_id=account_id, user_id=user_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -196,7 +203,7 @@ async def get( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -217,12 +224,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return await self._get( - f"/accounts/{account_id}/zt_risk_scoring/{user_id}", + path_template("/accounts/{account_id}/zt_risk_scoring/{user_id}", account_id=account_id, user_id=user_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -237,7 +246,7 @@ async def reset( self, user_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -257,12 +266,16 @@ async def reset( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not user_id: raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") return await self._post( - f"/accounts/{account_id}/zt_risk_scoring/{user_id}/reset", + path_template( + "/accounts/{account_id}/zt_risk_scoring/{user_id}/reset", account_id=account_id, user_id=user_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/summary.py b/src/cloudflare/resources/zero_trust/risk_scoring/summary.py index b5add52f5f4..00e304edb7f 100644 --- a/src/cloudflare/resources/zero_trust/risk_scoring/summary.py +++ b/src/cloudflare/resources/zero_trust/risk_scoring/summary.py @@ -7,6 +7,7 @@ import httpx from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import path_template from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> SummaryResourceWithStreamingResponse: def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -66,10 +67,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/summary", + path_template("/accounts/{account_id}/zt_risk_scoring/summary", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -104,7 +107,7 @@ def with_streaming_response(self) -> AsyncSummaryResourceWithStreamingResponse: async def get( self, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -125,10 +128,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/zt_risk_scoring/summary", + path_template("/accounts/{account_id}/zt_risk_scoring/summary", account_id=account_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/seats.py b/src/cloudflare/resources/zero_trust/seats.py index 33b23e1567c..2f46fcb8214 100644 --- a/src/cloudflare/resources/zero_trust/seats.py +++ b/src/cloudflare/resources/zero_trust/seats.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> SeatsResourceWithStreamingResponse: def edit( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[seat_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. @@ -71,10 +71,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/seats", + path_template("/accounts/{account_id}/access/seats", account_id=account_id), page=SyncSinglePage[Seat], body=maybe_transform(body, Iterable[seat_edit_params.Body]), options=make_request_options( @@ -108,7 +110,7 @@ def with_streaming_response(self) -> AsyncSeatsResourceWithStreamingResponse: def edit( self, *, - account_id: str, + account_id: str | None = None, body: Iterable[seat_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. @@ -132,10 +134,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/access/seats", + path_template("/accounts/{account_id}/access/seats", account_id=account_id), page=AsyncSinglePage[Seat], body=maybe_transform(body, Iterable[seat_edit_params.Body]), options=make_request_options( diff --git a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/cloudflared.py b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/cloudflared.py index 5f6a23aacfb..8e6d5fc122b 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/cloudflared.py +++ b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/cloudflared.py @@ -17,7 +17,7 @@ AsyncTokenResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from .connectors import ( ConnectorsResource, AsyncConnectorsResource, @@ -110,7 +110,7 @@ def with_streaming_response(self) -> CloudflaredResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, config_src: Literal["local", "cloudflare"] | Omit = omit, tunnel_secret: str | Omit = omit, @@ -144,10 +144,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cfd_tunnel", + path_template("/accounts/{account_id}/cfd_tunnel", account_id=account_id), body=maybe_transform( { "name": name, @@ -169,7 +171,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, exclude_prefix: str | Omit = omit, existed_at: str | Omit = omit, include_prefix: str | Omit = omit, @@ -221,10 +223,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cfd_tunnel", + path_template("/accounts/{account_id}/cfd_tunnel", account_id=account_id), page=SyncV4PagePaginationArray[CloudflareTunnel], options=make_request_options( extra_headers=extra_headers, @@ -255,7 +259,7 @@ def delete( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -279,12 +283,14 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._delete( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}", + path_template("/accounts/{account_id}/cfd_tunnel/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -299,7 +305,7 @@ def edit( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, tunnel_secret: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -330,12 +336,14 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._patch( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}", + path_template("/accounts/{account_id}/cfd_tunnel/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id), body=maybe_transform( { "name": name, @@ -357,7 +365,7 @@ def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -381,12 +389,14 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._get( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}", + path_template("/accounts/{account_id}/cfd_tunnel/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -441,7 +451,7 @@ def with_streaming_response(self) -> AsyncCloudflaredResourceWithStreamingRespon async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, config_src: Literal["local", "cloudflare"] | Omit = omit, tunnel_secret: str | Omit = omit, @@ -475,10 +485,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cfd_tunnel", + path_template("/accounts/{account_id}/cfd_tunnel", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -500,7 +512,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, exclude_prefix: str | Omit = omit, existed_at: str | Omit = omit, include_prefix: str | Omit = omit, @@ -552,10 +564,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/cfd_tunnel", + path_template("/accounts/{account_id}/cfd_tunnel", account_id=account_id), page=AsyncV4PagePaginationArray[CloudflareTunnel], options=make_request_options( extra_headers=extra_headers, @@ -586,7 +600,7 @@ async def delete( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -610,12 +624,14 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._delete( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}", + path_template("/accounts/{account_id}/cfd_tunnel/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -630,7 +646,7 @@ async def edit( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, tunnel_secret: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -661,12 +677,14 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._patch( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}", + path_template("/accounts/{account_id}/cfd_tunnel/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id), body=await async_maybe_transform( { "name": name, @@ -688,7 +706,7 @@ async def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -712,12 +730,14 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._get( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}", + path_template("/accounts/{account_id}/cfd_tunnel/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/configurations.py b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/configurations.py index b70cdd5caf2..1eea6f11433 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/configurations.py +++ b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/configurations.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -49,7 +49,7 @@ def update( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, config: configuration_update_params.Config | 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. @@ -76,12 +76,18 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._put( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations", + account_id=account_id, + tunnel_id=tunnel_id, + ), body=maybe_transform({"config": config}, configuration_update_params.ConfigurationUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -97,7 +103,7 @@ def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -121,12 +127,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._get( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations", + account_id=account_id, + tunnel_id=tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -162,7 +174,7 @@ async def update( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, config: configuration_update_params.Config | 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. @@ -189,12 +201,18 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._put( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations", + account_id=account_id, + tunnel_id=tunnel_id, + ), body=await async_maybe_transform({"config": config}, configuration_update_params.ConfigurationUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -210,7 +228,7 @@ async def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -234,12 +252,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._get( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations", + account_id=account_id, + tunnel_id=tunnel_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/connections.py b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/connections.py index 478f3deaaa4..05199a2c228 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/connections.py +++ b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/connections.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -49,7 +49,7 @@ def delete( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, client_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. @@ -79,12 +79,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._delete( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -100,7 +104,7 @@ def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -124,12 +128,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._get_api_list( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections", account_id=account_id, tunnel_id=tunnel_id + ), page=SyncSinglePage[Client], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -162,7 +170,7 @@ async def delete( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, client_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. @@ -192,12 +200,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._delete( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -215,7 +227,7 @@ def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -239,12 +251,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._get_api_list( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections", account_id=account_id, tunnel_id=tunnel_id + ), page=AsyncSinglePage[Client], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/connectors.py b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/connectors.py index 4bb21057683..0c7fe5569ed 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/connectors.py +++ b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/connectors.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def get( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, tunnel_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. @@ -73,6 +74,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: @@ -80,7 +83,12 @@ def get( if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connectors/{connector_id}", + account_id=account_id, + tunnel_id=tunnel_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -116,7 +124,7 @@ async def get( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, tunnel_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. @@ -143,6 +151,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: @@ -150,7 +160,12 @@ async def get( if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connectors/{connector_id}", + account_id=account_id, + tunnel_id=tunnel_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/management.py b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/management.py index f6c7015dfef..986e245d489 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/management.py +++ b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/management.py @@ -8,7 +8,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -49,7 +49,7 @@ def create( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, resources: List[Literal["logs"]], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -76,12 +76,16 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._post( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/management", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/management", account_id=account_id, tunnel_id=tunnel_id + ), body=maybe_transform({"resources": resources}, management_create_params.ManagementCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -118,7 +122,7 @@ async def create( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, resources: List[Literal["logs"]], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -145,12 +149,16 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._post( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/management", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/management", account_id=account_id, tunnel_id=tunnel_id + ), body=await async_maybe_transform({"resources": resources}, management_create_params.ManagementCreateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/token.py b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/token.py index d16411c5002..895633244c9 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/cloudflared/token.py +++ b/src/cloudflare/resources/zero_trust/tunnels/cloudflared/token.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -70,12 +71,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._get( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/token", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/token", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -111,7 +116,7 @@ async def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -135,12 +140,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._get( - f"/accounts/{account_id}/cfd_tunnel/{tunnel_id}/token", + path_template( + "/accounts/{account_id}/cfd_tunnel/{tunnel_id}/token", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/tunnels/tunnels.py b/src/cloudflare/resources/zero_trust/tunnels/tunnels.py index 7f0cc04bdfa..a1ce7d50af9 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/tunnels.py +++ b/src/cloudflare/resources/zero_trust/tunnels/tunnels.py @@ -9,7 +9,7 @@ import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform +from ...._utils import path_template, maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -73,7 +73,7 @@ def with_streaming_response(self) -> TunnelsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, exclude_prefix: str | Omit = omit, existed_at: str | Omit = omit, include_prefix: str | Omit = omit, @@ -128,10 +128,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/tunnels", + path_template("/accounts/{account_id}/tunnels", account_id=account_id), page=SyncV4PagePaginationArray[TunnelListResponse], options=make_request_options( extra_headers=extra_headers, @@ -191,7 +193,7 @@ def with_streaming_response(self) -> AsyncTunnelsResourceWithStreamingResponse: def list( self, *, - account_id: str, + account_id: str | None = None, exclude_prefix: str | Omit = omit, existed_at: str | Omit = omit, include_prefix: str | Omit = omit, @@ -246,10 +248,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/tunnels", + path_template("/accounts/{account_id}/tunnels", account_id=account_id), page=AsyncV4PagePaginationArray[TunnelListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/connections.py b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/connections.py index 47facb8f2a8..46040bb336d 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/connections.py +++ b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/connections.py @@ -5,6 +5,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -44,7 +45,7 @@ def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,12 +69,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._get_api_list( - f"/accounts/{account_id}/warp_connector/{tunnel_id}/connections", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}/connections", + account_id=account_id, + tunnel_id=tunnel_id, + ), page=SyncSinglePage[ConnectionGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -106,7 +113,7 @@ def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -130,12 +137,18 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._get_api_list( - f"/accounts/{account_id}/warp_connector/{tunnel_id}/connections", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}/connections", + account_id=account_id, + tunnel_id=tunnel_id, + ), page=AsyncSinglePage[ConnectionGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/connectors.py b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/connectors.py index f8303981ceb..eb447d8d76d 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/connectors.py +++ b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/connectors.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def get( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, tunnel_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. @@ -73,6 +74,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: @@ -80,7 +83,12 @@ def get( if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( - f"/accounts/{account_id}/warp_connector/{tunnel_id}/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}/connectors/{connector_id}", + account_id=account_id, + tunnel_id=tunnel_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -116,7 +124,7 @@ async def get( self, connector_id: str, *, - account_id: str, + account_id: str | None = None, tunnel_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. @@ -143,6 +151,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: @@ -150,7 +160,12 @@ async def get( if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( - f"/accounts/{account_id}/warp_connector/{tunnel_id}/connectors/{connector_id}", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}/connectors/{connector_id}", + account_id=account_id, + tunnel_id=tunnel_id, + connector_id=connector_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/failover.py b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/failover.py index 61a7fda0bd4..71d83b7e81f 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/failover.py +++ b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/failover.py @@ -7,7 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -47,7 +47,7 @@ def update( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, client_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. @@ -76,12 +76,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._put( - f"/accounts/{account_id}/warp_connector/{tunnel_id}/failover", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}/failover", account_id=account_id, tunnel_id=tunnel_id + ), body=maybe_transform({"client_id": client_id}, failover_update_params.FailoverUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -118,7 +122,7 @@ async def update( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, client_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. @@ -147,12 +151,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._put( - f"/accounts/{account_id}/warp_connector/{tunnel_id}/failover", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}/failover", account_id=account_id, tunnel_id=tunnel_id + ), body=await async_maybe_transform({"client_id": client_id}, failover_update_params.FailoverUpdateParams), options=make_request_options( extra_headers=extra_headers, diff --git a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/token.py b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/token.py index aeb96269e07..e755560a2fc 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/token.py +++ b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/token.py @@ -7,6 +7,7 @@ import httpx from ....._types import Body, Query, Headers, NotGiven, not_given +from ....._utils import path_template from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -46,7 +47,7 @@ def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -71,12 +72,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._get( - f"/accounts/{account_id}/warp_connector/{tunnel_id}/token", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}/token", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -112,7 +117,7 @@ async def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -137,12 +142,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._get( - f"/accounts/{account_id}/warp_connector/{tunnel_id}/token", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}/token", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/warp_connector.py b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/warp_connector.py index b0511e0a789..e23f37359d5 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/warp_connector/warp_connector.py +++ b/src/cloudflare/resources/zero_trust/tunnels/warp_connector/warp_connector.py @@ -25,7 +25,7 @@ AsyncFailoverResourceWithStreamingResponse, ) from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ....._utils import maybe_transform, async_maybe_transform +from ....._utils import path_template, maybe_transform, async_maybe_transform from .connectors import ( ConnectorsResource, AsyncConnectorsResource, @@ -106,7 +106,7 @@ def with_streaming_response(self) -> WARPConnectorResourceWithStreamingResponse: def create( self, *, - account_id: str, + account_id: str | None = None, name: str, ha: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -135,10 +135,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/warp_connector", + path_template("/accounts/{account_id}/warp_connector", account_id=account_id), body=maybe_transform( { "name": name, @@ -159,7 +161,7 @@ def create( def list( self, *, - account_id: str, + account_id: str | None = None, exclude_prefix: str | Omit = omit, existed_at: str | Omit = omit, include_prefix: str | Omit = omit, @@ -211,10 +213,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/warp_connector", + path_template("/accounts/{account_id}/warp_connector", account_id=account_id), page=SyncV4PagePaginationArray[WARPConnectorListResponse], options=make_request_options( extra_headers=extra_headers, @@ -245,7 +249,7 @@ def delete( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -269,12 +273,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._delete( - f"/accounts/{account_id}/warp_connector/{tunnel_id}", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -289,7 +297,7 @@ def edit( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, tunnel_secret: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -320,12 +328,16 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._patch( - f"/accounts/{account_id}/warp_connector/{tunnel_id}", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id + ), body=maybe_transform( { "name": name, @@ -347,7 +359,7 @@ def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -371,12 +383,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return self._get( - f"/accounts/{account_id}/warp_connector/{tunnel_id}", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -427,7 +443,7 @@ def with_streaming_response(self) -> AsyncWARPConnectorResourceWithStreamingResp async def create( self, *, - account_id: str, + account_id: str | None = None, name: str, ha: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -456,10 +472,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/warp_connector", + path_template("/accounts/{account_id}/warp_connector", account_id=account_id), body=await async_maybe_transform( { "name": name, @@ -480,7 +498,7 @@ async def create( def list( self, *, - account_id: str, + account_id: str | None = None, exclude_prefix: str | Omit = omit, existed_at: str | Omit = omit, include_prefix: str | Omit = omit, @@ -532,10 +550,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() 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}/warp_connector", + path_template("/accounts/{account_id}/warp_connector", account_id=account_id), page=AsyncV4PagePaginationArray[WARPConnectorListResponse], options=make_request_options( extra_headers=extra_headers, @@ -566,7 +586,7 @@ async def delete( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -590,12 +610,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._delete( - f"/accounts/{account_id}/warp_connector/{tunnel_id}", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -610,7 +634,7 @@ async def edit( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, name: str | Omit = omit, tunnel_secret: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -641,12 +665,16 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._patch( - f"/accounts/{account_id}/warp_connector/{tunnel_id}", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id + ), body=await async_maybe_transform( { "name": name, @@ -668,7 +696,7 @@ async def get( self, tunnel_id: str, *, - account_id: str, + account_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -692,12 +720,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if account_id is None: + account_id = self._client._get_account_id_path_param() if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not tunnel_id: raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}") return await self._get( - f"/accounts/{account_id}/warp_connector/{tunnel_id}", + path_template( + "/accounts/{account_id}/warp_connector/{tunnel_id}", account_id=account_id, tunnel_id=tunnel_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zones/activation_check.py b/src/cloudflare/resources/zones/activation_check.py index 8d829f2f272..ee28b04b0e3 100644 --- a/src/cloudflare/resources/zones/activation_check.py +++ b/src/cloudflare/resources/zones/activation_check.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -45,7 +46,7 @@ def with_streaming_response(self) -> ActivationCheckResourceWithStreamingRespons def trigger( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -69,10 +70,12 @@ def trigger( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/activation_check", + path_template("/zones/{zone_id}/activation_check", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -107,7 +110,7 @@ def with_streaming_response(self) -> AsyncActivationCheckResourceWithStreamingRe async def trigger( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -131,10 +134,12 @@ async def trigger( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/activation_check", + path_template("/zones/{zone_id}/activation_check", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zones/api.md b/src/cloudflare/resources/zones/api.md new file mode 100644 index 00000000000..a6b73560a00 --- /dev/null +++ b/src/cloudflare/resources/zones/api.md @@ -0,0 +1,188 @@ +# Zones + +Types: + +```python +from cloudflare.types.zones import Type, Zone, ZoneDeleteResponse +``` + +Methods: + +- client.zones.create(\*\*params) -> Optional[Zone] +- client.zones.list(\*\*params) -> SyncV4PagePaginationArray[Zone] +- client.zones.delete(\*, zone_id) -> Optional[ZoneDeleteResponse] +- client.zones.edit(\*, zone_id, \*\*params) -> Optional[Zone] +- client.zones.get(\*, zone_id) -> Optional[Zone] + +## ActivationCheck + +Types: + +```python +from cloudflare.types.zones import ActivationCheckTriggerResponse +``` + +Methods: + +- client.zones.activation_check.trigger(\*, zone_id) -> Optional[ActivationCheckTriggerResponse] + +## Settings + +Types: + +```python +from cloudflare.types.zones import ( + AdvancedDDoS, + Aegis, + AlwaysOnline, + AlwaysUseHTTPS, + AutomaticHTTPSRewrites, + AutomaticPlatformOptimization, + Brotli, + BrowserCacheTTL, + BrowserCheck, + CacheLevel, + ChallengeTTL, + Ciphers, + DevelopmentMode, + EarlyHints, + EmailObfuscation, + FontSettings, + H2Prioritization, + HotlinkProtection, + HTTP2, + HTTP3, + ImageResizing, + IPGeolocation, + IPV6, + MinTLSVersion, + Mirage, + NEL, + OpportunisticEncryption, + OpportunisticOnion, + OrangeToOrange, + OriginErrorPagePassThru, + OriginMaxHTTPVersion, + Polish, + PrefetchPreload, + ProxyReadTimeout, + PseudoIPV4, + ResponseBuffering, + RocketLoader, + SecurityHeaders, + SecurityLevel, + ServerSideExcludes, + SortQueryStringForCache, + SSL, + SSLRecommender, + TLS1_3, + TLSClientAuth, + TrueClientIPHeader, + WAF, + WebP, + Websocket, + ZeroRTT, + SettingEditResponse, + SettingGetResponse, +) +``` + +Methods: + +- client.zones.settings.edit(setting_id, \*, zone_id, \*\*params) -> Optional[SettingEditResponse] +- client.zones.settings.get(setting_id, \*, zone_id) -> Optional[SettingGetResponse] + +## Environments + +Types: + +```python +from cloudflare.types.zones import ( + EnvironmentCreateResponse, + EnvironmentUpdateResponse, + EnvironmentListResponse, + EnvironmentDeleteResponse, + EnvironmentEditResponse, + EnvironmentRollbackResponse, +) +``` + +Methods: + +- client.zones.environments.create(\*, zone_id, \*\*params) -> EnvironmentCreateResponse +- client.zones.environments.update(\*, zone_id, \*\*params) -> EnvironmentUpdateResponse +- client.zones.environments.list(\*, zone_id) -> EnvironmentListResponse +- client.zones.environments.delete(environment_id, \*, zone_id) -> EnvironmentDeleteResponse +- client.zones.environments.edit(\*, zone_id, \*\*params) -> EnvironmentEditResponse +- client.zones.environments.rollback(environment_id, \*, zone_id) -> EnvironmentRollbackResponse + +## CustomNameservers + +Types: + +```python +from cloudflare.types.zones import CustomNameserverUpdateResponse, CustomNameserverGetResponse +``` + +Methods: + +- client.zones.custom_nameservers.update(\*, zone_id, \*\*params) -> SyncSinglePage[CustomNameserverUpdateResponse] +- client.zones.custom_nameservers.get(\*, zone_id) -> CustomNameserverGetResponse + +## Holds + +Types: + +```python +from cloudflare.types.zones import ZoneHold +``` + +Methods: + +- client.zones.holds.create(\*, zone_id, \*\*params) -> ZoneHold +- client.zones.holds.delete(\*, zone_id, \*\*params) -> ZoneHold +- client.zones.holds.edit(\*, zone_id, \*\*params) -> ZoneHold +- client.zones.holds.get(\*, zone_id) -> ZoneHold + +## Subscriptions + +Types: + +```python +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.rate_plans.get(\*, zone_id) -> SyncSinglePage[RatePlanGetResponse] diff --git a/src/cloudflare/resources/zones/custom_nameservers.py b/src/cloudflare/resources/zones/custom_nameservers.py index b4632a7aaf3..2fe3e2743b5 100644 --- a/src/cloudflare/resources/zones/custom_nameservers.py +++ b/src/cloudflare/resources/zones/custom_nameservers.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform +from ..._utils import path_template, maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> CustomNameserversResourceWithStreamingRespo def update( self, *, - zone_id: str, + zone_id: str | None = None, enabled: bool | Omit = omit, ns_set: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -86,10 +86,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_ns", + path_template("/zones/{zone_id}/custom_ns", zone_id=zone_id), page=SyncSinglePage[CustomNameserverUpdateResponse], body=maybe_transform( { @@ -111,7 +113,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -136,10 +138,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/custom_ns", + path_template("/zones/{zone_id}/custom_ns", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -173,7 +177,7 @@ def with_streaming_response(self) -> AsyncCustomNameserversResourceWithStreaming def update( self, *, - zone_id: str, + zone_id: str | None = None, enabled: bool | Omit = omit, ns_set: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -208,10 +212,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/custom_ns", + path_template("/zones/{zone_id}/custom_ns", zone_id=zone_id), page=AsyncSinglePage[CustomNameserverUpdateResponse], body=maybe_transform( { @@ -233,7 +239,7 @@ def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -258,10 +264,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/custom_ns", + path_template("/zones/{zone_id}/custom_ns", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/resources/zones/environments.py b/src/cloudflare/resources/zones/environments.py index 3e044cbb64b..47ca8b06133 100644 --- a/src/cloudflare/resources/zones/environments.py +++ b/src/cloudflare/resources/zones/environments.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -52,7 +52,7 @@ def with_streaming_response(self) -> EnvironmentsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, environments: Iterable[environment_create_params.Environment], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -73,10 +73,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/environments", + path_template("/zones/{zone_id}/environments", zone_id=zone_id), body=maybe_transform({"environments": environments}, environment_create_params.EnvironmentCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -91,7 +93,7 @@ def create( def update( self, *, - zone_id: str, + zone_id: str | None = None, environments: Iterable[environment_update_params.Environment], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -112,10 +114,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/environments", + path_template("/zones/{zone_id}/environments", zone_id=zone_id), body=maybe_transform({"environments": environments}, environment_update_params.EnvironmentUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -130,7 +134,7 @@ def update( def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -150,10 +154,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/environments", + path_template("/zones/{zone_id}/environments", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -168,7 +174,7 @@ def delete( self, environment_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -188,12 +194,16 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not environment_id: raise ValueError(f"Expected a non-empty value for `environment_id` but received {environment_id!r}") return self._delete( - f"/zones/{zone_id}/environments/{environment_id}", + path_template( + "/zones/{zone_id}/environments/{environment_id}", zone_id=zone_id, environment_id=environment_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -207,7 +217,7 @@ def delete( def edit( self, *, - zone_id: str, + zone_id: str | None = None, environments: Iterable[environment_edit_params.Environment], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -228,10 +238,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/environments", + path_template("/zones/{zone_id}/environments", zone_id=zone_id), body=maybe_transform({"environments": environments}, environment_edit_params.EnvironmentEditParams), options=make_request_options( extra_headers=extra_headers, @@ -247,7 +259,7 @@ def rollback( self, environment_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -267,12 +279,18 @@ def rollback( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not environment_id: raise ValueError(f"Expected a non-empty value for `environment_id` but received {environment_id!r}") return self._post( - f"/zones/{zone_id}/environments/{environment_id}/rollback", + path_template( + "/zones/{zone_id}/environments/{environment_id}/rollback", + zone_id=zone_id, + environment_id=environment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -307,7 +325,7 @@ def with_streaming_response(self) -> AsyncEnvironmentsResourceWithStreamingRespo async def create( self, *, - zone_id: str, + zone_id: str | None = None, environments: Iterable[environment_create_params.Environment], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -328,10 +346,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/environments", + path_template("/zones/{zone_id}/environments", zone_id=zone_id), body=await async_maybe_transform( {"environments": environments}, environment_create_params.EnvironmentCreateParams ), @@ -348,7 +368,7 @@ async def create( async def update( self, *, - zone_id: str, + zone_id: str | None = None, environments: Iterable[environment_update_params.Environment], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -369,10 +389,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/environments", + path_template("/zones/{zone_id}/environments", zone_id=zone_id), body=await async_maybe_transform( {"environments": environments}, environment_update_params.EnvironmentUpdateParams ), @@ -389,7 +411,7 @@ async def update( async def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -409,10 +431,12 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/environments", + path_template("/zones/{zone_id}/environments", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -427,7 +451,7 @@ async def delete( self, environment_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -447,12 +471,16 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not environment_id: raise ValueError(f"Expected a non-empty value for `environment_id` but received {environment_id!r}") return await self._delete( - f"/zones/{zone_id}/environments/{environment_id}", + path_template( + "/zones/{zone_id}/environments/{environment_id}", zone_id=zone_id, environment_id=environment_id + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -466,7 +494,7 @@ async def delete( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, environments: Iterable[environment_edit_params.Environment], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -487,10 +515,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/environments", + path_template("/zones/{zone_id}/environments", zone_id=zone_id), body=await async_maybe_transform( {"environments": environments}, environment_edit_params.EnvironmentEditParams ), @@ -508,7 +538,7 @@ async def rollback( self, environment_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -528,12 +558,18 @@ async def rollback( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not environment_id: raise ValueError(f"Expected a non-empty value for `environment_id` but received {environment_id!r}") return await self._post( - f"/zones/{zone_id}/environments/{environment_id}/rollback", + path_template( + "/zones/{zone_id}/environments/{environment_id}/rollback", + zone_id=zone_id, + environment_id=environment_id, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zones/holds.py b/src/cloudflare/resources/zones/holds.py index 788b8bf77d2..74b25ab3843 100644 --- a/src/cloudflare/resources/zones/holds.py +++ b/src/cloudflare/resources/zones/holds.py @@ -7,7 +7,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -47,7 +47,7 @@ def with_streaming_response(self) -> HoldsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, include_subdomains: 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. @@ -76,10 +76,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/hold", + path_template("/zones/{zone_id}/hold", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -94,7 +96,7 @@ def create( def delete( self, *, - zone_id: str, + zone_id: str | None = None, hold_after: 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. @@ -122,10 +124,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/hold", + path_template("/zones/{zone_id}/hold", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -140,7 +144,7 @@ def delete( def edit( self, *, - zone_id: str, + zone_id: str | None = None, hold_after: str | Omit = omit, include_subdomains: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -176,10 +180,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/hold", + path_template("/zones/{zone_id}/hold", zone_id=zone_id), body=maybe_transform( { "hold_after": hold_after, @@ -200,7 +206,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -223,10 +229,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/hold", + path_template("/zones/{zone_id}/hold", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -261,7 +269,7 @@ def with_streaming_response(self) -> AsyncHoldsResourceWithStreamingResponse: async def create( self, *, - zone_id: str, + zone_id: str | None = None, include_subdomains: 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. @@ -290,10 +298,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/hold", + path_template("/zones/{zone_id}/hold", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -310,7 +320,7 @@ async def create( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, hold_after: 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. @@ -338,10 +348,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/hold", + path_template("/zones/{zone_id}/hold", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -356,7 +368,7 @@ async def delete( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, hold_after: str | Omit = omit, include_subdomains: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -392,10 +404,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/hold", + path_template("/zones/{zone_id}/hold", zone_id=zone_id), body=await async_maybe_transform( { "hold_after": hold_after, @@ -416,7 +430,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -439,10 +453,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/hold", + path_template("/zones/{zone_id}/hold", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zones/plans.py b/src/cloudflare/resources/zones/plans.py index 907f8eb216d..8803d47e872 100644 --- a/src/cloudflare/resources/zones/plans.py +++ b/src/cloudflare/resources/zones/plans.py @@ -7,6 +7,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -46,7 +47,7 @@ def with_streaming_response(self) -> PlansResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -68,10 +69,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/available_plans", + path_template("/zones/{zone_id}/available_plans", zone_id=zone_id), page=SyncSinglePage[AvailableRatePlan], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -83,7 +86,7 @@ def get( self, plan_identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -107,12 +110,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not plan_identifier: raise ValueError(f"Expected a non-empty value for `plan_identifier` but received {plan_identifier!r}") return self._get( - f"/zones/{zone_id}/available_plans/{plan_identifier}", + path_template( + "/zones/{zone_id}/available_plans/{plan_identifier}", zone_id=zone_id, plan_identifier=plan_identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -147,7 +154,7 @@ def with_streaming_response(self) -> AsyncPlansResourceWithStreamingResponse: def list( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -169,10 +176,12 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/available_plans", + path_template("/zones/{zone_id}/available_plans", zone_id=zone_id), page=AsyncSinglePage[AvailableRatePlan], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -184,7 +193,7 @@ async def get( self, plan_identifier: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -208,12 +217,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not plan_identifier: raise ValueError(f"Expected a non-empty value for `plan_identifier` but received {plan_identifier!r}") return await self._get( - f"/zones/{zone_id}/available_plans/{plan_identifier}", + path_template( + "/zones/{zone_id}/available_plans/{plan_identifier}", zone_id=zone_id, plan_identifier=plan_identifier + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zones/rate_plans.py b/src/cloudflare/resources/zones/rate_plans.py index 0cf59d0d07a..a478f50d6ed 100644 --- a/src/cloudflare/resources/zones/rate_plans.py +++ b/src/cloudflare/resources/zones/rate_plans.py @@ -5,6 +5,7 @@ import httpx from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import path_template from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -43,7 +44,7 @@ def with_streaming_response(self) -> RatePlansResourceWithStreamingResponse: def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -65,10 +66,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/available_rate_plans", + path_template("/zones/{zone_id}/available_rate_plans", zone_id=zone_id), page=SyncSinglePage[RatePlanGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -100,7 +103,7 @@ def with_streaming_response(self) -> AsyncRatePlansResourceWithStreamingResponse def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -122,10 +125,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/available_rate_plans", + path_template("/zones/{zone_id}/available_rate_plans", zone_id=zone_id), page=AsyncSinglePage[RatePlanGetResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/cloudflare/resources/zones/settings.py b/src/cloudflare/resources/zones/settings.py index 0c7fc85891b..30c70858fc3 100644 --- a/src/cloudflare/resources/zones/settings.py +++ b/src/cloudflare/resources/zones/settings.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def edit( self, setting_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -85,7 +85,7 @@ def edit( self, setting_id: str, *, - zone_id: str, + zone_id: str | None = None, value: setting_edit_params.Variant1Value | 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. @@ -114,12 +114,11 @@ def edit( """ ... - @required_args(["zone_id"]) def edit( self, setting_id: str, *, - zone_id: str, + zone_id: str | None = None, enabled: bool | Omit = omit, value: setting_edit_params.Variant1Value | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -129,6 +128,8 @@ def edit( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[SettingEditResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: @@ -136,7 +137,7 @@ def edit( return cast( Optional[SettingEditResponse], self._patch( - f"/zones/{zone_id}/settings/{setting_id}", + path_template("/zones/{zone_id}/settings/{setting_id}", zone_id=zone_id, setting_id=setting_id), body=maybe_transform( { "enabled": enabled, @@ -161,7 +162,7 @@ def get( self, setting_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -185,6 +186,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: @@ -192,7 +195,7 @@ def get( return cast( Optional[SettingGetResponse], self._get( - f"/zones/{zone_id}/settings/{setting_id}", + path_template("/zones/{zone_id}/settings/{setting_id}", zone_id=zone_id, setting_id=setting_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -232,7 +235,7 @@ async def edit( self, setting_id: str, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -266,7 +269,7 @@ async def edit( self, setting_id: str, *, - zone_id: str, + zone_id: str | None = None, value: setting_edit_params.Variant1Value | 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. @@ -295,12 +298,11 @@ async def edit( """ ... - @required_args(["zone_id"]) async def edit( self, setting_id: str, *, - zone_id: str, + zone_id: str | None = None, enabled: bool | Omit = omit, value: setting_edit_params.Variant1Value | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -310,6 +312,8 @@ async def edit( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[SettingEditResponse]: + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: @@ -317,7 +321,7 @@ async def edit( return cast( Optional[SettingEditResponse], await self._patch( - f"/zones/{zone_id}/settings/{setting_id}", + path_template("/zones/{zone_id}/settings/{setting_id}", zone_id=zone_id, setting_id=setting_id), body=await async_maybe_transform( { "enabled": enabled, @@ -342,7 +346,7 @@ async def get( self, setting_id: str, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -366,6 +370,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not setting_id: @@ -373,7 +379,7 @@ async def get( return cast( Optional[SettingGetResponse], await self._get( - f"/zones/{zone_id}/settings/{setting_id}", + path_template("/zones/{zone_id}/settings/{setting_id}", zone_id=zone_id, setting_id=setting_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zones/subscriptions.py b/src/cloudflare/resources/zones/subscriptions.py index 78acb39ee35..dcb79a6de34 100644 --- a/src/cloudflare/resources/zones/subscriptions.py +++ b/src/cloudflare/resources/zones/subscriptions.py @@ -8,7 +8,7 @@ import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -51,7 +51,7 @@ def with_streaming_response(self) -> SubscriptionsResourceWithStreamingResponse: def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -79,10 +79,12 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/subscription", + path_template("/zones/{zone_id}/subscription", zone_id=zone_id), body=maybe_transform( { "frequency": frequency, @@ -103,7 +105,7 @@ def create( def update( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -131,10 +133,12 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._put( - f"/zones/{zone_id}/subscription", + path_template("/zones/{zone_id}/subscription", zone_id=zone_id), body=maybe_transform( { "frequency": frequency, @@ -155,7 +159,7 @@ def update( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -177,10 +181,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}/subscription", + path_template("/zones/{zone_id}/subscription", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -215,7 +221,7 @@ def with_streaming_response(self) -> AsyncSubscriptionsResourceWithStreamingResp async def create( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -243,10 +249,12 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}/subscription", + path_template("/zones/{zone_id}/subscription", zone_id=zone_id), body=await async_maybe_transform( { "frequency": frequency, @@ -267,7 +275,7 @@ async def create( async def update( self, *, - zone_id: str, + zone_id: str | None = None, 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. @@ -295,10 +303,12 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._put( - f"/zones/{zone_id}/subscription", + path_template("/zones/{zone_id}/subscription", zone_id=zone_id), body=await async_maybe_transform( { "frequency": frequency, @@ -319,7 +329,7 @@ async def update( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -341,10 +351,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}/subscription", + path_template("/zones/{zone_id}/subscription", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/zones/zones.py b/src/cloudflare/resources/zones/zones.py index 271bcef52db..2ac3421c63c 100644 --- a/src/cloudflare/resources/zones/zones.py +++ b/src/cloudflare/resources/zones/zones.py @@ -24,7 +24,7 @@ AsyncPlansResourceWithStreamingResponse, ) from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ..._utils import maybe_transform, async_maybe_transform +from ..._utils import path_template, maybe_transform, async_maybe_transform from .settings import ( SettingsResource, AsyncSettingsResource, @@ -282,7 +282,7 @@ def list( def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -304,10 +304,12 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}", + path_template("/zones/{zone_id}", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -321,7 +323,7 @@ def delete( def edit( self, *, - zone_id: str, + zone_id: str | None = None, paused: bool | Omit = omit, type: Literal["full", "partial", "secondary", "internal"] | Omit = omit, vanity_name_servers: SequenceNotStr[str] | Omit = omit, @@ -358,10 +360,12 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}", + path_template("/zones/{zone_id}", zone_id=zone_id), body=maybe_transform( { "paused": paused, @@ -383,7 +387,7 @@ def edit( def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -405,10 +409,12 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get( - f"/zones/{zone_id}", + path_template("/zones/{zone_id}", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -610,7 +616,7 @@ def list( async def delete( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -632,10 +638,12 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}", + path_template("/zones/{zone_id}", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -649,7 +657,7 @@ async def delete( async def edit( self, *, - zone_id: str, + zone_id: str | None = None, paused: bool | Omit = omit, type: Literal["full", "partial", "secondary", "internal"] | Omit = omit, vanity_name_servers: SequenceNotStr[str] | Omit = omit, @@ -686,10 +694,12 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() 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}", + path_template("/zones/{zone_id}", zone_id=zone_id), body=await async_maybe_transform( { "paused": paused, @@ -711,7 +721,7 @@ async def edit( async def get( self, *, - zone_id: str, + zone_id: str | None = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -733,10 +743,12 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if zone_id is None: + zone_id = self._client._get_zone_id_path_param() if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._get( - f"/zones/{zone_id}", + path_template("/zones/{zone_id}", zone_id=zone_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/types/abuse_reports/abuse_report_create_params.py b/src/cloudflare/types/abuse_reports/abuse_report_create_params.py index 69e21aeea82..6da2f0430a1 100644 --- a/src/cloudflare/types/abuse_reports/abuse_report_create_params.py +++ b/src/cloudflare/types/abuse_reports/abuse_report_create_params.py @@ -20,7 +20,7 @@ class AbuseReportsDmcaReport(TypedDict, total=False): - account_id: Required[str] + account_id: str act: Required[Literal["abuse_dmca"]] """The report type for submitted reports.""" @@ -142,7 +142,7 @@ class AbuseReportsDmcaReport(TypedDict, total=False): class AbuseReportsTrademarkReport(TypedDict, total=False): - account_id: Required[str] + account_id: str act: Required[Literal["abuse_trademark"]] """The report type for submitted reports.""" @@ -228,7 +228,7 @@ class AbuseReportsTrademarkReport(TypedDict, total=False): class AbuseReportsGeneralReport(TypedDict, total=False): - account_id: Required[str] + account_id: str act: Required[Literal["abuse_general"]] """The report type for submitted reports.""" @@ -327,7 +327,7 @@ class AbuseReportsGeneralReport(TypedDict, total=False): class AbuseReportsPhishingReport(TypedDict, total=False): - account_id: Required[str] + account_id: str act: Required[Literal["abuse_phishing"]] """The report type for submitted reports.""" @@ -411,7 +411,7 @@ class AbuseReportsPhishingReport(TypedDict, total=False): class AbuseReportsCsamReport(TypedDict, total=False): - account_id: Required[str] + account_id: str act: Required[Literal["abuse_children"]] """The report type for submitted reports.""" @@ -501,7 +501,7 @@ class AbuseReportsCsamReport(TypedDict, total=False): class AbuseReportsThreatReport(TypedDict, total=False): - account_id: Required[str] + account_id: str act: Required[Literal["abuse_threat"]] """The report type for submitted reports.""" @@ -578,7 +578,7 @@ class AbuseReportsThreatReport(TypedDict, total=False): class AbuseReportsRegistrarWhoisReport(TypedDict, total=False): - account_id: Required[str] + account_id: str act: Required[Literal["abuse_registrar_whois"]] """The report type for submitted reports.""" @@ -701,7 +701,7 @@ class AbuseReportsRegistrarWhoisReportRegWhoRequest(TypedDict, total=False): class AbuseReportsNcseiReport(TypedDict, total=False): - account_id: Required[str] + account_id: str act: Required[Literal["abuse_ncsei"]] """The report type for submitted reports.""" diff --git a/src/cloudflare/types/abuse_reports/abuse_report_list_params.py b/src/cloudflare/types/abuse_reports/abuse_report_list_params.py index 94ececff967..2079f7b70ef 100644 --- a/src/cloudflare/types/abuse_reports/abuse_report_list_params.py +++ b/src/cloudflare/types/abuse_reports/abuse_report_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["AbuseReportListParams"] class AbuseReportListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str created_after: str """Returns reports created after the specified date""" diff --git a/src/cloudflare/types/abuse_reports/mitigation_list_params.py b/src/cloudflare/types/abuse_reports/mitigation_list_params.py index 4093a07c4fb..9ec2264ce3a 100644 --- a/src/cloudflare/types/abuse_reports/mitigation_list_params.py +++ b/src/cloudflare/types/abuse_reports/mitigation_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["MitigationListParams"] class MitigationListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str effective_after: str """Returns mitigation that were dispatched after the given date""" diff --git a/src/cloudflare/types/abuse_reports/mitigation_review_params.py b/src/cloudflare/types/abuse_reports/mitigation_review_params.py index 93cdff5c1ad..f9beba3f9ce 100644 --- a/src/cloudflare/types/abuse_reports/mitigation_review_params.py +++ b/src/cloudflare/types/abuse_reports/mitigation_review_params.py @@ -9,7 +9,7 @@ class MitigationReviewParams(TypedDict, total=False): - account_id: Required[str] + account_id: str appeals: Required[Iterable[Appeal]] """List of mitigations to appeal.""" diff --git a/src/cloudflare/types/accounts/account_update_params.py b/src/cloudflare/types/accounts/account_update_params.py index d0cb3859d99..c9be1bd5274 100644 --- a/src/cloudflare/types/accounts/account_update_params.py +++ b/src/cloudflare/types/accounts/account_update_params.py @@ -8,7 +8,7 @@ class AccountUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" id: Required[str] diff --git a/src/cloudflare/types/accounts/logs/audit_list_params.py b/src/cloudflare/types/accounts/logs/audit_list_params.py index 39350b1f6b0..0e7c3af761d 100644 --- a/src/cloudflare/types/accounts/logs/audit_list_params.py +++ b/src/cloudflare/types/accounts/logs/audit_list_params.py @@ -37,7 +37,7 @@ class AuditListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The unique id that identifies the account.""" before: Required[Annotated[Union[str, date], PropertyInfo(format="iso8601")]] diff --git a/src/cloudflare/types/accounts/member_create_params.py b/src/cloudflare/types/accounts/member_create_params.py index 48c257c5826..268f388074f 100644 --- a/src/cloudflare/types/accounts/member_create_params.py +++ b/src/cloudflare/types/accounts/member_create_params.py @@ -18,7 +18,7 @@ class IAMCreateMemberWithRoles(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" email: Required[str] @@ -37,7 +37,7 @@ class IAMCreateMemberWithRoles(TypedDict, total=False): class IAMCreateMemberWithPolicies(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" email: Required[str] diff --git a/src/cloudflare/types/accounts/member_list_params.py b/src/cloudflare/types/accounts/member_list_params.py index cda9328b103..989647d59bd 100644 --- a/src/cloudflare/types/accounts/member_list_params.py +++ b/src/cloudflare/types/accounts/member_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["MemberListParams"] class MemberListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/accounts/member_update_params.py b/src/cloudflare/types/accounts/member_update_params.py index 6c0a304dce1..0ef14ca6b20 100644 --- a/src/cloudflare/types/accounts/member_update_params.py +++ b/src/cloudflare/types/accounts/member_update_params.py @@ -18,7 +18,7 @@ class IAMUpdateMemberWithRoles(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" roles: Iterable[Role] @@ -26,7 +26,7 @@ class IAMUpdateMemberWithRoles(TypedDict, total=False): class IAMUpdateMemberWithPolicies(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" policies: Required[Iterable[IAMUpdateMemberWithPoliciesPolicy]] diff --git a/src/cloudflare/types/accounts/role_list_params.py b/src/cloudflare/types/accounts/role_list_params.py index d4e5289bbec..5cd701000fd 100644 --- a/src/cloudflare/types/accounts/role_list_params.py +++ b/src/cloudflare/types/accounts/role_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["RoleListParams"] class RoleListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" page: float diff --git a/src/cloudflare/types/accounts/subscription_create_params.py b/src/cloudflare/types/accounts/subscription_create_params.py index 8e1e503d9f6..fdf9a7d20de 100644 --- a/src/cloudflare/types/accounts/subscription_create_params.py +++ b/src/cloudflare/types/accounts/subscription_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..shared_params.rate_plan import RatePlan @@ -10,7 +10,7 @@ class SubscriptionCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" frequency: Literal["weekly", "monthly", "quarterly", "yearly"] diff --git a/src/cloudflare/types/accounts/subscription_update_params.py b/src/cloudflare/types/accounts/subscription_update_params.py index fa42b5e2337..aefe3999115 100644 --- a/src/cloudflare/types/accounts/subscription_update_params.py +++ b/src/cloudflare/types/accounts/subscription_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..shared_params.rate_plan import RatePlan @@ -10,7 +10,7 @@ class SubscriptionUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" frequency: Literal["weekly", "monthly", "quarterly", "yearly"] diff --git a/src/cloudflare/types/accounts/token_create_params.py b/src/cloudflare/types/accounts/token_create_params.py index 6ff13271545..a8d61bb29a4 100644 --- a/src/cloudflare/types/accounts/token_create_params.py +++ b/src/cloudflare/types/accounts/token_create_params.py @@ -15,7 +15,7 @@ class TokenCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: Required[str] diff --git a/src/cloudflare/types/accounts/token_list_params.py b/src/cloudflare/types/accounts/token_list_params.py index 7a9ded98d9e..92ec000db2b 100644 --- a/src/cloudflare/types/accounts/token_list_params.py +++ b/src/cloudflare/types/accounts/token_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["TokenListParams"] class TokenListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/accounts/token_update_params.py b/src/cloudflare/types/accounts/token_update_params.py index 524886308b0..28b5cd4a7b9 100644 --- a/src/cloudflare/types/accounts/token_update_params.py +++ b/src/cloudflare/types/accounts/token_update_params.py @@ -15,7 +15,7 @@ class TokenUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: Required[str] diff --git a/src/cloudflare/types/accounts/tokens/permission_group_get_params.py b/src/cloudflare/types/accounts/tokens/permission_group_get_params.py index c91ca4db066..aa19a3a33e5 100644 --- a/src/cloudflare/types/accounts/tokens/permission_group_get_params.py +++ b/src/cloudflare/types/accounts/tokens/permission_group_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PermissionGroupGetParams"] class PermissionGroupGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: str diff --git a/src/cloudflare/types/accounts/tokens/permission_group_list_params.py b/src/cloudflare/types/accounts/tokens/permission_group_list_params.py index 3a3000cb8a6..3bb553cb6b8 100644 --- a/src/cloudflare/types/accounts/tokens/permission_group_list_params.py +++ b/src/cloudflare/types/accounts/tokens/permission_group_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PermissionGroupListParams"] class PermissionGroupListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: str diff --git a/src/cloudflare/types/accounts/tokens/value_update_params.py b/src/cloudflare/types/accounts/tokens/value_update_params.py index a70fab2ae59..5fa0d36db1e 100644 --- a/src/cloudflare/types/accounts/tokens/value_update_params.py +++ b/src/cloudflare/types/accounts/tokens/value_update_params.py @@ -8,7 +8,7 @@ class ValueUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" body: Required[object] diff --git a/src/cloudflare/types/acm/custom_trust_store_create_params.py b/src/cloudflare/types/acm/custom_trust_store_create_params.py index 38498ed17fa..c715264411d 100644 --- a/src/cloudflare/types/acm/custom_trust_store_create_params.py +++ b/src/cloudflare/types/acm/custom_trust_store_create_params.py @@ -8,7 +8,7 @@ class CustomTrustStoreCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" certificate: Required[str] diff --git a/src/cloudflare/types/acm/custom_trust_store_list_params.py b/src/cloudflare/types/acm/custom_trust_store_list_params.py index 065c67d4223..4e069f99aa6 100644 --- a/src/cloudflare/types/acm/custom_trust_store_list_params.py +++ b/src/cloudflare/types/acm/custom_trust_store_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CustomTrustStoreListParams"] class CustomTrustStoreListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" limit: int diff --git a/src/cloudflare/types/acm/total_tls_edit_params.py b/src/cloudflare/types/acm/total_tls_edit_params.py index defd75ebdd5..c7089a514a2 100644 --- a/src/cloudflare/types/acm/total_tls_edit_params.py +++ b/src/cloudflare/types/acm/total_tls_edit_params.py @@ -10,7 +10,7 @@ class TotalTLSEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" enabled: Required[bool] diff --git a/src/cloudflare/types/acm/total_tls_update_params.py b/src/cloudflare/types/acm/total_tls_update_params.py index 8a100d6e937..4c0d557071a 100644 --- a/src/cloudflare/types/acm/total_tls_update_params.py +++ b/src/cloudflare/types/acm/total_tls_update_params.py @@ -10,7 +10,7 @@ class TotalTLSUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" enabled: Required[bool] diff --git a/src/cloudflare/types/addressing/address_map_create_params.py b/src/cloudflare/types/addressing/address_map_create_params.py index 7437032d536..913a5083f87 100644 --- a/src/cloudflare/types/addressing/address_map_create_params.py +++ b/src/cloudflare/types/addressing/address_map_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from .kind import Kind from ..._types import SequenceNotStr @@ -12,7 +12,7 @@ class AddressMapCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" description: Optional[str] diff --git a/src/cloudflare/types/addressing/address_map_edit_params.py b/src/cloudflare/types/addressing/address_map_edit_params.py index 78a94270693..71d12374080 100644 --- a/src/cloudflare/types/addressing/address_map_edit_params.py +++ b/src/cloudflare/types/addressing/address_map_edit_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["AddressMapEditParams"] class AddressMapEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" default_sni: Optional[str] diff --git a/src/cloudflare/types/addressing/address_maps/account_update_params.py b/src/cloudflare/types/addressing/address_maps/account_update_params.py index ff618f7f917..f6653e3529d 100644 --- a/src/cloudflare/types/addressing/address_maps/account_update_params.py +++ b/src/cloudflare/types/addressing/address_maps/account_update_params.py @@ -8,7 +8,7 @@ class AccountUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" body: Required[object] diff --git a/src/cloudflare/types/addressing/address_maps/ip_update_params.py b/src/cloudflare/types/addressing/address_maps/ip_update_params.py index 7c4e1611411..316a85b34a0 100644 --- a/src/cloudflare/types/addressing/address_maps/ip_update_params.py +++ b/src/cloudflare/types/addressing/address_maps/ip_update_params.py @@ -8,7 +8,7 @@ class IPUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" address_map_id: Required[str] diff --git a/src/cloudflare/types/addressing/address_maps/zone_update_params.py b/src/cloudflare/types/addressing/address_maps/zone_update_params.py index 04047f85fc0..90092ef4ab9 100644 --- a/src/cloudflare/types/addressing/address_maps/zone_update_params.py +++ b/src/cloudflare/types/addressing/address_maps/zone_update_params.py @@ -8,10 +8,10 @@ class ZoneUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier of a zone.""" - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" body: Required[object] diff --git a/src/cloudflare/types/addressing/loa_document_create_params.py b/src/cloudflare/types/addressing/loa_document_create_params.py index 3ea6bd6de69..5abde543b68 100644 --- a/src/cloudflare/types/addressing/loa_document_create_params.py +++ b/src/cloudflare/types/addressing/loa_document_create_params.py @@ -8,7 +8,7 @@ class LOADocumentCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" loa_document: Required[str] diff --git a/src/cloudflare/types/addressing/prefix_create_params.py b/src/cloudflare/types/addressing/prefix_create_params.py index 86828ed1d96..5d936970e95 100644 --- a/src/cloudflare/types/addressing/prefix_create_params.py +++ b/src/cloudflare/types/addressing/prefix_create_params.py @@ -9,7 +9,7 @@ class PrefixCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" asn: Required[int] diff --git a/src/cloudflare/types/addressing/prefix_edit_params.py b/src/cloudflare/types/addressing/prefix_edit_params.py index b1ad60bb46f..427aba530f6 100644 --- a/src/cloudflare/types/addressing/prefix_edit_params.py +++ b/src/cloudflare/types/addressing/prefix_edit_params.py @@ -8,7 +8,7 @@ class PrefixEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" description: Required[str] diff --git a/src/cloudflare/types/addressing/prefixes/advertisement_status_edit_params.py b/src/cloudflare/types/addressing/prefixes/advertisement_status_edit_params.py index 5de84a7f1d0..e4291a1824c 100644 --- a/src/cloudflare/types/addressing/prefixes/advertisement_status_edit_params.py +++ b/src/cloudflare/types/addressing/prefixes/advertisement_status_edit_params.py @@ -8,7 +8,7 @@ class AdvertisementStatusEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" advertised: Required[bool] diff --git a/src/cloudflare/types/addressing/prefixes/bgp_prefix_create_params.py b/src/cloudflare/types/addressing/prefixes/bgp_prefix_create_params.py index dc9d548929e..ad51e52473a 100644 --- a/src/cloudflare/types/addressing/prefixes/bgp_prefix_create_params.py +++ b/src/cloudflare/types/addressing/prefixes/bgp_prefix_create_params.py @@ -8,7 +8,7 @@ class BGPPrefixCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" cidr: Required[str] diff --git a/src/cloudflare/types/addressing/prefixes/bgp_prefix_edit_params.py b/src/cloudflare/types/addressing/prefixes/bgp_prefix_edit_params.py index f610ee9434f..6f30da96697 100644 --- a/src/cloudflare/types/addressing/prefixes/bgp_prefix_edit_params.py +++ b/src/cloudflare/types/addressing/prefixes/bgp_prefix_edit_params.py @@ -8,7 +8,7 @@ class BGPPrefixEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" prefix_id: Required[str] diff --git a/src/cloudflare/types/addressing/prefixes/delegation_create_params.py b/src/cloudflare/types/addressing/prefixes/delegation_create_params.py index 948fe969d3e..93e1d52a831 100644 --- a/src/cloudflare/types/addressing/prefixes/delegation_create_params.py +++ b/src/cloudflare/types/addressing/prefixes/delegation_create_params.py @@ -8,7 +8,7 @@ class DelegationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" cidr: Required[str] diff --git a/src/cloudflare/types/addressing/prefixes/service_binding_create_params.py b/src/cloudflare/types/addressing/prefixes/service_binding_create_params.py index ed098c0dc4f..ed6fcf509f9 100644 --- a/src/cloudflare/types/addressing/prefixes/service_binding_create_params.py +++ b/src/cloudflare/types/addressing/prefixes/service_binding_create_params.py @@ -8,7 +8,7 @@ class ServiceBindingCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of a Cloudflare account.""" cidr: Required[str] diff --git a/src/cloudflare/types/addressing/regional_hostname_create_params.py b/src/cloudflare/types/addressing/regional_hostname_create_params.py index c462c98f63d..131b0475ba5 100644 --- a/src/cloudflare/types/addressing/regional_hostname_create_params.py +++ b/src/cloudflare/types/addressing/regional_hostname_create_params.py @@ -8,7 +8,7 @@ class RegionalHostnameCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" hostname: Required[str] diff --git a/src/cloudflare/types/addressing/regional_hostname_edit_params.py b/src/cloudflare/types/addressing/regional_hostname_edit_params.py index 822196cf6af..6da57bb9b05 100644 --- a/src/cloudflare/types/addressing/regional_hostname_edit_params.py +++ b/src/cloudflare/types/addressing/regional_hostname_edit_params.py @@ -8,7 +8,7 @@ class RegionalHostnameEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" region_key: Required[str] diff --git a/src/cloudflare/types/ai/ai_run_params.py b/src/cloudflare/types/ai/ai_run_params.py index 6ce24ce4ae0..af5343696af 100644 --- a/src/cloudflare/types/ai/ai_run_params.py +++ b/src/cloudflare/types/ai/ai_run_params.py @@ -44,14 +44,14 @@ class TextClassification(TypedDict, total=False): - account_id: Required[str] + account_id: str text: Required[str] """The text that you want to classify""" class TextToImage(TypedDict, total=False): - account_id: Required[str] + account_id: str prompt: Required[str] """A text description of the image you want to generate""" @@ -103,7 +103,7 @@ class TextToImage(TypedDict, total=False): class TextToSpeech(TypedDict, total=False): - account_id: Required[str] + account_id: str prompt: Required[str] """A text description of the audio you want to generate""" @@ -116,14 +116,14 @@ class TextToSpeech(TypedDict, total=False): class TextEmbeddings(TypedDict, total=False): - account_id: Required[str] + account_id: str text: Required[Union[str, SequenceNotStr[str]]] """The text to embed""" class AutomaticSpeechRecognition(TypedDict, total=False): - account_id: Required[str] + account_id: str audio: Required[Iterable[float]] """ @@ -142,7 +142,7 @@ class AutomaticSpeechRecognition(TypedDict, total=False): class ImageClassification(TypedDict, total=False): - account_id: Required[str] + account_id: str image: Required[Iterable[float]] """ @@ -152,7 +152,7 @@ class ImageClassification(TypedDict, total=False): class ObjectDetection(TypedDict, total=False): - account_id: Required[str] + account_id: str image: Iterable[float] """ @@ -162,7 +162,7 @@ class ObjectDetection(TypedDict, total=False): class Prompt(TypedDict, total=False): - account_id: Required[str] + account_id: str prompt: Required[str] """The input text prompt for the model to generate a response.""" @@ -227,7 +227,7 @@ class PromptResponseFormat(TypedDict, total=False): class Messages(TypedDict, total=False): - account_id: Required[str] + account_id: str messages: Required[Iterable[MessagesMessage]] """An array of message objects representing the conversation history.""" @@ -393,7 +393,7 @@ class MessagesToolFunction(TypedDict, total=False): class Translation(TypedDict, total=False): - account_id: Required[str] + account_id: str target_lang: Required[str] """The language code to translate the text into (e.g., 'es' for Spanish)""" @@ -409,7 +409,7 @@ class Translation(TypedDict, total=False): class Summarization(TypedDict, total=False): - account_id: Required[str] + account_id: str input_text: Required[str] """The text that you want the model to summarize""" @@ -419,7 +419,7 @@ class Summarization(TypedDict, total=False): class ImageToText(TypedDict, total=False): - account_id: Required[str] + account_id: str image: Required[Iterable[float]] """ @@ -473,7 +473,7 @@ class ImageToText(TypedDict, total=False): class Variant12(TypedDict, total=False): - account_id: Required[str] + account_id: str image: Required[str] """Image in base64 encoded format.""" @@ -524,7 +524,7 @@ class Variant12(TypedDict, total=False): class Variant13(TypedDict, total=False): - account_id: Required[str] + account_id: str image: Required[str] """Image in base64 encoded format.""" @@ -601,7 +601,7 @@ class Variant13Message(TypedDict, total=False): class MultimodalEmbeddings(TypedDict, total=False): - account_id: Required[str] + account_id: str image: str """Image in base64 encoded format.""" diff --git a/src/cloudflare/types/ai/finetune_create_params.py b/src/cloudflare/types/ai/finetune_create_params.py index 84fc0d24f14..1c2bbbf1443 100644 --- a/src/cloudflare/types/ai/finetune_create_params.py +++ b/src/cloudflare/types/ai/finetune_create_params.py @@ -8,7 +8,7 @@ class FinetuneCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str model: Required[str] diff --git a/src/cloudflare/types/ai/finetunes/asset_create_params.py b/src/cloudflare/types/ai/finetunes/asset_create_params.py index 26f0da33305..7d6ab6665a0 100644 --- a/src/cloudflare/types/ai/finetunes/asset_create_params.py +++ b/src/cloudflare/types/ai/finetunes/asset_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ...._types import FileTypes @@ -10,7 +10,7 @@ class AssetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str file: FileTypes diff --git a/src/cloudflare/types/ai/finetunes/public_list_params.py b/src/cloudflare/types/ai/finetunes/public_list_params.py index c5a973eaf63..9097fa43f5f 100644 --- a/src/cloudflare/types/ai/finetunes/public_list_params.py +++ b/src/cloudflare/types/ai/finetunes/public_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._utils import PropertyInfo @@ -10,7 +10,7 @@ class PublicListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str limit: float """Pagination Limit""" diff --git a/src/cloudflare/types/ai/model_list_params.py b/src/cloudflare/types/ai/model_list_params.py index bcbc1d7bc05..3f892145b29 100644 --- a/src/cloudflare/types/ai/model_list_params.py +++ b/src/cloudflare/types/ai/model_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ModelListParams"] class ModelListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str author: str """Filter by Author""" diff --git a/src/cloudflare/types/ai/models/schema_get_params.py b/src/cloudflare/types/ai/models/schema_get_params.py index 92d676194ab..b0e257cb5fe 100644 --- a/src/cloudflare/types/ai/models/schema_get_params.py +++ b/src/cloudflare/types/ai/models/schema_get_params.py @@ -8,7 +8,7 @@ class SchemaGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str model: Required[str] """Model Name""" diff --git a/src/cloudflare/types/ai/to_markdown_transform_params.py b/src/cloudflare/types/ai/to_markdown_transform_params.py index 8a39a616882..070bddbacc5 100644 --- a/src/cloudflare/types/ai/to_markdown_transform_params.py +++ b/src/cloudflare/types/ai/to_markdown_transform_params.py @@ -10,7 +10,7 @@ class ToMarkdownTransformParams(TypedDict, total=False): - account_id: Required[str] + account_id: str file: Required[File] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py index d38ec3329b4..8bf93efc61c 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py @@ -9,7 +9,7 @@ class AIGatewayCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: Required[str] """gateway id""" diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py index a2545d4af8e..f7cdc20f0fe 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["AIGatewayListParams"] class AIGatewayListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: int diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py index 0843aea093a..3fdbd032a2c 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py @@ -20,7 +20,7 @@ class AIGatewayUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str cache_invalidate_on_update: Required[bool] diff --git a/src/cloudflare/types/ai_gateway/dataset_create_params.py b/src/cloudflare/types/ai_gateway/dataset_create_params.py index 8c558e8d20b..63e4e0cfe04 100644 --- a/src/cloudflare/types/ai_gateway/dataset_create_params.py +++ b/src/cloudflare/types/ai_gateway/dataset_create_params.py @@ -11,7 +11,7 @@ class DatasetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str enable: Required[bool] diff --git a/src/cloudflare/types/ai_gateway/dataset_list_params.py b/src/cloudflare/types/ai_gateway/dataset_list_params.py index 440331fa032..4dd0124632e 100644 --- a/src/cloudflare/types/ai_gateway/dataset_list_params.py +++ b/src/cloudflare/types/ai_gateway/dataset_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DatasetListParams"] class DatasetListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str enable: bool diff --git a/src/cloudflare/types/ai_gateway/dataset_update_params.py b/src/cloudflare/types/ai_gateway/dataset_update_params.py index 78abca5484d..2c55d29699e 100644 --- a/src/cloudflare/types/ai_gateway/dataset_update_params.py +++ b/src/cloudflare/types/ai_gateway/dataset_update_params.py @@ -11,7 +11,7 @@ class DatasetUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str gateway_id: Required[str] """gateway id""" diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_create_deployment_params.py b/src/cloudflare/types/ai_gateway/dynamic_routing_create_deployment_params.py index daf70ff0d0a..efc1813565a 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_create_deployment_params.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_create_deployment_params.py @@ -8,7 +8,7 @@ class DynamicRoutingCreateDeploymentParams(TypedDict, total=False): - account_id: Required[str] + account_id: str gateway_id: Required[str] diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_create_params.py b/src/cloudflare/types/ai_gateway/dynamic_routing_create_params.py index 135063ee111..8d8c537517f 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_create_params.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_create_params.py @@ -36,7 +36,7 @@ class DynamicRoutingCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str elements: Required[Iterable[Element]] diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_create_version_params.py b/src/cloudflare/types/ai_gateway/dynamic_routing_create_version_params.py index d2a41a7298b..ac281ff8a7a 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_create_version_params.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_create_version_params.py @@ -36,7 +36,7 @@ class DynamicRoutingCreateVersionParams(TypedDict, total=False): - account_id: Required[str] + account_id: str gateway_id: Required[str] diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_update_params.py b/src/cloudflare/types/ai_gateway/dynamic_routing_update_params.py index 75453811680..f0233f8fc52 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_update_params.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_update_params.py @@ -8,7 +8,7 @@ class DynamicRoutingUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str gateway_id: Required[str] diff --git a/src/cloudflare/types/ai_gateway/evaluation_create_params.py b/src/cloudflare/types/ai_gateway/evaluation_create_params.py index f434312dce7..5d22c2610e4 100644 --- a/src/cloudflare/types/ai_gateway/evaluation_create_params.py +++ b/src/cloudflare/types/ai_gateway/evaluation_create_params.py @@ -10,7 +10,7 @@ class EvaluationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str dataset_ids: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/ai_gateway/evaluation_list_params.py b/src/cloudflare/types/ai_gateway/evaluation_list_params.py index deefec45cbf..5fe10f3a91d 100644 --- a/src/cloudflare/types/ai_gateway/evaluation_list_params.py +++ b/src/cloudflare/types/ai_gateway/evaluation_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["EvaluationListParams"] class EvaluationListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: str diff --git a/src/cloudflare/types/ai_gateway/evaluation_type_list_params.py b/src/cloudflare/types/ai_gateway/evaluation_type_list_params.py index 5a03c32439c..4a046a65622 100644 --- a/src/cloudflare/types/ai_gateway/evaluation_type_list_params.py +++ b/src/cloudflare/types/ai_gateway/evaluation_type_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["EvaluationTypeListParams"] class EvaluationTypeListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str order_by: str diff --git a/src/cloudflare/types/ai_gateway/log_delete_params.py b/src/cloudflare/types/ai_gateway/log_delete_params.py index 2aa8a530b71..3b2159c033e 100644 --- a/src/cloudflare/types/ai_gateway/log_delete_params.py +++ b/src/cloudflare/types/ai_gateway/log_delete_params.py @@ -11,7 +11,7 @@ class LogDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str filters: Iterable[Filter] diff --git a/src/cloudflare/types/ai_gateway/log_edit_params.py b/src/cloudflare/types/ai_gateway/log_edit_params.py index 140b789b00c..32d19763ead 100644 --- a/src/cloudflare/types/ai_gateway/log_edit_params.py +++ b/src/cloudflare/types/ai_gateway/log_edit_params.py @@ -9,7 +9,7 @@ class LogEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str gateway_id: Required[str] """gateway id""" diff --git a/src/cloudflare/types/ai_gateway/log_list_params.py b/src/cloudflare/types/ai_gateway/log_list_params.py index b20feb3ae78..6a59df4ea5f 100644 --- a/src/cloudflare/types/ai_gateway/log_list_params.py +++ b/src/cloudflare/types/ai_gateway/log_list_params.py @@ -13,7 +13,7 @@ class LogListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str cached: bool diff --git a/src/cloudflare/types/ai_gateway/provider_config_create_params.py b/src/cloudflare/types/ai_gateway/provider_config_create_params.py index fecfe448bcb..3f8eaa66547 100644 --- a/src/cloudflare/types/ai_gateway/provider_config_create_params.py +++ b/src/cloudflare/types/ai_gateway/provider_config_create_params.py @@ -8,7 +8,7 @@ class ProviderConfigCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str alias: Required[str] diff --git a/src/cloudflare/types/ai_gateway/provider_config_list_params.py b/src/cloudflare/types/ai_gateway/provider_config_list_params.py index c1a36c2428a..6530539f80d 100644 --- a/src/cloudflare/types/ai_gateway/provider_config_list_params.py +++ b/src/cloudflare/types/ai_gateway/provider_config_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ProviderConfigListParams"] class ProviderConfigListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: int diff --git a/src/cloudflare/types/aisearch/__init__.py b/src/cloudflare/types/aisearch/__init__.py index 93509eebddb..b44a272c9ab 100644 --- a/src/cloudflare/types/aisearch/__init__.py +++ b/src/cloudflare/types/aisearch/__init__.py @@ -8,8 +8,8 @@ from .token_read_response import TokenReadResponse as TokenReadResponse from .token_update_params import TokenUpdateParams as TokenUpdateParams from .instance_list_params import InstanceListParams as InstanceListParams +from .namespace_list_params import NamespaceListParams as NamespaceListParams from .token_create_response import TokenCreateResponse as TokenCreateResponse -from .token_delete_response import TokenDeleteResponse as TokenDeleteResponse from .token_update_response import TokenUpdateResponse as TokenUpdateResponse from .instance_create_params import InstanceCreateParams as InstanceCreateParams from .instance_list_response import InstanceListResponse as InstanceListResponse @@ -17,9 +17,19 @@ from .instance_search_params import InstanceSearchParams as InstanceSearchParams from .instance_update_params import InstanceUpdateParams as InstanceUpdateParams from .instance_stats_response import InstanceStatsResponse as InstanceStatsResponse +from .namespace_create_params import NamespaceCreateParams as NamespaceCreateParams +from .namespace_list_response import NamespaceListResponse as NamespaceListResponse +from .namespace_read_response import NamespaceReadResponse as NamespaceReadResponse +from .namespace_search_params import NamespaceSearchParams as NamespaceSearchParams +from .namespace_update_params import NamespaceUpdateParams as NamespaceUpdateParams from .instance_create_response import InstanceCreateResponse as InstanceCreateResponse from .instance_delete_response import InstanceDeleteResponse as InstanceDeleteResponse from .instance_search_response import InstanceSearchResponse as InstanceSearchResponse from .instance_update_response import InstanceUpdateResponse as InstanceUpdateResponse +from .namespace_create_response import NamespaceCreateResponse as NamespaceCreateResponse +from .namespace_search_response import NamespaceSearchResponse as NamespaceSearchResponse +from .namespace_update_response import NamespaceUpdateResponse as NamespaceUpdateResponse from .instance_chat_completions_params import InstanceChatCompletionsParams as InstanceChatCompletionsParams +from .namespace_chat_completions_params import NamespaceChatCompletionsParams as NamespaceChatCompletionsParams from .instance_chat_completions_response import InstanceChatCompletionsResponse as InstanceChatCompletionsResponse +from .namespace_chat_completions_response import NamespaceChatCompletionsResponse as NamespaceChatCompletionsResponse diff --git a/src/cloudflare/types/aisearch/instance_chat_completions_params.py b/src/cloudflare/types/aisearch/instance_chat_completions_params.py index 48404e6cfa6..5ec107392b1 100644 --- a/src/cloudflare/types/aisearch/instance_chat_completions_params.py +++ b/src/cloudflare/types/aisearch/instance_chat_completions_params.py @@ -2,8 +2,8 @@ from __future__ import annotations -from typing import Dict, Union, Iterable, Optional -from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict +from typing import Dict, Iterable, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict from ..._utils import PropertyInfo @@ -20,7 +20,7 @@ class InstanceChatCompletionsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str messages: Required[Iterable[Message]] @@ -62,15 +62,12 @@ class InstanceChatCompletionsParams(TypedDict, total=False): stream: bool -class MessageTyped(TypedDict, total=False): +class Message(TypedDict, total=False, extra_items=object): # type: ignore[call-arg] content: Required[Optional[str]] role: Required[Literal["system", "developer", "user", "assistant", "tool"]] -Message: TypeAlias = Union[MessageTyped, Dict[str, object]] - - class AISearchOptionsCache(TypedDict, total=False): cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] diff --git a/src/cloudflare/types/aisearch/instance_create_params.py b/src/cloudflare/types/aisearch/instance_create_params.py index 553e205ee20..0260d19406e 100644 --- a/src/cloudflare/types/aisearch/instance_create_params.py +++ b/src/cloudflare/types/aisearch/instance_create_params.py @@ -33,7 +33,7 @@ class InstanceCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: Required[str] """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" @@ -172,11 +172,11 @@ class InstanceCreateParams(TypedDict, total=False): source_params: Optional[SourceParams] - sync_interval: Literal[3600, 7200, 14400, 21600, 43200, 86400] + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] """Interval between automatic syncs, in seconds. - Allowed values: 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 - (24h). + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). """ token_id: str diff --git a/src/cloudflare/types/aisearch/instance_create_response.py b/src/cloudflare/types/aisearch/instance_create_response.py index afdccc717ec..a1d955a3e36 100644 --- a/src/cloudflare/types/aisearch/instance_create_response.py +++ b/src/cloudflare/types/aisearch/instance_create_response.py @@ -399,11 +399,11 @@ class InstanceCreateResponse(BaseModel): status: Optional[str] = None - sync_interval: Optional[Literal[3600, 7200, 14400, 21600, 43200, 86400]] = None + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None """Interval between automatic syncs, in seconds. - Allowed values: 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 - (24h). + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). """ token_id: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/instance_delete_response.py b/src/cloudflare/types/aisearch/instance_delete_response.py index 2fa470022e2..2d8af06cb64 100644 --- a/src/cloudflare/types/aisearch/instance_delete_response.py +++ b/src/cloudflare/types/aisearch/instance_delete_response.py @@ -399,11 +399,11 @@ class InstanceDeleteResponse(BaseModel): status: Optional[str] = None - sync_interval: Optional[Literal[3600, 7200, 14400, 21600, 43200, 86400]] = None + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None """Interval between automatic syncs, in seconds. - Allowed values: 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 - (24h). + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). """ token_id: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/instance_list_params.py b/src/cloudflare/types/aisearch/instance_list_params.py index 7c3b1faa18a..c69be488f9a 100644 --- a/src/cloudflare/types/aisearch/instance_list_params.py +++ b/src/cloudflare/types/aisearch/instance_list_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["InstanceListParams"] class InstanceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str namespace: Optional[str] diff --git a/src/cloudflare/types/aisearch/instance_list_response.py b/src/cloudflare/types/aisearch/instance_list_response.py index b239c6821cb..a18131f83ca 100644 --- a/src/cloudflare/types/aisearch/instance_list_response.py +++ b/src/cloudflare/types/aisearch/instance_list_response.py @@ -399,11 +399,11 @@ class InstanceListResponse(BaseModel): status: Optional[str] = None - sync_interval: Optional[Literal[3600, 7200, 14400, 21600, 43200, 86400]] = None + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None """Interval between automatic syncs, in seconds. - Allowed values: 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 - (24h). + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). """ token_id: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/instance_read_response.py b/src/cloudflare/types/aisearch/instance_read_response.py index 32c63565504..f573f989aaa 100644 --- a/src/cloudflare/types/aisearch/instance_read_response.py +++ b/src/cloudflare/types/aisearch/instance_read_response.py @@ -399,11 +399,11 @@ class InstanceReadResponse(BaseModel): status: Optional[str] = None - sync_interval: Optional[Literal[3600, 7200, 14400, 21600, 43200, 86400]] = None + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None """Interval between automatic syncs, in seconds. - Allowed values: 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 - (24h). + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). """ token_id: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/instance_search_params.py b/src/cloudflare/types/aisearch/instance_search_params.py index 06588471e16..1a6ce900868 100644 --- a/src/cloudflare/types/aisearch/instance_search_params.py +++ b/src/cloudflare/types/aisearch/instance_search_params.py @@ -2,8 +2,8 @@ from __future__ import annotations -from typing import Dict, Union, Iterable, Optional -from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict +from typing import Dict, Iterable, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict from ..._utils import PropertyInfo @@ -20,7 +20,7 @@ class InstanceSearchParams(TypedDict, total=False): - account_id: Required[str] + account_id: str aisearch_options: Annotated[AISearchOptions, PropertyInfo(alias="ai_search_options")] @@ -147,10 +147,7 @@ class AISearchOptions(TypedDict, total=False): retrieval: AISearchOptionsRetrieval -class MessageTyped(TypedDict, total=False): +class Message(TypedDict, total=False, extra_items=object): # type: ignore[call-arg] content: Required[Optional[str]] role: Required[Literal["system", "developer", "user", "assistant", "tool"]] - - -Message: TypeAlias = Union[MessageTyped, Dict[str, object]] diff --git a/src/cloudflare/types/aisearch/instance_update_params.py b/src/cloudflare/types/aisearch/instance_update_params.py index e0d94062315..a483de8edbc 100644 --- a/src/cloudflare/types/aisearch/instance_update_params.py +++ b/src/cloudflare/types/aisearch/instance_update_params.py @@ -33,7 +33,7 @@ class InstanceUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str ai_gateway_id: Optional[str] @@ -203,11 +203,11 @@ class InstanceUpdateParams(TypedDict, total=False): ] ] - sync_interval: Literal[3600, 7200, 14400, 21600, 43200, 86400] + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] """Interval between automatic syncs, in seconds. - Allowed values: 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 - (24h). + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). """ system_prompt_aisearch: Annotated[Optional[str], PropertyInfo(alias="system_prompt_ai_search")] diff --git a/src/cloudflare/types/aisearch/instance_update_response.py b/src/cloudflare/types/aisearch/instance_update_response.py index f0549a3011b..ccbbe7cea67 100644 --- a/src/cloudflare/types/aisearch/instance_update_response.py +++ b/src/cloudflare/types/aisearch/instance_update_response.py @@ -399,11 +399,11 @@ class InstanceUpdateResponse(BaseModel): status: Optional[str] = None - sync_interval: Optional[Literal[3600, 7200, 14400, 21600, 43200, 86400]] = None + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None """Interval between automatic syncs, in seconds. - Allowed values: 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 - (24h). + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). """ token_id: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/instances/job_create_params.py b/src/cloudflare/types/aisearch/instances/job_create_params.py index 243c20584fb..eee8bbcb449 100644 --- a/src/cloudflare/types/aisearch/instances/job_create_params.py +++ b/src/cloudflare/types/aisearch/instances/job_create_params.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["JobCreateParams"] class JobCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str description: str diff --git a/src/cloudflare/types/aisearch/instances/job_list_params.py b/src/cloudflare/types/aisearch/instances/job_list_params.py index 41df366ab10..cab5a6501bf 100644 --- a/src/cloudflare/types/aisearch/instances/job_list_params.py +++ b/src/cloudflare/types/aisearch/instances/job_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["JobListParams"] class JobListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: int diff --git a/src/cloudflare/types/aisearch/instances/job_logs_params.py b/src/cloudflare/types/aisearch/instances/job_logs_params.py index 3f573b3271e..aa9e0745699 100644 --- a/src/cloudflare/types/aisearch/instances/job_logs_params.py +++ b/src/cloudflare/types/aisearch/instances/job_logs_params.py @@ -8,7 +8,7 @@ class JobLogsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: Required[str] """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" diff --git a/src/cloudflare/types/aisearch/namespace_chat_completions_params.py b/src/cloudflare/types/aisearch/namespace_chat_completions_params.py new file mode 100644 index 00000000000..8e1cd2535d4 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_chat_completions_params.py @@ -0,0 +1,185 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Iterable, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo + +__all__ = [ + "NamespaceChatCompletionsParams", + "AISearchOptions", + "AISearchOptionsCache", + "AISearchOptionsQueryRewrite", + "AISearchOptionsReranking", + "AISearchOptionsRetrieval", + "AISearchOptionsRetrievalBoostBy", + "Message", +] + + +class NamespaceChatCompletionsParams(TypedDict, total=False): + account_id: str + + aisearch_options: Required[Annotated[AISearchOptions, PropertyInfo(alias="ai_search_options")]] + + messages: Required[Iterable[Message]] + + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + + stream: bool + + +class AISearchOptionsCache(TypedDict, total=False): + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + + enabled: bool + + +class AISearchOptionsQueryRewrite(TypedDict, total=False): + enabled: bool + + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + + rewrite_prompt: str + + +class AISearchOptionsReranking(TypedDict, total=False): + enabled: bool + + match_threshold: float + + model: Literal["@cf/baai/bge-reranker-base", ""] + + +class AISearchOptionsRetrievalBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class AISearchOptionsRetrieval(TypedDict, total=False): + boost_by: Iterable[AISearchOptionsRetrievalBoostBy] + """Metadata fields to boost search results by. + + Overrides the instance-level boost_by config. Direction defaults to 'asc' for + numeric/datetime fields, 'exists' for text/boolean fields. Fields must match + 'timestamp' or a defined custom_metadata field. + """ + + context_expansion: int + + filters: Dict[str, object] + + fusion_method: Literal["max", "rrf"] + + keyword_match_mode: Literal["and", "or"] + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + match_threshold: float + + max_num_results: int + + retrieval_type: Literal["vector", "keyword", "hybrid"] + + return_on_failure: bool + + +class AISearchOptions(TypedDict, total=False): + instance_ids: Required[SequenceNotStr[str]] + + cache: AISearchOptionsCache + + query_rewrite: AISearchOptionsQueryRewrite + + reranking: AISearchOptionsReranking + + retrieval: AISearchOptionsRetrieval + + +class Message(TypedDict, total=False, extra_items=object): # type: ignore[call-arg] + content: Required[Optional[str]] + + role: Required[Literal["system", "developer", "user", "assistant", "tool"]] diff --git a/src/cloudflare/types/aisearch/namespace_chat_completions_response.py b/src/cloudflare/types/aisearch/namespace_chat_completions_response.py new file mode 100644 index 00000000000..4de71319145 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_chat_completions_response.py @@ -0,0 +1,113 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import TYPE_CHECKING, Dict, List, Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = [ + "NamespaceChatCompletionsResponse", + "Choice", + "ChoiceMessage", + "Chunk", + "ChunkItem", + "ChunkScoringDetails", + "Error", +] + + +class ChoiceMessage(BaseModel): + content: Optional[str] = None + + role: Literal["system", "developer", "user", "assistant", "tool"] + + if TYPE_CHECKING: + # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a + # value to this field, so for compatibility we avoid doing it at runtime. + __pydantic_extra__: Dict[str, object] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride] + + # Stub to indicate that arbitrary properties are accepted. + # To access properties that are not valid identifiers you can use `getattr`, e.g. + # `getattr(obj, '$type')` + def __getattr__(self, attr: str) -> object: ... + else: + __pydantic_extra__: Dict[str, object] + + +class Choice(BaseModel): + message: ChoiceMessage + + index: Optional[int] = None + + +class ChunkItem(BaseModel): + key: str + + metadata: Optional[Dict[str, object]] = None + + timestamp: Optional[float] = None + + +class ChunkScoringDetails(BaseModel): + fusion_method: Optional[Literal["rrf", "max"]] = None + + keyword_rank: Optional[float] = None + + keyword_score: Optional[float] = None + + reranking_score: Optional[float] = None + + vector_rank: Optional[float] = None + + vector_score: Optional[float] = None + + +class Chunk(BaseModel): + id: str + + instance_id: str + + score: float + + text: str + + type: str + + item: Optional[ChunkItem] = None + + scoring_details: Optional[ChunkScoringDetails] = None + + +class Error(BaseModel): + instance_id: str + + message: str + + +class NamespaceChatCompletionsResponse(BaseModel): + choices: List[Choice] + + chunks: List[Chunk] + + id: Optional[str] = None + + errors: Optional[List[Error]] = None + + model: Optional[str] = None + + object: Optional[str] = None + + if TYPE_CHECKING: + # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a + # value to this field, so for compatibility we avoid doing it at runtime. + __pydantic_extra__: Dict[str, builtins.object] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride] + + # Stub to indicate that arbitrary properties are accepted. + # To access properties that are not valid identifiers you can use `getattr`, e.g. + # `getattr(obj, '$type')` + def __getattr__(self, attr: str) -> builtins.object: ... + else: + __pydantic_extra__: Dict[str, builtins.object] diff --git a/src/cloudflare/types/aisearch/namespace_create_params.py b/src/cloudflare/types/aisearch/namespace_create_params.py new file mode 100644 index 00000000000..64b5514f359 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_create_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Required, TypedDict + +__all__ = ["NamespaceCreateParams"] + + +class NamespaceCreateParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + description: Optional[str] + """Optional description for the namespace. Max 256 characters.""" diff --git a/src/cloudflare/types/aisearch/namespace_create_response.py b/src/cloudflare/types/aisearch/namespace_create_response.py new file mode 100644 index 00000000000..f241d89da89 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_create_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["NamespaceCreateResponse"] + + +class NamespaceCreateResponse(BaseModel): + created_at: datetime + + name: str + + description: Optional[str] = None + """Optional description for the namespace. Max 256 characters.""" diff --git a/src/cloudflare/types/aisearch/namespace_list_params.py b/src/cloudflare/types/aisearch/namespace_list_params.py new file mode 100644 index 00000000000..5bc3091e667 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_list_params.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["NamespaceListParams"] + + +class NamespaceListParams(TypedDict, total=False): + account_id: str + + page: int + """Page number (1-indexed).""" + + per_page: int + """Number of results per page.""" + + search: str + """ + Filter namespaces whose name or description contains this string + (case-insensitive). + """ diff --git a/src/cloudflare/types/aisearch/namespace_list_response.py b/src/cloudflare/types/aisearch/namespace_list_response.py new file mode 100644 index 00000000000..38515b753eb --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_list_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["NamespaceListResponse"] + + +class NamespaceListResponse(BaseModel): + created_at: datetime + + name: str + + description: Optional[str] = None + """Optional description for the namespace. Max 256 characters.""" diff --git a/src/cloudflare/types/aisearch/namespace_read_response.py b/src/cloudflare/types/aisearch/namespace_read_response.py new file mode 100644 index 00000000000..c06d4f20bd7 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_read_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["NamespaceReadResponse"] + + +class NamespaceReadResponse(BaseModel): + created_at: datetime + + name: str + + description: Optional[str] = None + """Optional description for the namespace. Max 256 characters.""" diff --git a/src/cloudflare/types/aisearch/namespace_search_params.py b/src/cloudflare/types/aisearch/namespace_search_params.py new file mode 100644 index 00000000000..7f4b28df992 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_search_params.py @@ -0,0 +1,156 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Iterable, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo + +__all__ = [ + "NamespaceSearchParams", + "AISearchOptions", + "AISearchOptionsCache", + "AISearchOptionsQueryRewrite", + "AISearchOptionsReranking", + "AISearchOptionsRetrieval", + "AISearchOptionsRetrievalBoostBy", + "Message", +] + + +class NamespaceSearchParams(TypedDict, total=False): + account_id: str + + aisearch_options: Required[Annotated[AISearchOptions, PropertyInfo(alias="ai_search_options")]] + + messages: Iterable[Message] + + query: str + """A simple text query string. + + Alternative to 'messages' — provide either this or 'messages', not both. + """ + + +class AISearchOptionsCache(TypedDict, total=False): + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + + enabled: bool + + +class AISearchOptionsQueryRewrite(TypedDict, total=False): + enabled: bool + + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + + rewrite_prompt: str + + +class AISearchOptionsReranking(TypedDict, total=False): + enabled: bool + + match_threshold: float + + model: Literal["@cf/baai/bge-reranker-base", ""] + + +class AISearchOptionsRetrievalBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class AISearchOptionsRetrieval(TypedDict, total=False): + boost_by: Iterable[AISearchOptionsRetrievalBoostBy] + """Metadata fields to boost search results by. + + Overrides the instance-level boost_by config. Direction defaults to 'asc' for + numeric/datetime fields, 'exists' for text/boolean fields. Fields must match + 'timestamp' or a defined custom_metadata field. + """ + + context_expansion: int + + filters: Dict[str, object] + + fusion_method: Literal["max", "rrf"] + + keyword_match_mode: Literal["and", "or"] + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + match_threshold: float + + max_num_results: int + + retrieval_type: Literal["vector", "keyword", "hybrid"] + + return_on_failure: bool + + +class AISearchOptions(TypedDict, total=False): + instance_ids: Required[SequenceNotStr[str]] + + cache: AISearchOptionsCache + + query_rewrite: AISearchOptionsQueryRewrite + + reranking: AISearchOptionsReranking + + retrieval: AISearchOptionsRetrieval + + +class Message(TypedDict, total=False, extra_items=object): # type: ignore[call-arg] + content: Required[Optional[str]] + + role: Required[Literal["system", "developer", "user", "assistant", "tool"]] diff --git a/src/cloudflare/types/aisearch/namespace_search_response.py b/src/cloudflare/types/aisearch/namespace_search_response.py new file mode 100644 index 00000000000..daa43bf37f2 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_search_response.py @@ -0,0 +1,60 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["NamespaceSearchResponse", "Chunk", "ChunkItem", "ChunkScoringDetails", "Error"] + + +class ChunkItem(BaseModel): + key: str + + metadata: Optional[Dict[str, object]] = None + + timestamp: Optional[float] = None + + +class ChunkScoringDetails(BaseModel): + fusion_method: Optional[Literal["rrf", "max"]] = None + + keyword_rank: Optional[float] = None + + keyword_score: Optional[float] = None + + reranking_score: Optional[float] = None + + vector_rank: Optional[float] = None + + vector_score: Optional[float] = None + + +class Chunk(BaseModel): + id: str + + instance_id: str + + score: float + + text: str + + type: str + + item: Optional[ChunkItem] = None + + scoring_details: Optional[ChunkScoringDetails] = None + + +class Error(BaseModel): + instance_id: str + + message: str + + +class NamespaceSearchResponse(BaseModel): + chunks: List[Chunk] + + search_query: str + + errors: Optional[List[Error]] = None diff --git a/src/cloudflare/types/aisearch/namespace_update_params.py b/src/cloudflare/types/aisearch/namespace_update_params.py new file mode 100644 index 00000000000..90384d81556 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_update_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import TypedDict + +__all__ = ["NamespaceUpdateParams"] + + +class NamespaceUpdateParams(TypedDict, total=False): + account_id: str + + description: Optional[str] + """Optional description for the namespace. Max 256 characters.""" diff --git a/src/cloudflare/types/aisearch/namespace_update_response.py b/src/cloudflare/types/aisearch/namespace_update_response.py new file mode 100644 index 00000000000..28b2aeb2d61 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespace_update_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["NamespaceUpdateResponse"] + + +class NamespaceUpdateResponse(BaseModel): + created_at: datetime + + name: str + + description: Optional[str] = None + """Optional description for the namespace. Max 256 characters.""" diff --git a/src/cloudflare/types/aisearch/namespaces/__init__.py b/src/cloudflare/types/aisearch/namespaces/__init__.py new file mode 100644 index 00000000000..d1d45a063a0 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/__init__.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .instance_list_params import InstanceListParams as InstanceListParams +from .instance_create_params import InstanceCreateParams as InstanceCreateParams +from .instance_list_response import InstanceListResponse as InstanceListResponse +from .instance_read_response import InstanceReadResponse as InstanceReadResponse +from .instance_search_params import InstanceSearchParams as InstanceSearchParams +from .instance_update_params import InstanceUpdateParams as InstanceUpdateParams +from .instance_stats_response import InstanceStatsResponse as InstanceStatsResponse +from .instance_create_response import InstanceCreateResponse as InstanceCreateResponse +from .instance_delete_response import InstanceDeleteResponse as InstanceDeleteResponse +from .instance_search_response import InstanceSearchResponse as InstanceSearchResponse +from .instance_update_response import InstanceUpdateResponse as InstanceUpdateResponse +from .instance_chat_completions_params import InstanceChatCompletionsParams as InstanceChatCompletionsParams +from .instance_chat_completions_response import InstanceChatCompletionsResponse as InstanceChatCompletionsResponse diff --git a/src/cloudflare/types/aisearch/namespaces/instance_chat_completions_params.py b/src/cloudflare/types/aisearch/namespaces/instance_chat_completions_params.py new file mode 100644 index 00000000000..fdef80ec2a5 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_chat_completions_params.py @@ -0,0 +1,184 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Iterable, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = [ + "InstanceChatCompletionsParams", + "Message", + "AISearchOptions", + "AISearchOptionsCache", + "AISearchOptionsQueryRewrite", + "AISearchOptionsReranking", + "AISearchOptionsRetrieval", + "AISearchOptionsRetrievalBoostBy", +] + + +class InstanceChatCompletionsParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + messages: Required[Iterable[Message]] + + aisearch_options: Annotated[AISearchOptions, PropertyInfo(alias="ai_search_options")] + + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + + stream: bool + + +class Message(TypedDict, total=False, extra_items=object): # type: ignore[call-arg] + content: Required[Optional[str]] + + role: Required[Literal["system", "developer", "user", "assistant", "tool"]] + + +class AISearchOptionsCache(TypedDict, total=False): + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + + enabled: bool + + +class AISearchOptionsQueryRewrite(TypedDict, total=False): + enabled: bool + + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + + rewrite_prompt: str + + +class AISearchOptionsReranking(TypedDict, total=False): + enabled: bool + + match_threshold: float + + model: Literal["@cf/baai/bge-reranker-base", ""] + + +class AISearchOptionsRetrievalBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class AISearchOptionsRetrieval(TypedDict, total=False): + boost_by: Iterable[AISearchOptionsRetrievalBoostBy] + """Metadata fields to boost search results by. + + Overrides the instance-level boost_by config. Direction defaults to 'asc' for + numeric/datetime fields, 'exists' for text/boolean fields. Fields must match + 'timestamp' or a defined custom_metadata field. + """ + + context_expansion: int + + filters: Dict[str, object] + + fusion_method: Literal["max", "rrf"] + + keyword_match_mode: Literal["and", "or"] + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + match_threshold: float + + max_num_results: int + + retrieval_type: Literal["vector", "keyword", "hybrid"] + + return_on_failure: bool + + +class AISearchOptions(TypedDict, total=False): + cache: AISearchOptionsCache + + query_rewrite: AISearchOptionsQueryRewrite + + reranking: AISearchOptionsReranking + + retrieval: AISearchOptionsRetrieval diff --git a/src/cloudflare/types/aisearch/namespaces/instance_chat_completions_response.py b/src/cloudflare/types/aisearch/namespaces/instance_chat_completions_response.py new file mode 100644 index 00000000000..334500a4f97 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_chat_completions_response.py @@ -0,0 +1,95 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import TYPE_CHECKING, Dict, List, Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["InstanceChatCompletionsResponse", "Choice", "ChoiceMessage", "Chunk", "ChunkItem", "ChunkScoringDetails"] + + +class ChoiceMessage(BaseModel): + content: Optional[str] = None + + role: Literal["system", "developer", "user", "assistant", "tool"] + + if TYPE_CHECKING: + # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a + # value to this field, so for compatibility we avoid doing it at runtime. + __pydantic_extra__: Dict[str, object] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride] + + # Stub to indicate that arbitrary properties are accepted. + # To access properties that are not valid identifiers you can use `getattr`, e.g. + # `getattr(obj, '$type')` + def __getattr__(self, attr: str) -> object: ... + else: + __pydantic_extra__: Dict[str, object] + + +class Choice(BaseModel): + message: ChoiceMessage + + index: Optional[int] = None + + +class ChunkItem(BaseModel): + key: str + + metadata: Optional[Dict[str, object]] = None + + timestamp: Optional[float] = None + + +class ChunkScoringDetails(BaseModel): + fusion_method: Optional[Literal["rrf", "max"]] = None + + keyword_rank: Optional[float] = None + + keyword_score: Optional[float] = None + + reranking_score: Optional[float] = None + + vector_rank: Optional[float] = None + + vector_score: Optional[float] = None + + +class Chunk(BaseModel): + id: str + + score: float + + text: str + + type: str + + item: Optional[ChunkItem] = None + + scoring_details: Optional[ChunkScoringDetails] = None + + +class InstanceChatCompletionsResponse(BaseModel): + choices: List[Choice] + + chunks: List[Chunk] + + id: Optional[str] = None + + model: Optional[str] = None + + object: Optional[str] = None + + if TYPE_CHECKING: + # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a + # value to this field, so for compatibility we avoid doing it at runtime. + __pydantic_extra__: Dict[str, builtins.object] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride] + + # Stub to indicate that arbitrary properties are accepted. + # To access properties that are not valid identifiers you can use `getattr`, e.g. + # `getattr(obj, '$type')` + def __getattr__(self, attr: str) -> builtins.object: ... + else: + __pydantic_extra__: Dict[str, builtins.object] diff --git a/src/cloudflare/types/aisearch/namespaces/instance_create_params.py b/src/cloudflare/types/aisearch/namespaces/instance_create_params.py new file mode 100644 index 00000000000..fee11c5c3d9 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_create_params.py @@ -0,0 +1,396 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Iterable, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ...._types import SequenceNotStr +from ...._utils import PropertyInfo +from ...r2.buckets.provider import Provider + +__all__ = [ + "InstanceCreateParams", + "CustomMetadata", + "IndexMethod", + "IndexingOptions", + "Metadata", + "MetadataSearchForAgents", + "PublicEndpointParams", + "PublicEndpointParamsChatCompletionsEndpoint", + "PublicEndpointParamsMcp", + "PublicEndpointParamsRateLimit", + "PublicEndpointParamsSearchEndpoint", + "RetrievalOptions", + "RetrievalOptionsBoostBy", + "SourceParams", + "SourceParamsWebCrawler", + "SourceParamsWebCrawlerCrawlOptions", + "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", + "SourceParamsWebCrawlerStoreOptions", +] + + +class InstanceCreateParams(TypedDict, total=False): + account_id: str + + id: Required[str] + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + ai_gateway_id: Optional[str] + + aisearch_model: Annotated[ + Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ], + PropertyInfo(alias="ai_search_model"), + ] + + cache: bool + + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + + chunk: bool + + chunk_overlap: int + + chunk_size: int + + custom_metadata: Iterable[CustomMetadata] + + embedding_model: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] + + fusion_method: Literal["max", "rrf"] + + hybrid_search_enabled: bool + """Deprecated — use index_method instead.""" + + index_method: IndexMethod + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + indexing_options: Optional[IndexingOptions] + + max_num_results: int + + metadata: Metadata + + public_endpoint_params: PublicEndpointParams + + reranking: bool + + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] + + retrieval_options: Optional[RetrievalOptions] + + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] + + rewrite_query: bool + + score_threshold: float + + source: Optional[str] + + source_params: Optional[SourceParams] + + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] + """Interval between automatic syncs, in seconds. + + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). + """ + + token_id: str + + type: Optional[Literal["r2", "web-crawler"]] + + +class CustomMetadata(TypedDict, total=False): + data_type: Required[Literal["text", "number", "boolean", "datetime"]] + + field_name: Required[str] + + +class IndexMethod(TypedDict, total=False): + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + keyword: Required[bool] + """Enable keyword (BM25) storage backend.""" + + vector: Required[bool] + """Enable vector (embedding) storage backend.""" + + +class IndexingOptions(TypedDict, total=False): + keyword_tokenizer: Literal["porter", "trigram"] + """Tokenizer used for keyword search indexing. + + porter provides word-level tokenization with Porter stemming (good for natural + language queries). trigram enables character-level substring matching (good for + partial matches, code, identifiers). Changing this triggers a full re-index. + Defaults to porter. + """ + + +class MetadataSearchForAgents(TypedDict, total=False): + hostname: Required[str] + + zone_id: Required[str] + + zone_name: Required[str] + + +class Metadata(TypedDict, total=False): + created_from_aisearch_wizard: bool + + search_for_agents: MetadataSearchForAgents + + worker_domain: str + + +class PublicEndpointParamsChatCompletionsEndpoint(TypedDict, total=False): + disabled: bool + """Disable chat completions endpoint for this public endpoint""" + + +class PublicEndpointParamsMcp(TypedDict, total=False): + description: str + + disabled: bool + """Disable MCP endpoint for this public endpoint""" + + +class PublicEndpointParamsRateLimit(TypedDict, total=False): + period_ms: int + + requests: int + + technique: Literal["fixed", "sliding"] + + +class PublicEndpointParamsSearchEndpoint(TypedDict, total=False): + disabled: bool + """Disable search endpoint for this public endpoint""" + + +class PublicEndpointParams(TypedDict, total=False): + authorized_hosts: SequenceNotStr[str] + + chat_completions_endpoint: PublicEndpointParamsChatCompletionsEndpoint + + enabled: bool + + mcp: PublicEndpointParamsMcp + + rate_limit: PublicEndpointParamsRateLimit + + search_endpoint: PublicEndpointParamsSearchEndpoint + + +class RetrievalOptionsBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class RetrievalOptions(TypedDict, total=False): + boost_by: Iterable[RetrievalOptionsBoostBy] + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + + keyword_match_mode: Literal["and", "or"] + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + +class SourceParamsWebCrawlerCrawlOptions(TypedDict, total=False): + depth: float + + include_external_links: bool + + include_subdomains: bool + + max_age: float + + source: Literal["all", "sitemaps", "links"] + + +class SourceParamsWebCrawlerParseOptionsContentSelector(TypedDict, total=False): + path: Required[str] + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: Required[str] + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + +class SourceParamsWebCrawlerParseOptions(TypedDict, total=False): + content_selector: Iterable[SourceParamsWebCrawlerParseOptionsContentSelector] + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + + include_headers: Dict[str, str] + + include_images: bool + + specific_sitemaps: SequenceNotStr[str] + """List of specific sitemap URLs to use for crawling. + + Only valid when parse_type is 'sitemap'. + """ + + use_browser_rendering: bool + + +class SourceParamsWebCrawlerStoreOptions(TypedDict, total=False): + storage_id: Required[str] + + r2_jurisdiction: str + + storage_type: Provider + + +class SourceParamsWebCrawler(TypedDict, total=False): + crawl_options: SourceParamsWebCrawlerCrawlOptions + + parse_options: SourceParamsWebCrawlerParseOptions + + parse_type: Literal["sitemap", "feed-rss", "crawl"] + + store_options: SourceParamsWebCrawlerStoreOptions + + +class SourceParams(TypedDict, total=False): + exclude_items: SequenceNotStr[str] + """List of path patterns to exclude. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /admin/** matches /admin/users and + /admin/settings/advanced) + """ + + include_items: SequenceNotStr[str] + """List of path patterns to include. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) + """ + + prefix: str + + r2_jurisdiction: str + + web_crawler: SourceParamsWebCrawler diff --git a/src/cloudflare/types/aisearch/namespaces/instance_create_response.py b/src/cloudflare/types/aisearch/namespaces/instance_create_response.py new file mode 100644 index 00000000000..e32256f511e --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_create_response.py @@ -0,0 +1,411 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel +from ...r2.buckets.provider import Provider + +__all__ = [ + "InstanceCreateResponse", + "CustomMetadata", + "IndexMethod", + "IndexingOptions", + "Metadata", + "MetadataSearchForAgents", + "PublicEndpointParams", + "PublicEndpointParamsChatCompletionsEndpoint", + "PublicEndpointParamsMcp", + "PublicEndpointParamsRateLimit", + "PublicEndpointParamsSearchEndpoint", + "RetrievalOptions", + "RetrievalOptionsBoostBy", + "SourceParams", + "SourceParamsWebCrawler", + "SourceParamsWebCrawlerCrawlOptions", + "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", + "SourceParamsWebCrawlerStoreOptions", +] + + +class CustomMetadata(BaseModel): + data_type: Literal["text", "number", "boolean", "datetime"] + + field_name: str + + +class IndexMethod(BaseModel): + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + keyword: bool + """Enable keyword (BM25) storage backend.""" + + vector: bool + """Enable vector (embedding) storage backend.""" + + +class IndexingOptions(BaseModel): + keyword_tokenizer: Optional[Literal["porter", "trigram"]] = None + """Tokenizer used for keyword search indexing. + + porter provides word-level tokenization with Porter stemming (good for natural + language queries). trigram enables character-level substring matching (good for + partial matches, code, identifiers). Changing this triggers a full re-index. + Defaults to porter. + """ + + +class MetadataSearchForAgents(BaseModel): + hostname: str + + zone_id: str + + zone_name: str + + +class Metadata(BaseModel): + created_from_aisearch_wizard: Optional[bool] = None + + search_for_agents: Optional[MetadataSearchForAgents] = None + + worker_domain: Optional[str] = None + + +class PublicEndpointParamsChatCompletionsEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable chat completions endpoint for this public endpoint""" + + +class PublicEndpointParamsMcp(BaseModel): + description: Optional[str] = None + + disabled: Optional[bool] = None + """Disable MCP endpoint for this public endpoint""" + + +class PublicEndpointParamsRateLimit(BaseModel): + period_ms: Optional[int] = None + + requests: Optional[int] = None + + technique: Optional[Literal["fixed", "sliding"]] = None + + +class PublicEndpointParamsSearchEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable search endpoint for this public endpoint""" + + +class PublicEndpointParams(BaseModel): + authorized_hosts: Optional[List[str]] = None + + chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint] = None + + enabled: Optional[bool] = None + + mcp: Optional[PublicEndpointParamsMcp] = None + + rate_limit: Optional[PublicEndpointParamsRateLimit] = None + + search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None + + +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + + keyword_match_mode: Optional[Literal["and", "or"]] = None + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + +class SourceParamsWebCrawlerCrawlOptions(BaseModel): + depth: Optional[float] = None + + include_external_links: Optional[bool] = None + + include_subdomains: Optional[bool] = None + + max_age: Optional[float] = None + + source: Optional[Literal["all", "sitemaps", "links"]] = None + + +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + +class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + + include_headers: Optional[Dict[str, str]] = None + + include_images: Optional[bool] = None + + specific_sitemaps: Optional[List[str]] = None + """List of specific sitemap URLs to use for crawling. + + Only valid when parse_type is 'sitemap'. + """ + + use_browser_rendering: Optional[bool] = None + + +class SourceParamsWebCrawlerStoreOptions(BaseModel): + storage_id: str + + r2_jurisdiction: Optional[str] = None + + storage_type: Optional[Provider] = None + + +class SourceParamsWebCrawler(BaseModel): + crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions] = None + + parse_options: Optional[SourceParamsWebCrawlerParseOptions] = None + + parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]] = None + + store_options: Optional[SourceParamsWebCrawlerStoreOptions] = None + + +class SourceParams(BaseModel): + exclude_items: Optional[List[str]] = None + """List of path patterns to exclude. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /admin/** matches /admin/users and + /admin/settings/advanced) + """ + + include_items: Optional[List[str]] = None + """List of path patterns to include. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) + """ + + prefix: Optional[str] = None + + r2_jurisdiction: Optional[str] = None + + web_crawler: Optional[SourceParamsWebCrawler] = None + + +class InstanceCreateResponse(BaseModel): + id: str + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + created_at: datetime + + modified_at: datetime + + ai_gateway_id: Optional[str] = None + + aisearch_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = FieldInfo(alias="ai_search_model", default=None) + + cache: Optional[bool] = None + + cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]] = None + + chunk_overlap: Optional[int] = None + + chunk_size: Optional[int] = None + + created_by: Optional[str] = None + + custom_metadata: Optional[List[CustomMetadata]] = None + + embedding_model: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] = None + + enable: Optional[bool] = None + + engine_version: Optional[float] = None + + fusion_method: Optional[Literal["max", "rrf"]] = None + + hybrid_search_enabled: Optional[bool] = None + """Deprecated — use index_method instead.""" + + index_method: Optional[IndexMethod] = None + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + indexing_options: Optional[IndexingOptions] = None + + last_activity: Optional[datetime] = None + + max_num_results: Optional[int] = None + + metadata: Optional[Metadata] = None + + modified_by: Optional[str] = None + + namespace: Optional[str] = None + + paused: Optional[bool] = None + + public_endpoint_id: Optional[str] = None + + public_endpoint_params: Optional[PublicEndpointParams] = None + + reranking: Optional[bool] = None + + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] = None + + retrieval_options: Optional[RetrievalOptions] = None + + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = None + + rewrite_query: Optional[bool] = None + + score_threshold: Optional[float] = None + + source: Optional[str] = None + + source_params: Optional[SourceParams] = None + + status: Optional[str] = None + + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None + """Interval between automatic syncs, in seconds. + + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). + """ + + token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instance_delete_response.py b/src/cloudflare/types/aisearch/namespaces/instance_delete_response.py new file mode 100644 index 00000000000..9854b1bf225 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_delete_response.py @@ -0,0 +1,411 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel +from ...r2.buckets.provider import Provider + +__all__ = [ + "InstanceDeleteResponse", + "CustomMetadata", + "IndexMethod", + "IndexingOptions", + "Metadata", + "MetadataSearchForAgents", + "PublicEndpointParams", + "PublicEndpointParamsChatCompletionsEndpoint", + "PublicEndpointParamsMcp", + "PublicEndpointParamsRateLimit", + "PublicEndpointParamsSearchEndpoint", + "RetrievalOptions", + "RetrievalOptionsBoostBy", + "SourceParams", + "SourceParamsWebCrawler", + "SourceParamsWebCrawlerCrawlOptions", + "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", + "SourceParamsWebCrawlerStoreOptions", +] + + +class CustomMetadata(BaseModel): + data_type: Literal["text", "number", "boolean", "datetime"] + + field_name: str + + +class IndexMethod(BaseModel): + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + keyword: bool + """Enable keyword (BM25) storage backend.""" + + vector: bool + """Enable vector (embedding) storage backend.""" + + +class IndexingOptions(BaseModel): + keyword_tokenizer: Optional[Literal["porter", "trigram"]] = None + """Tokenizer used for keyword search indexing. + + porter provides word-level tokenization with Porter stemming (good for natural + language queries). trigram enables character-level substring matching (good for + partial matches, code, identifiers). Changing this triggers a full re-index. + Defaults to porter. + """ + + +class MetadataSearchForAgents(BaseModel): + hostname: str + + zone_id: str + + zone_name: str + + +class Metadata(BaseModel): + created_from_aisearch_wizard: Optional[bool] = None + + search_for_agents: Optional[MetadataSearchForAgents] = None + + worker_domain: Optional[str] = None + + +class PublicEndpointParamsChatCompletionsEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable chat completions endpoint for this public endpoint""" + + +class PublicEndpointParamsMcp(BaseModel): + description: Optional[str] = None + + disabled: Optional[bool] = None + """Disable MCP endpoint for this public endpoint""" + + +class PublicEndpointParamsRateLimit(BaseModel): + period_ms: Optional[int] = None + + requests: Optional[int] = None + + technique: Optional[Literal["fixed", "sliding"]] = None + + +class PublicEndpointParamsSearchEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable search endpoint for this public endpoint""" + + +class PublicEndpointParams(BaseModel): + authorized_hosts: Optional[List[str]] = None + + chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint] = None + + enabled: Optional[bool] = None + + mcp: Optional[PublicEndpointParamsMcp] = None + + rate_limit: Optional[PublicEndpointParamsRateLimit] = None + + search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None + + +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + + keyword_match_mode: Optional[Literal["and", "or"]] = None + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + +class SourceParamsWebCrawlerCrawlOptions(BaseModel): + depth: Optional[float] = None + + include_external_links: Optional[bool] = None + + include_subdomains: Optional[bool] = None + + max_age: Optional[float] = None + + source: Optional[Literal["all", "sitemaps", "links"]] = None + + +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + +class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + + include_headers: Optional[Dict[str, str]] = None + + include_images: Optional[bool] = None + + specific_sitemaps: Optional[List[str]] = None + """List of specific sitemap URLs to use for crawling. + + Only valid when parse_type is 'sitemap'. + """ + + use_browser_rendering: Optional[bool] = None + + +class SourceParamsWebCrawlerStoreOptions(BaseModel): + storage_id: str + + r2_jurisdiction: Optional[str] = None + + storage_type: Optional[Provider] = None + + +class SourceParamsWebCrawler(BaseModel): + crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions] = None + + parse_options: Optional[SourceParamsWebCrawlerParseOptions] = None + + parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]] = None + + store_options: Optional[SourceParamsWebCrawlerStoreOptions] = None + + +class SourceParams(BaseModel): + exclude_items: Optional[List[str]] = None + """List of path patterns to exclude. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /admin/** matches /admin/users and + /admin/settings/advanced) + """ + + include_items: Optional[List[str]] = None + """List of path patterns to include. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) + """ + + prefix: Optional[str] = None + + r2_jurisdiction: Optional[str] = None + + web_crawler: Optional[SourceParamsWebCrawler] = None + + +class InstanceDeleteResponse(BaseModel): + id: str + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + created_at: datetime + + modified_at: datetime + + ai_gateway_id: Optional[str] = None + + aisearch_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = FieldInfo(alias="ai_search_model", default=None) + + cache: Optional[bool] = None + + cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]] = None + + chunk_overlap: Optional[int] = None + + chunk_size: Optional[int] = None + + created_by: Optional[str] = None + + custom_metadata: Optional[List[CustomMetadata]] = None + + embedding_model: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] = None + + enable: Optional[bool] = None + + engine_version: Optional[float] = None + + fusion_method: Optional[Literal["max", "rrf"]] = None + + hybrid_search_enabled: Optional[bool] = None + """Deprecated — use index_method instead.""" + + index_method: Optional[IndexMethod] = None + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + indexing_options: Optional[IndexingOptions] = None + + last_activity: Optional[datetime] = None + + max_num_results: Optional[int] = None + + metadata: Optional[Metadata] = None + + modified_by: Optional[str] = None + + namespace: Optional[str] = None + + paused: Optional[bool] = None + + public_endpoint_id: Optional[str] = None + + public_endpoint_params: Optional[PublicEndpointParams] = None + + reranking: Optional[bool] = None + + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] = None + + retrieval_options: Optional[RetrievalOptions] = None + + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = None + + rewrite_query: Optional[bool] = None + + score_threshold: Optional[float] = None + + source: Optional[str] = None + + source_params: Optional[SourceParams] = None + + status: Optional[str] = None + + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None + """Interval between automatic syncs, in seconds. + + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). + """ + + token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instance_list_params.py b/src/cloudflare/types/aisearch/namespaces/instance_list_params.py new file mode 100644 index 00000000000..c69be488f9a --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_list_params.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, TypedDict + +__all__ = ["InstanceListParams"] + + +class InstanceListParams(TypedDict, total=False): + account_id: str + + namespace: Optional[str] + + order_by: Literal["created_at"] + """Order By Column Name""" + + order_by_direction: Literal["asc", "desc"] + """Order By Direction""" + + page: int + + per_page: int + + search: str + """Search by id""" diff --git a/src/cloudflare/types/aisearch/namespaces/instance_list_response.py b/src/cloudflare/types/aisearch/namespaces/instance_list_response.py new file mode 100644 index 00000000000..0b285ba0e3e --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_list_response.py @@ -0,0 +1,411 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel +from ...r2.buckets.provider import Provider + +__all__ = [ + "InstanceListResponse", + "CustomMetadata", + "IndexMethod", + "IndexingOptions", + "Metadata", + "MetadataSearchForAgents", + "PublicEndpointParams", + "PublicEndpointParamsChatCompletionsEndpoint", + "PublicEndpointParamsMcp", + "PublicEndpointParamsRateLimit", + "PublicEndpointParamsSearchEndpoint", + "RetrievalOptions", + "RetrievalOptionsBoostBy", + "SourceParams", + "SourceParamsWebCrawler", + "SourceParamsWebCrawlerCrawlOptions", + "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", + "SourceParamsWebCrawlerStoreOptions", +] + + +class CustomMetadata(BaseModel): + data_type: Literal["text", "number", "boolean", "datetime"] + + field_name: str + + +class IndexMethod(BaseModel): + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + keyword: bool + """Enable keyword (BM25) storage backend.""" + + vector: bool + """Enable vector (embedding) storage backend.""" + + +class IndexingOptions(BaseModel): + keyword_tokenizer: Optional[Literal["porter", "trigram"]] = None + """Tokenizer used for keyword search indexing. + + porter provides word-level tokenization with Porter stemming (good for natural + language queries). trigram enables character-level substring matching (good for + partial matches, code, identifiers). Changing this triggers a full re-index. + Defaults to porter. + """ + + +class MetadataSearchForAgents(BaseModel): + hostname: str + + zone_id: str + + zone_name: str + + +class Metadata(BaseModel): + created_from_aisearch_wizard: Optional[bool] = None + + search_for_agents: Optional[MetadataSearchForAgents] = None + + worker_domain: Optional[str] = None + + +class PublicEndpointParamsChatCompletionsEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable chat completions endpoint for this public endpoint""" + + +class PublicEndpointParamsMcp(BaseModel): + description: Optional[str] = None + + disabled: Optional[bool] = None + """Disable MCP endpoint for this public endpoint""" + + +class PublicEndpointParamsRateLimit(BaseModel): + period_ms: Optional[int] = None + + requests: Optional[int] = None + + technique: Optional[Literal["fixed", "sliding"]] = None + + +class PublicEndpointParamsSearchEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable search endpoint for this public endpoint""" + + +class PublicEndpointParams(BaseModel): + authorized_hosts: Optional[List[str]] = None + + chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint] = None + + enabled: Optional[bool] = None + + mcp: Optional[PublicEndpointParamsMcp] = None + + rate_limit: Optional[PublicEndpointParamsRateLimit] = None + + search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None + + +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + + keyword_match_mode: Optional[Literal["and", "or"]] = None + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + +class SourceParamsWebCrawlerCrawlOptions(BaseModel): + depth: Optional[float] = None + + include_external_links: Optional[bool] = None + + include_subdomains: Optional[bool] = None + + max_age: Optional[float] = None + + source: Optional[Literal["all", "sitemaps", "links"]] = None + + +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + +class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + + include_headers: Optional[Dict[str, str]] = None + + include_images: Optional[bool] = None + + specific_sitemaps: Optional[List[str]] = None + """List of specific sitemap URLs to use for crawling. + + Only valid when parse_type is 'sitemap'. + """ + + use_browser_rendering: Optional[bool] = None + + +class SourceParamsWebCrawlerStoreOptions(BaseModel): + storage_id: str + + r2_jurisdiction: Optional[str] = None + + storage_type: Optional[Provider] = None + + +class SourceParamsWebCrawler(BaseModel): + crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions] = None + + parse_options: Optional[SourceParamsWebCrawlerParseOptions] = None + + parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]] = None + + store_options: Optional[SourceParamsWebCrawlerStoreOptions] = None + + +class SourceParams(BaseModel): + exclude_items: Optional[List[str]] = None + """List of path patterns to exclude. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /admin/** matches /admin/users and + /admin/settings/advanced) + """ + + include_items: Optional[List[str]] = None + """List of path patterns to include. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) + """ + + prefix: Optional[str] = None + + r2_jurisdiction: Optional[str] = None + + web_crawler: Optional[SourceParamsWebCrawler] = None + + +class InstanceListResponse(BaseModel): + id: str + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + created_at: datetime + + modified_at: datetime + + ai_gateway_id: Optional[str] = None + + aisearch_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = FieldInfo(alias="ai_search_model", default=None) + + cache: Optional[bool] = None + + cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]] = None + + chunk_overlap: Optional[int] = None + + chunk_size: Optional[int] = None + + created_by: Optional[str] = None + + custom_metadata: Optional[List[CustomMetadata]] = None + + embedding_model: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] = None + + enable: Optional[bool] = None + + engine_version: Optional[float] = None + + fusion_method: Optional[Literal["max", "rrf"]] = None + + hybrid_search_enabled: Optional[bool] = None + """Deprecated — use index_method instead.""" + + index_method: Optional[IndexMethod] = None + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + indexing_options: Optional[IndexingOptions] = None + + last_activity: Optional[datetime] = None + + max_num_results: Optional[int] = None + + metadata: Optional[Metadata] = None + + modified_by: Optional[str] = None + + namespace: Optional[str] = None + + paused: Optional[bool] = None + + public_endpoint_id: Optional[str] = None + + public_endpoint_params: Optional[PublicEndpointParams] = None + + reranking: Optional[bool] = None + + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] = None + + retrieval_options: Optional[RetrievalOptions] = None + + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = None + + rewrite_query: Optional[bool] = None + + score_threshold: Optional[float] = None + + source: Optional[str] = None + + source_params: Optional[SourceParams] = None + + status: Optional[str] = None + + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None + """Interval between automatic syncs, in seconds. + + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). + """ + + token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instance_read_response.py b/src/cloudflare/types/aisearch/namespaces/instance_read_response.py new file mode 100644 index 00000000000..0905449fb17 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_read_response.py @@ -0,0 +1,411 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel +from ...r2.buckets.provider import Provider + +__all__ = [ + "InstanceReadResponse", + "CustomMetadata", + "IndexMethod", + "IndexingOptions", + "Metadata", + "MetadataSearchForAgents", + "PublicEndpointParams", + "PublicEndpointParamsChatCompletionsEndpoint", + "PublicEndpointParamsMcp", + "PublicEndpointParamsRateLimit", + "PublicEndpointParamsSearchEndpoint", + "RetrievalOptions", + "RetrievalOptionsBoostBy", + "SourceParams", + "SourceParamsWebCrawler", + "SourceParamsWebCrawlerCrawlOptions", + "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", + "SourceParamsWebCrawlerStoreOptions", +] + + +class CustomMetadata(BaseModel): + data_type: Literal["text", "number", "boolean", "datetime"] + + field_name: str + + +class IndexMethod(BaseModel): + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + keyword: bool + """Enable keyword (BM25) storage backend.""" + + vector: bool + """Enable vector (embedding) storage backend.""" + + +class IndexingOptions(BaseModel): + keyword_tokenizer: Optional[Literal["porter", "trigram"]] = None + """Tokenizer used for keyword search indexing. + + porter provides word-level tokenization with Porter stemming (good for natural + language queries). trigram enables character-level substring matching (good for + partial matches, code, identifiers). Changing this triggers a full re-index. + Defaults to porter. + """ + + +class MetadataSearchForAgents(BaseModel): + hostname: str + + zone_id: str + + zone_name: str + + +class Metadata(BaseModel): + created_from_aisearch_wizard: Optional[bool] = None + + search_for_agents: Optional[MetadataSearchForAgents] = None + + worker_domain: Optional[str] = None + + +class PublicEndpointParamsChatCompletionsEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable chat completions endpoint for this public endpoint""" + + +class PublicEndpointParamsMcp(BaseModel): + description: Optional[str] = None + + disabled: Optional[bool] = None + """Disable MCP endpoint for this public endpoint""" + + +class PublicEndpointParamsRateLimit(BaseModel): + period_ms: Optional[int] = None + + requests: Optional[int] = None + + technique: Optional[Literal["fixed", "sliding"]] = None + + +class PublicEndpointParamsSearchEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable search endpoint for this public endpoint""" + + +class PublicEndpointParams(BaseModel): + authorized_hosts: Optional[List[str]] = None + + chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint] = None + + enabled: Optional[bool] = None + + mcp: Optional[PublicEndpointParamsMcp] = None + + rate_limit: Optional[PublicEndpointParamsRateLimit] = None + + search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None + + +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + + keyword_match_mode: Optional[Literal["and", "or"]] = None + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + +class SourceParamsWebCrawlerCrawlOptions(BaseModel): + depth: Optional[float] = None + + include_external_links: Optional[bool] = None + + include_subdomains: Optional[bool] = None + + max_age: Optional[float] = None + + source: Optional[Literal["all", "sitemaps", "links"]] = None + + +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + +class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + + include_headers: Optional[Dict[str, str]] = None + + include_images: Optional[bool] = None + + specific_sitemaps: Optional[List[str]] = None + """List of specific sitemap URLs to use for crawling. + + Only valid when parse_type is 'sitemap'. + """ + + use_browser_rendering: Optional[bool] = None + + +class SourceParamsWebCrawlerStoreOptions(BaseModel): + storage_id: str + + r2_jurisdiction: Optional[str] = None + + storage_type: Optional[Provider] = None + + +class SourceParamsWebCrawler(BaseModel): + crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions] = None + + parse_options: Optional[SourceParamsWebCrawlerParseOptions] = None + + parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]] = None + + store_options: Optional[SourceParamsWebCrawlerStoreOptions] = None + + +class SourceParams(BaseModel): + exclude_items: Optional[List[str]] = None + """List of path patterns to exclude. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /admin/** matches /admin/users and + /admin/settings/advanced) + """ + + include_items: Optional[List[str]] = None + """List of path patterns to include. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) + """ + + prefix: Optional[str] = None + + r2_jurisdiction: Optional[str] = None + + web_crawler: Optional[SourceParamsWebCrawler] = None + + +class InstanceReadResponse(BaseModel): + id: str + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + created_at: datetime + + modified_at: datetime + + ai_gateway_id: Optional[str] = None + + aisearch_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = FieldInfo(alias="ai_search_model", default=None) + + cache: Optional[bool] = None + + cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]] = None + + chunk_overlap: Optional[int] = None + + chunk_size: Optional[int] = None + + created_by: Optional[str] = None + + custom_metadata: Optional[List[CustomMetadata]] = None + + embedding_model: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] = None + + enable: Optional[bool] = None + + engine_version: Optional[float] = None + + fusion_method: Optional[Literal["max", "rrf"]] = None + + hybrid_search_enabled: Optional[bool] = None + """Deprecated — use index_method instead.""" + + index_method: Optional[IndexMethod] = None + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + indexing_options: Optional[IndexingOptions] = None + + last_activity: Optional[datetime] = None + + max_num_results: Optional[int] = None + + metadata: Optional[Metadata] = None + + modified_by: Optional[str] = None + + namespace: Optional[str] = None + + paused: Optional[bool] = None + + public_endpoint_id: Optional[str] = None + + public_endpoint_params: Optional[PublicEndpointParams] = None + + reranking: Optional[bool] = None + + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] = None + + retrieval_options: Optional[RetrievalOptions] = None + + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = None + + rewrite_query: Optional[bool] = None + + score_threshold: Optional[float] = None + + source: Optional[str] = None + + source_params: Optional[SourceParams] = None + + status: Optional[str] = None + + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None + """Interval between automatic syncs, in seconds. + + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). + """ + + token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instance_search_params.py b/src/cloudflare/types/aisearch/namespaces/instance_search_params.py new file mode 100644 index 00000000000..3a8c7c4c112 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_search_params.py @@ -0,0 +1,155 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Iterable, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = [ + "InstanceSearchParams", + "AISearchOptions", + "AISearchOptionsCache", + "AISearchOptionsQueryRewrite", + "AISearchOptionsReranking", + "AISearchOptionsRetrieval", + "AISearchOptionsRetrievalBoostBy", + "Message", +] + + +class InstanceSearchParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + aisearch_options: Annotated[AISearchOptions, PropertyInfo(alias="ai_search_options")] + + messages: Iterable[Message] + + query: str + """A simple text query string. + + Alternative to 'messages' — provide either this or 'messages', not both. + """ + + +class AISearchOptionsCache(TypedDict, total=False): + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + + enabled: bool + + +class AISearchOptionsQueryRewrite(TypedDict, total=False): + enabled: bool + + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + + rewrite_prompt: str + + +class AISearchOptionsReranking(TypedDict, total=False): + enabled: bool + + match_threshold: float + + model: Literal["@cf/baai/bge-reranker-base", ""] + + +class AISearchOptionsRetrievalBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class AISearchOptionsRetrieval(TypedDict, total=False): + boost_by: Iterable[AISearchOptionsRetrievalBoostBy] + """Metadata fields to boost search results by. + + Overrides the instance-level boost_by config. Direction defaults to 'asc' for + numeric/datetime fields, 'exists' for text/boolean fields. Fields must match + 'timestamp' or a defined custom_metadata field. + """ + + context_expansion: int + + filters: Dict[str, object] + + fusion_method: Literal["max", "rrf"] + + keyword_match_mode: Literal["and", "or"] + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + match_threshold: float + + max_num_results: int + + retrieval_type: Literal["vector", "keyword", "hybrid"] + + return_on_failure: bool + + +class AISearchOptions(TypedDict, total=False): + cache: AISearchOptionsCache + + query_rewrite: AISearchOptionsQueryRewrite + + reranking: AISearchOptionsReranking + + retrieval: AISearchOptionsRetrieval + + +class Message(TypedDict, total=False, extra_items=object): # type: ignore[call-arg] + content: Required[Optional[str]] + + role: Required[Literal["system", "developer", "user", "assistant", "tool"]] diff --git a/src/cloudflare/types/aisearch/namespaces/instance_search_response.py b/src/cloudflare/types/aisearch/namespaces/instance_search_response.py new file mode 100644 index 00000000000..51b320b5632 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_search_response.py @@ -0,0 +1,50 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["InstanceSearchResponse", "Chunk", "ChunkItem", "ChunkScoringDetails"] + + +class ChunkItem(BaseModel): + key: str + + metadata: Optional[Dict[str, object]] = None + + timestamp: Optional[float] = None + + +class ChunkScoringDetails(BaseModel): + fusion_method: Optional[Literal["rrf", "max"]] = None + + keyword_rank: Optional[float] = None + + keyword_score: Optional[float] = None + + reranking_score: Optional[float] = None + + vector_rank: Optional[float] = None + + vector_score: Optional[float] = None + + +class Chunk(BaseModel): + id: str + + score: float + + text: str + + type: str + + item: Optional[ChunkItem] = None + + scoring_details: Optional[ChunkScoringDetails] = None + + +class InstanceSearchResponse(BaseModel): + chunks: List[Chunk] + + search_query: str diff --git a/src/cloudflare/types/aisearch/namespaces/instance_stats_response.py b/src/cloudflare/types/aisearch/namespaces/instance_stats_response.py new file mode 100644 index 00000000000..280f4a76fa2 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_stats_response.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Optional +from datetime import datetime + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["InstanceStatsResponse", "Engine", "EngineR2", "EngineVectorize"] + + +class EngineR2(BaseModel): + """R2 bucket storage usage in bytes.""" + + metadata_size_bytes: int = FieldInfo(alias="metadataSizeBytes") + + object_count: int = FieldInfo(alias="objectCount") + + payload_size_bytes: int = FieldInfo(alias="payloadSizeBytes") + + +class EngineVectorize(BaseModel): + """Vectorize index metadata (dimensions, vector count).""" + + dimensions: int + + vectors_count: int = FieldInfo(alias="vectorsCount") + + +class Engine(BaseModel): + """Engine-specific metadata. Present only for managed (v3) instances.""" + + r2: Optional[EngineR2] = None + """R2 bucket storage usage in bytes.""" + + vectorize: Optional[EngineVectorize] = None + """Vectorize index metadata (dimensions, vector count).""" + + +class InstanceStatsResponse(BaseModel): + completed: Optional[int] = None + + engine: Optional[Engine] = None + """Engine-specific metadata. Present only for managed (v3) instances.""" + + error: Optional[int] = None + + file_embed_errors: Optional[Dict[str, object]] = None + + index_source_errors: Optional[Dict[str, object]] = None + + last_activity: Optional[datetime] = None + + outdated: Optional[int] = None + + queued: Optional[int] = None + + running: Optional[int] = None + + skipped: Optional[int] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instance_update_params.py b/src/cloudflare/types/aisearch/namespaces/instance_update_params.py new file mode 100644 index 00000000000..e2ac52fc3bb --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_update_params.py @@ -0,0 +1,433 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Iterable, Optional +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ...._types import SequenceNotStr +from ...._utils import PropertyInfo +from ...r2.buckets.provider import Provider + +__all__ = [ + "InstanceUpdateParams", + "CustomMetadata", + "IndexMethod", + "IndexingOptions", + "Metadata", + "MetadataSearchForAgents", + "PublicEndpointParams", + "PublicEndpointParamsChatCompletionsEndpoint", + "PublicEndpointParamsMcp", + "PublicEndpointParamsRateLimit", + "PublicEndpointParamsSearchEndpoint", + "RetrievalOptions", + "RetrievalOptionsBoostBy", + "SourceParams", + "SourceParamsWebCrawler", + "SourceParamsWebCrawlerCrawlOptions", + "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", + "SourceParamsWebCrawlerStoreOptions", +] + + +class InstanceUpdateParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + ai_gateway_id: Optional[str] + + aisearch_model: Annotated[ + Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ], + PropertyInfo(alias="ai_search_model"), + ] + + cache: bool + + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + + chunk: bool + + chunk_overlap: int + + chunk_size: int + + custom_metadata: Iterable[CustomMetadata] + + embedding_model: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] + + fusion_method: Literal["max", "rrf"] + + index_method: IndexMethod + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + indexing_options: Optional[IndexingOptions] + + max_num_results: int + + metadata: Metadata + + paused: bool + + public_endpoint_params: PublicEndpointParams + + reranking: bool + + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] + + retrieval_options: Optional[RetrievalOptions] + + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] + + rewrite_query: bool + + score_threshold: float + + source_params: Optional[SourceParams] + + summarization: bool + + summarization_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] + + sync_interval: Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400] + """Interval between automatic syncs, in seconds. + + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). + """ + + system_prompt_aisearch: Annotated[Optional[str], PropertyInfo(alias="system_prompt_ai_search")] + + system_prompt_index_summarization: Optional[str] + + system_prompt_rewrite_query: Optional[str] + + token_id: str + + +class CustomMetadata(TypedDict, total=False): + data_type: Required[Literal["text", "number", "boolean", "datetime"]] + + field_name: Required[str] + + +class IndexMethod(TypedDict, total=False): + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + keyword: Required[bool] + """Enable keyword (BM25) storage backend.""" + + vector: Required[bool] + """Enable vector (embedding) storage backend.""" + + +class IndexingOptions(TypedDict, total=False): + keyword_tokenizer: Literal["porter", "trigram"] + """Tokenizer used for keyword search indexing. + + porter provides word-level tokenization with Porter stemming (good for natural + language queries). trigram enables character-level substring matching (good for + partial matches, code, identifiers). Changing this triggers a full re-index. + Defaults to porter. + """ + + +class MetadataSearchForAgents(TypedDict, total=False): + hostname: Required[str] + + zone_id: Required[str] + + zone_name: Required[str] + + +class Metadata(TypedDict, total=False): + created_from_aisearch_wizard: bool + + search_for_agents: MetadataSearchForAgents + + worker_domain: str + + +class PublicEndpointParamsChatCompletionsEndpoint(TypedDict, total=False): + disabled: bool + """Disable chat completions endpoint for this public endpoint""" + + +class PublicEndpointParamsMcp(TypedDict, total=False): + description: str + + disabled: bool + """Disable MCP endpoint for this public endpoint""" + + +class PublicEndpointParamsRateLimit(TypedDict, total=False): + period_ms: int + + requests: int + + technique: Literal["fixed", "sliding"] + + +class PublicEndpointParamsSearchEndpoint(TypedDict, total=False): + disabled: bool + """Disable search endpoint for this public endpoint""" + + +class PublicEndpointParams(TypedDict, total=False): + authorized_hosts: SequenceNotStr[str] + + chat_completions_endpoint: PublicEndpointParamsChatCompletionsEndpoint + + enabled: bool + + mcp: PublicEndpointParamsMcp + + rate_limit: PublicEndpointParamsRateLimit + + search_endpoint: PublicEndpointParamsSearchEndpoint + + +class RetrievalOptionsBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class RetrievalOptions(TypedDict, total=False): + boost_by: Iterable[RetrievalOptionsBoostBy] + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + + keyword_match_mode: Literal["and", "or"] + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + +class SourceParamsWebCrawlerCrawlOptions(TypedDict, total=False): + depth: float + + include_external_links: bool + + include_subdomains: bool + + max_age: float + + source: Literal["all", "sitemaps", "links"] + + +class SourceParamsWebCrawlerParseOptionsContentSelector(TypedDict, total=False): + path: Required[str] + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: Required[str] + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + +class SourceParamsWebCrawlerParseOptions(TypedDict, total=False): + content_selector: Iterable[SourceParamsWebCrawlerParseOptionsContentSelector] + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + + include_headers: Dict[str, str] + + include_images: bool + + specific_sitemaps: SequenceNotStr[str] + """List of specific sitemap URLs to use for crawling. + + Only valid when parse_type is 'sitemap'. + """ + + use_browser_rendering: bool + + +class SourceParamsWebCrawlerStoreOptions(TypedDict, total=False): + storage_id: Required[str] + + r2_jurisdiction: str + + storage_type: Provider + + +class SourceParamsWebCrawler(TypedDict, total=False): + crawl_options: SourceParamsWebCrawlerCrawlOptions + + parse_options: SourceParamsWebCrawlerParseOptions + + parse_type: Literal["sitemap", "feed-rss", "crawl"] + + store_options: SourceParamsWebCrawlerStoreOptions + + +class SourceParams(TypedDict, total=False): + exclude_items: SequenceNotStr[str] + """List of path patterns to exclude. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /admin/** matches /admin/users and + /admin/settings/advanced) + """ + + include_items: SequenceNotStr[str] + """List of path patterns to include. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) + """ + + prefix: str + + r2_jurisdiction: str + + web_crawler: SourceParamsWebCrawler diff --git a/src/cloudflare/types/aisearch/namespaces/instance_update_response.py b/src/cloudflare/types/aisearch/namespaces/instance_update_response.py new file mode 100644 index 00000000000..0f4e80924d1 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instance_update_response.py @@ -0,0 +1,411 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel +from ...r2.buckets.provider import Provider + +__all__ = [ + "InstanceUpdateResponse", + "CustomMetadata", + "IndexMethod", + "IndexingOptions", + "Metadata", + "MetadataSearchForAgents", + "PublicEndpointParams", + "PublicEndpointParamsChatCompletionsEndpoint", + "PublicEndpointParamsMcp", + "PublicEndpointParamsRateLimit", + "PublicEndpointParamsSearchEndpoint", + "RetrievalOptions", + "RetrievalOptionsBoostBy", + "SourceParams", + "SourceParamsWebCrawler", + "SourceParamsWebCrawlerCrawlOptions", + "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", + "SourceParamsWebCrawlerStoreOptions", +] + + +class CustomMetadata(BaseModel): + data_type: Literal["text", "number", "boolean", "datetime"] + + field_name: str + + +class IndexMethod(BaseModel): + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + keyword: bool + """Enable keyword (BM25) storage backend.""" + + vector: bool + """Enable vector (embedding) storage backend.""" + + +class IndexingOptions(BaseModel): + keyword_tokenizer: Optional[Literal["porter", "trigram"]] = None + """Tokenizer used for keyword search indexing. + + porter provides word-level tokenization with Porter stemming (good for natural + language queries). trigram enables character-level substring matching (good for + partial matches, code, identifiers). Changing this triggers a full re-index. + Defaults to porter. + """ + + +class MetadataSearchForAgents(BaseModel): + hostname: str + + zone_id: str + + zone_name: str + + +class Metadata(BaseModel): + created_from_aisearch_wizard: Optional[bool] = None + + search_for_agents: Optional[MetadataSearchForAgents] = None + + worker_domain: Optional[str] = None + + +class PublicEndpointParamsChatCompletionsEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable chat completions endpoint for this public endpoint""" + + +class PublicEndpointParamsMcp(BaseModel): + description: Optional[str] = None + + disabled: Optional[bool] = None + """Disable MCP endpoint for this public endpoint""" + + +class PublicEndpointParamsRateLimit(BaseModel): + period_ms: Optional[int] = None + + requests: Optional[int] = None + + technique: Optional[Literal["fixed", "sliding"]] = None + + +class PublicEndpointParamsSearchEndpoint(BaseModel): + disabled: Optional[bool] = None + """Disable search endpoint for this public endpoint""" + + +class PublicEndpointParams(BaseModel): + authorized_hosts: Optional[List[str]] = None + + chat_completions_endpoint: Optional[PublicEndpointParamsChatCompletionsEndpoint] = None + + enabled: Optional[bool] = None + + mcp: Optional[PublicEndpointParamsMcp] = None + + rate_limit: Optional[PublicEndpointParamsRateLimit] = None + + search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None + + +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + and datetime fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric/datetime + fields, 'exists' for text/boolean fields. + """ + + +class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + + keyword_match_mode: Optional[Literal["and", "or"]] = None + """Controls which documents are candidates for BM25 scoring. + + 'and' restricts candidates to documents containing all query terms; 'or' + includes any document containing at least one term, ranked by BM25 relevance. + Defaults to 'and'. + """ + + +class SourceParamsWebCrawlerCrawlOptions(BaseModel): + depth: Optional[float] = None + + include_external_links: Optional[bool] = None + + include_subdomains: Optional[bool] = None + + max_age: Optional[float] = None + + source: Optional[Literal["all", "sitemaps", "links"]] = None + + +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + +class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + + include_headers: Optional[Dict[str, str]] = None + + include_images: Optional[bool] = None + + specific_sitemaps: Optional[List[str]] = None + """List of specific sitemap URLs to use for crawling. + + Only valid when parse_type is 'sitemap'. + """ + + use_browser_rendering: Optional[bool] = None + + +class SourceParamsWebCrawlerStoreOptions(BaseModel): + storage_id: str + + r2_jurisdiction: Optional[str] = None + + storage_type: Optional[Provider] = None + + +class SourceParamsWebCrawler(BaseModel): + crawl_options: Optional[SourceParamsWebCrawlerCrawlOptions] = None + + parse_options: Optional[SourceParamsWebCrawlerParseOptions] = None + + parse_type: Optional[Literal["sitemap", "feed-rss", "crawl"]] = None + + store_options: Optional[SourceParamsWebCrawlerStoreOptions] = None + + +class SourceParams(BaseModel): + exclude_items: Optional[List[str]] = None + """List of path patterns to exclude. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /admin/** matches /admin/users and + /admin/settings/advanced) + """ + + include_items: Optional[List[str]] = None + """List of path patterns to include. + + Uses micromatch glob syntax: \\** matches within a path segment, ** matches across + path segments (e.g., /blog/** matches /blog/post and /blog/2024/post) + """ + + prefix: Optional[str] = None + + r2_jurisdiction: Optional[str] = None + + web_crawler: Optional[SourceParamsWebCrawler] = None + + +class InstanceUpdateResponse(BaseModel): + id: str + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + created_at: datetime + + modified_at: datetime + + ai_gateway_id: Optional[str] = None + + aisearch_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = FieldInfo(alias="ai_search_model", default=None) + + cache: Optional[bool] = None + + cache_threshold: Optional[Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"]] = None + + chunk_overlap: Optional[int] = None + + chunk_size: Optional[int] = None + + created_by: Optional[str] = None + + custom_metadata: Optional[List[CustomMetadata]] = None + + embedding_model: Optional[ + 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", + "google-ai-studio/gemini-embedding-2-preview", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + ] = None + + enable: Optional[bool] = None + + engine_version: Optional[float] = None + + fusion_method: Optional[Literal["max", "rrf"]] = None + + hybrid_search_enabled: Optional[bool] = None + """Deprecated — use index_method instead.""" + + index_method: Optional[IndexMethod] = None + """Controls which storage backends are used during indexing. + + Defaults to vector-only. + """ + + indexing_options: Optional[IndexingOptions] = None + + last_activity: Optional[datetime] = None + + max_num_results: Optional[int] = None + + metadata: Optional[Metadata] = None + + modified_by: Optional[str] = None + + namespace: Optional[str] = None + + paused: Optional[bool] = None + + public_endpoint_id: Optional[str] = None + + public_endpoint_params: Optional[PublicEndpointParams] = None + + reranking: Optional[bool] = None + + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] = None + + retrieval_options: Optional[RetrievalOptions] = None + + rewrite_model: Optional[ + Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/zai-org/glm-4.7-flash", + "@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", + "@cf/google/gemma-3-12b-it", + "@cf/google/gemma-4-26b-a4b-it", + "@cf/moonshotai/kimi-k2.5", + "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", + "", + ] + ] = None + + rewrite_query: Optional[bool] = None + + score_threshold: Optional[float] = None + + source: Optional[str] = None + + source_params: Optional[SourceParams] = None + + status: Optional[str] = None + + sync_interval: Optional[Literal[900, 1800, 3600, 7200, 14400, 21600, 43200, 86400]] = None + """Interval between automatic syncs, in seconds. + + Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), + 21600 (6h), 43200 (12h), 86400 (24h). + """ + + token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instances/__init__.py b/src/cloudflare/types/aisearch/namespaces/instances/__init__.py new file mode 100644 index 00000000000..d184d3fe33e --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/__init__.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .job_list_params import JobListParams as JobListParams +from .job_logs_params import JobLogsParams as JobLogsParams +from .item_list_params import ItemListParams as ItemListParams +from .item_logs_params import ItemLogsParams as ItemLogsParams +from .item_sync_params import ItemSyncParams as ItemSyncParams +from .job_get_response import JobGetResponse as JobGetResponse +from .item_get_response import ItemGetResponse as ItemGetResponse +from .job_create_params import JobCreateParams as JobCreateParams +from .job_list_response import JobListResponse as JobListResponse +from .job_logs_response import JobLogsResponse as JobLogsResponse +from .job_update_params import JobUpdateParams as JobUpdateParams +from .item_chunks_params import ItemChunksParams as ItemChunksParams +from .item_list_response import ItemListResponse as ItemListResponse +from .item_logs_response import ItemLogsResponse as ItemLogsResponse +from .item_sync_response import ItemSyncResponse as ItemSyncResponse +from .item_upload_params import ItemUploadParams as ItemUploadParams +from .job_create_response import JobCreateResponse as JobCreateResponse +from .job_update_response import JobUpdateResponse as JobUpdateResponse +from .item_chunks_response import ItemChunksResponse as ItemChunksResponse +from .item_delete_response import ItemDeleteResponse as ItemDeleteResponse +from .item_upload_response import ItemUploadResponse as ItemUploadResponse +from .item_create_or_update_params import ItemCreateOrUpdateParams as ItemCreateOrUpdateParams +from .item_create_or_update_response import ItemCreateOrUpdateResponse as ItemCreateOrUpdateResponse diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_chunks_params.py b/src/cloudflare/types/aisearch/namespaces/instances/item_chunks_params.py new file mode 100644 index 00000000000..182e2d1350f --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_chunks_params.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ItemChunksParams"] + + +class ItemChunksParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + id: Required[str] + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + limit: int + + offset: int diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_chunks_response.py b/src/cloudflare/types/aisearch/namespaces/instances/item_chunks_response.py new file mode 100644 index 00000000000..8adb7ad1060 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_chunks_response.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from typing_extensions import TypeAlias + +from ....._models import BaseModel + +__all__ = ["ItemChunksResponse", "ItemChunksResponseItem", "ItemChunksResponseItemItem"] + + +class ItemChunksResponseItemItem(BaseModel): + key: str + + metadata: Optional[Dict[str, object]] = None + + timestamp: Optional[float] = None + + +class ItemChunksResponseItem(BaseModel): + id: str + + item: ItemChunksResponseItemItem + + text: str + + end_byte: Optional[float] = None + + start_byte: Optional[float] = None + + +ItemChunksResponse: TypeAlias = List[ItemChunksResponseItem] diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_create_or_update_params.py b/src/cloudflare/types/aisearch/namespaces/instances/item_create_or_update_params.py new file mode 100644 index 00000000000..595acb2b092 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_create_or_update_params.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ItemCreateOrUpdateParams"] + + +class ItemCreateOrUpdateParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + key: Required[str] + """Item key / filename. Must not exceed 128 characters.""" + + next_action: Required[Literal["INDEX"]] diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_create_or_update_response.py b/src/cloudflare/types/aisearch/namespaces/instances/item_create_or_update_response.py new file mode 100644 index 00000000000..46e8702e1b0 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_create_or_update_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["ItemCreateOrUpdateResponse"] + + +class ItemCreateOrUpdateResponse(BaseModel): + id: str + + checksum: str + + chunks_count: Optional[int] = None + + created_at: datetime + + file_size: Optional[float] = None + + key: str + + last_seen_at: datetime + + namespace: str + + next_action: Optional[Literal["INDEX", "DELETE"]] = None + + source_id: Optional[str] = None + """Identifies which data source this item belongs to. + + "builtin" for uploaded files, "{type}:{source}" for external sources, null for + legacy items. + """ + + status: Literal["queued", "running", "completed", "error", "skipped", "outdated"] + + error: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_delete_response.py b/src/cloudflare/types/aisearch/namespaces/instances/item_delete_response.py new file mode 100644 index 00000000000..e8406b4f8d7 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_delete_response.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from ....._models import BaseModel + +__all__ = ["ItemDeleteResponse"] + + +class ItemDeleteResponse(BaseModel): + key: str diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_get_response.py b/src/cloudflare/types/aisearch/namespaces/instances/item_get_response.py new file mode 100644 index 00000000000..3463a3075ee --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_get_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["ItemGetResponse"] + + +class ItemGetResponse(BaseModel): + id: str + + checksum: str + + chunks_count: Optional[int] = None + + created_at: datetime + + file_size: Optional[float] = None + + key: str + + last_seen_at: datetime + + namespace: str + + next_action: Optional[Literal["INDEX", "DELETE"]] = None + + source_id: Optional[str] = None + """Identifies which data source this item belongs to. + + "builtin" for uploaded files, "{type}:{source}" for external sources, null for + legacy items. + """ + + status: Literal["queued", "running", "completed", "error", "skipped", "outdated"] + + error: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_list_params.py b/src/cloudflare/types/aisearch/namespaces/instances/item_list_params.py new file mode 100644 index 00000000000..59091e3f9a6 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_list_params.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ItemListParams"] + + +class ItemListParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + item_id: str + """Filter items by their unique ID. Returns at most one item.""" + + metadata_filter: str + """JSON-encoded metadata filter using Vectorize filter syntax. + + Examples: {"folder":"reports/"}, + {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}} + """ + + page: int + + per_page: int + + search: str + + sort_by: Literal["status", "modified_at"] + """Sort order for items. + + "status" (default) sorts by status priority then last_seen_at. "modified_at" + sorts by file modification time (most recent first), falling back to created_at. + """ + + source: str + """Filter items by source_id. + + Use "builtin" for uploaded files, or a source identifier like + "web-crawler:https://example.com". + """ + + status: Literal["queued", "running", "completed", "error", "skipped", "outdated"] diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_list_response.py b/src/cloudflare/types/aisearch/namespaces/instances/item_list_response.py new file mode 100644 index 00000000000..174f6774d46 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_list_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["ItemListResponse"] + + +class ItemListResponse(BaseModel): + id: str + + checksum: str + + chunks_count: Optional[int] = None + + created_at: datetime + + file_size: Optional[float] = None + + key: str + + last_seen_at: datetime + + namespace: str + + next_action: Optional[Literal["INDEX", "DELETE"]] = None + + source_id: Optional[str] = None + """Identifies which data source this item belongs to. + + "builtin" for uploaded files, "{type}:{source}" for external sources, null for + legacy items. + """ + + status: Literal["queued", "running", "completed", "error", "skipped", "outdated"] + + error: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_logs_params.py b/src/cloudflare/types/aisearch/namespaces/instances/item_logs_params.py new file mode 100644 index 00000000000..64478012b2e --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_logs_params.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ItemLogsParams"] + + +class ItemLogsParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + id: Required[str] + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + cursor: str + + limit: int diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_logs_response.py b/src/cloudflare/types/aisearch/namespaces/instances/item_logs_response.py new file mode 100644 index 00000000000..13fd4544f9f --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_logs_response.py @@ -0,0 +1,30 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import TypeAlias + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel + +__all__ = ["ItemLogsResponse", "ItemLogsResponseItem"] + + +class ItemLogsResponseItem(BaseModel): + action: str + + chunk_count: Optional[int] = FieldInfo(alias="chunkCount", default=None) + + error_type: Optional[str] = FieldInfo(alias="errorType", default=None) + + file_key: str = FieldInfo(alias="fileKey") + + message: Optional[str] = None + + processing_time_ms: Optional[int] = FieldInfo(alias="processingTimeMs", default=None) + + timestamp: datetime + + +ItemLogsResponse: TypeAlias = List[ItemLogsResponseItem] diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_sync_params.py b/src/cloudflare/types/aisearch/namespaces/instances/item_sync_params.py new file mode 100644 index 00000000000..2f6a96f0196 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_sync_params.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ItemSyncParams"] + + +class ItemSyncParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + id: Required[str] + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + next_action: Required[Literal["INDEX"]] diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_sync_response.py b/src/cloudflare/types/aisearch/namespaces/instances/item_sync_response.py new file mode 100644 index 00000000000..a55fb66bdff --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_sync_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["ItemSyncResponse"] + + +class ItemSyncResponse(BaseModel): + id: str + + checksum: str + + chunks_count: Optional[int] = None + + created_at: datetime + + file_size: Optional[float] = None + + key: str + + last_seen_at: datetime + + namespace: str + + next_action: Optional[Literal["INDEX", "DELETE"]] = None + + source_id: Optional[str] = None + """Identifies which data source this item belongs to. + + "builtin" for uploaded files, "{type}:{source}" for external sources, null for + legacy items. + """ + + status: Literal["queued", "running", "completed", "error", "skipped", "outdated"] + + error: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_upload_params.py b/src/cloudflare/types/aisearch/namespaces/instances/item_upload_params.py new file mode 100644 index 00000000000..71ee15f99a1 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_upload_params.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from ....._types import FileTypes + +__all__ = ["ItemUploadParams", "File"] + + +class ItemUploadParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + file: Required[File] + + +class File(TypedDict, total=False): + file: Required[FileTypes] + """The file to upload (max 4MB). Filename must not exceed 128 characters.""" + + metadata: str + """JSON string of custom metadata key-value pairs.""" + + wait_for_completion: bool + """Wait for indexing to complete before responding. Defaults to false.""" diff --git a/src/cloudflare/types/aisearch/namespaces/instances/item_upload_response.py b/src/cloudflare/types/aisearch/namespaces/instances/item_upload_response.py new file mode 100644 index 00000000000..d7c88105669 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/item_upload_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["ItemUploadResponse"] + + +class ItemUploadResponse(BaseModel): + id: str + + checksum: str + + chunks_count: Optional[int] = None + + created_at: datetime + + file_size: Optional[float] = None + + key: str + + last_seen_at: datetime + + namespace: str + + next_action: Optional[Literal["INDEX", "DELETE"]] = None + + source_id: Optional[str] = None + """Identifies which data source this item belongs to. + + "builtin" for uploaded files, "{type}:{source}" for external sources, null for + legacy items. + """ + + status: Literal["queued", "running", "completed", "error", "skipped", "outdated"] + + error: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instances/job_create_params.py b/src/cloudflare/types/aisearch/namespaces/instances/job_create_params.py new file mode 100644 index 00000000000..3b661c9281b --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/job_create_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["JobCreateParams"] + + +class JobCreateParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + description: str diff --git a/src/cloudflare/types/aisearch/namespaces/instances/job_create_response.py b/src/cloudflare/types/aisearch/namespaces/instances/job_create_response.py new file mode 100644 index 00000000000..71f4d602ee2 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/job_create_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["JobCreateResponse"] + + +class JobCreateResponse(BaseModel): + id: str + + source: Literal["user", "schedule"] + + description: Optional[str] = None + + end_reason: Optional[str] = None + + ended_at: Optional[str] = None + + last_seen_at: Optional[str] = None + + started_at: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instances/job_get_response.py b/src/cloudflare/types/aisearch/namespaces/instances/job_get_response.py new file mode 100644 index 00000000000..5ba54e35920 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/job_get_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["JobGetResponse"] + + +class JobGetResponse(BaseModel): + id: str + + source: Literal["user", "schedule"] + + description: Optional[str] = None + + end_reason: Optional[str] = None + + ended_at: Optional[str] = None + + last_seen_at: Optional[str] = None + + started_at: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instances/job_list_params.py b/src/cloudflare/types/aisearch/namespaces/instances/job_list_params.py new file mode 100644 index 00000000000..a57c0e147f6 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/job_list_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["JobListParams"] + + +class JobListParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + page: int + + per_page: int diff --git a/src/cloudflare/types/aisearch/namespaces/instances/job_list_response.py b/src/cloudflare/types/aisearch/namespaces/instances/job_list_response.py new file mode 100644 index 00000000000..87920298476 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/job_list_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["JobListResponse"] + + +class JobListResponse(BaseModel): + id: str + + source: Literal["user", "schedule"] + + description: Optional[str] = None + + end_reason: Optional[str] = None + + ended_at: Optional[str] = None + + last_seen_at: Optional[str] = None + + started_at: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/namespaces/instances/job_logs_params.py b/src/cloudflare/types/aisearch/namespaces/instances/job_logs_params.py new file mode 100644 index 00000000000..cb626d6d40b --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/job_logs_params.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["JobLogsParams"] + + +class JobLogsParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + id: Required[str] + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + page: int + + per_page: int diff --git a/src/cloudflare/types/aisearch/namespaces/instances/job_logs_response.py b/src/cloudflare/types/aisearch/namespaces/instances/job_logs_response.py new file mode 100644 index 00000000000..c631ee58705 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/job_logs_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from ....._models import BaseModel + +__all__ = ["JobLogsResponse", "JobLogsResponseItem"] + + +class JobLogsResponseItem(BaseModel): + id: int + + created_at: float + + message: str + + message_type: int + + +JobLogsResponse: TypeAlias = List[JobLogsResponseItem] diff --git a/src/cloudflare/types/aisearch/namespaces/instances/job_update_params.py b/src/cloudflare/types/aisearch/namespaces/instances/job_update_params.py new file mode 100644 index 00000000000..1cd6b87f495 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/job_update_params.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["JobUpdateParams"] + + +class JobUpdateParams(TypedDict, total=False): + account_id: str + + name: Required[str] + + id: Required[str] + """AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.""" + + action: Required[Literal["cancel"]] diff --git a/src/cloudflare/types/aisearch/namespaces/instances/job_update_response.py b/src/cloudflare/types/aisearch/namespaces/instances/job_update_response.py new file mode 100644 index 00000000000..8b363a5d356 --- /dev/null +++ b/src/cloudflare/types/aisearch/namespaces/instances/job_update_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["JobUpdateResponse"] + + +class JobUpdateResponse(BaseModel): + id: str + + source: Literal["user", "schedule"] + + description: Optional[str] = None + + end_reason: Optional[str] = None + + ended_at: Optional[str] = None + + last_seen_at: Optional[str] = None + + started_at: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/token_create_params.py b/src/cloudflare/types/aisearch/token_create_params.py index 930d7b5eb33..8373703deee 100644 --- a/src/cloudflare/types/aisearch/token_create_params.py +++ b/src/cloudflare/types/aisearch/token_create_params.py @@ -8,10 +8,12 @@ class TokenCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str cf_api_id: Required[str] cf_api_key: Required[str] name: Required[str] + + legacy: bool diff --git a/src/cloudflare/types/aisearch/token_delete_response.py b/src/cloudflare/types/aisearch/token_delete_response.py deleted file mode 100644 index 80331067158..00000000000 --- a/src/cloudflare/types/aisearch/token_delete_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime - -from ..._models import BaseModel - -__all__ = ["TokenDeleteResponse"] - - -class TokenDeleteResponse(BaseModel): - id: str - - cf_api_id: str - - created_at: datetime - - modified_at: datetime - - name: str - - created_by: Optional[str] = None - - enabled: Optional[bool] = None - - legacy: Optional[bool] = None - - modified_by: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/token_list_params.py b/src/cloudflare/types/aisearch/token_list_params.py index 01a1a0f2add..e98a767635b 100644 --- a/src/cloudflare/types/aisearch/token_list_params.py +++ b/src/cloudflare/types/aisearch/token_list_params.py @@ -2,20 +2,19 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import TypedDict __all__ = ["TokenListParams"] class TokenListParams(TypedDict, total=False): - account_id: Required[str] - - order_by: Literal["created_at"] - """Order By Column Name""" - - order_by_direction: Literal["asc", "desc"] - """Order By Direction""" + account_id: str page: int + """Page number (1-indexed).""" per_page: int + """Number of results per page.""" + + search: str + """Filter tokens whose name contains this string (case-insensitive).""" diff --git a/src/cloudflare/types/aisearch/token_update_params.py b/src/cloudflare/types/aisearch/token_update_params.py index 5591335b963..c2733902346 100644 --- a/src/cloudflare/types/aisearch/token_update_params.py +++ b/src/cloudflare/types/aisearch/token_update_params.py @@ -8,10 +8,12 @@ class TokenUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str cf_api_id: Required[str] cf_api_key: Required[str] name: Required[str] + + legacy: bool diff --git a/src/cloudflare/types/alerting/destinations/webhook_create_params.py b/src/cloudflare/types/alerting/destinations/webhook_create_params.py index 9a14c7e35ca..4c5d1aeae95 100644 --- a/src/cloudflare/types/alerting/destinations/webhook_create_params.py +++ b/src/cloudflare/types/alerting/destinations/webhook_create_params.py @@ -8,7 +8,7 @@ class WebhookCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account id""" name: Required[str] diff --git a/src/cloudflare/types/alerting/destinations/webhook_update_params.py b/src/cloudflare/types/alerting/destinations/webhook_update_params.py index d28b2ea9efe..72d116ec2fb 100644 --- a/src/cloudflare/types/alerting/destinations/webhook_update_params.py +++ b/src/cloudflare/types/alerting/destinations/webhook_update_params.py @@ -8,7 +8,7 @@ class WebhookUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account id""" name: Required[str] diff --git a/src/cloudflare/types/alerting/history_list_params.py b/src/cloudflare/types/alerting/history_list_params.py index 913da1c6c6f..86ae2739009 100644 --- a/src/cloudflare/types/alerting/history_list_params.py +++ b/src/cloudflare/types/alerting/history_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class HistoryListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account id""" before: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/alerting/policy_create_params.py b/src/cloudflare/types/alerting/policy_create_params.py index fa5ed2838cf..f943d4c3843 100644 --- a/src/cloudflare/types/alerting/policy_create_params.py +++ b/src/cloudflare/types/alerting/policy_create_params.py @@ -11,7 +11,7 @@ class PolicyCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account id""" alert_type: Required[ diff --git a/src/cloudflare/types/alerting/policy_update_params.py b/src/cloudflare/types/alerting/policy_update_params.py index 92df4ae3c39..dd096305316 100644 --- a/src/cloudflare/types/alerting/policy_update_params.py +++ b/src/cloudflare/types/alerting/policy_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from .mechanism_param import MechanismParam from .policy_filter_param import PolicyFilterParam @@ -11,7 +11,7 @@ class PolicyUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account id""" alert_interval: str diff --git a/src/cloudflare/types/alerting/silence_create_params.py b/src/cloudflare/types/alerting/silence_create_params.py index d8d733bab17..854618e5cd0 100644 --- a/src/cloudflare/types/alerting/silence_create_params.py +++ b/src/cloudflare/types/alerting/silence_create_params.py @@ -9,7 +9,7 @@ class SilenceCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account id""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/alerting/silence_update_params.py b/src/cloudflare/types/alerting/silence_update_params.py index 59567cfd488..4ef82cc2633 100644 --- a/src/cloudflare/types/alerting/silence_update_params.py +++ b/src/cloudflare/types/alerting/silence_update_params.py @@ -9,7 +9,7 @@ class SilenceUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account id""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/api_gateway/configuration_get_params.py b/src/cloudflare/types/api_gateway/configuration_get_params.py index c00dd74928d..44f5d98094e 100644 --- a/src/cloudflare/types/api_gateway/configuration_get_params.py +++ b/src/cloudflare/types/api_gateway/configuration_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ConfigurationGetParams"] class ConfigurationGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" normalize: bool diff --git a/src/cloudflare/types/api_gateway/configuration_update_params.py b/src/cloudflare/types/api_gateway/configuration_update_params.py index f1d0aae61cc..472e997a860 100644 --- a/src/cloudflare/types/api_gateway/configuration_update_params.py +++ b/src/cloudflare/types/api_gateway/configuration_update_params.py @@ -14,7 +14,7 @@ class ConfigurationUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" auth_id_characteristics: Required[Iterable[AuthIDCharacteristic]] diff --git a/src/cloudflare/types/api_gateway/discovery/operation_bulk_edit_params.py b/src/cloudflare/types/api_gateway/discovery/operation_bulk_edit_params.py index c750d5f3eed..4e70d7eb3dc 100644 --- a/src/cloudflare/types/api_gateway/discovery/operation_bulk_edit_params.py +++ b/src/cloudflare/types/api_gateway/discovery/operation_bulk_edit_params.py @@ -9,7 +9,7 @@ class OperationBulkEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[Dict[str, Body]] diff --git a/src/cloudflare/types/api_gateway/discovery/operation_edit_params.py b/src/cloudflare/types/api_gateway/discovery/operation_edit_params.py index 8431ce868d8..a3ef0ccbb02 100644 --- a/src/cloudflare/types/api_gateway/discovery/operation_edit_params.py +++ b/src/cloudflare/types/api_gateway/discovery/operation_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["OperationEditParams"] class OperationEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" state: Literal["review", "ignored"] diff --git a/src/cloudflare/types/api_gateway/discovery/operation_list_params.py b/src/cloudflare/types/api_gateway/discovery/operation_list_params.py index 9fa1389e662..f9c52a91006 100644 --- a/src/cloudflare/types/api_gateway/discovery/operation_list_params.py +++ b/src/cloudflare/types/api_gateway/discovery/operation_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ...._types import SequenceNotStr @@ -10,7 +10,7 @@ class OperationListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" diff: bool diff --git a/src/cloudflare/types/api_gateway/expression_template/fallthrough_create_params.py b/src/cloudflare/types/api_gateway/expression_template/fallthrough_create_params.py index 18508a7a0d9..ecece881e0b 100644 --- a/src/cloudflare/types/api_gateway/expression_template/fallthrough_create_params.py +++ b/src/cloudflare/types/api_gateway/expression_template/fallthrough_create_params.py @@ -10,7 +10,7 @@ class FallthroughCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" hosts: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/api_gateway/label_list_params.py b/src/cloudflare/types/api_gateway/label_list_params.py index b337bed3c58..f5220a6d88b 100644 --- a/src/cloudflare/types/api_gateway/label_list_params.py +++ b/src/cloudflare/types/api_gateway/label_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["LabelListParams"] class LabelListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/api_gateway/labels/managed/resources/operation_update_params.py b/src/cloudflare/types/api_gateway/labels/managed/resources/operation_update_params.py index 9ac1c183791..cdd3a5efdcb 100644 --- a/src/cloudflare/types/api_gateway/labels/managed/resources/operation_update_params.py +++ b/src/cloudflare/types/api_gateway/labels/managed/resources/operation_update_params.py @@ -10,7 +10,7 @@ class OperationUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" selector: Required[Selector] diff --git a/src/cloudflare/types/api_gateway/labels/managed_get_params.py b/src/cloudflare/types/api_gateway/labels/managed_get_params.py index 142f564d8da..83b7390605b 100644 --- a/src/cloudflare/types/api_gateway/labels/managed_get_params.py +++ b/src/cloudflare/types/api_gateway/labels/managed_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ManagedGetParams"] class ManagedGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" with_mapped_resource_counts: bool diff --git a/src/cloudflare/types/api_gateway/labels/user/resources/operation_update_params.py b/src/cloudflare/types/api_gateway/labels/user/resources/operation_update_params.py index 9ac1c183791..cdd3a5efdcb 100644 --- a/src/cloudflare/types/api_gateway/labels/user/resources/operation_update_params.py +++ b/src/cloudflare/types/api_gateway/labels/user/resources/operation_update_params.py @@ -10,7 +10,7 @@ class OperationUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" selector: Required[Selector] diff --git a/src/cloudflare/types/api_gateway/labels/user_bulk_create_params.py b/src/cloudflare/types/api_gateway/labels/user_bulk_create_params.py index 49d825ddf5a..c9c9a2dc3df 100644 --- a/src/cloudflare/types/api_gateway/labels/user_bulk_create_params.py +++ b/src/cloudflare/types/api_gateway/labels/user_bulk_create_params.py @@ -9,7 +9,7 @@ class UserBulkCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/api_gateway/labels/user_edit_params.py b/src/cloudflare/types/api_gateway/labels/user_edit_params.py index d673bc20605..150342216a2 100644 --- a/src/cloudflare/types/api_gateway/labels/user_edit_params.py +++ b/src/cloudflare/types/api_gateway/labels/user_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["UserEditParams"] class UserEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" description: str diff --git a/src/cloudflare/types/api_gateway/labels/user_get_params.py b/src/cloudflare/types/api_gateway/labels/user_get_params.py index 7dc41440ffa..b3aa7a7d652 100644 --- a/src/cloudflare/types/api_gateway/labels/user_get_params.py +++ b/src/cloudflare/types/api_gateway/labels/user_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["UserGetParams"] class UserGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" with_mapped_resource_counts: bool diff --git a/src/cloudflare/types/api_gateway/labels/user_update_params.py b/src/cloudflare/types/api_gateway/labels/user_update_params.py index b8b57259532..078b73f271e 100644 --- a/src/cloudflare/types/api_gateway/labels/user_update_params.py +++ b/src/cloudflare/types/api_gateway/labels/user_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["UserUpdateParams"] class UserUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" description: str diff --git a/src/cloudflare/types/api_gateway/operation_bulk_create_params.py b/src/cloudflare/types/api_gateway/operation_bulk_create_params.py index f5ef1ce8db1..56e8e0b8933 100644 --- a/src/cloudflare/types/api_gateway/operation_bulk_create_params.py +++ b/src/cloudflare/types/api_gateway/operation_bulk_create_params.py @@ -9,7 +9,7 @@ class OperationBulkCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/api_gateway/operation_create_params.py b/src/cloudflare/types/api_gateway/operation_create_params.py index f6eeb0677a1..bf63f2065de 100644 --- a/src/cloudflare/types/api_gateway/operation_create_params.py +++ b/src/cloudflare/types/api_gateway/operation_create_params.py @@ -8,7 +8,7 @@ class OperationCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" endpoint: Required[str] diff --git a/src/cloudflare/types/api_gateway/operation_get_params.py b/src/cloudflare/types/api_gateway/operation_get_params.py index 80b1e80e724..11e25466100 100644 --- a/src/cloudflare/types/api_gateway/operation_get_params.py +++ b/src/cloudflare/types/api_gateway/operation_get_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["OperationGetParams"] class OperationGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] diff --git a/src/cloudflare/types/api_gateway/operation_list_params.py b/src/cloudflare/types/api_gateway/operation_list_params.py index 4ecdcf5db5e..4371540b40c 100644 --- a/src/cloudflare/types/api_gateway/operation_list_params.py +++ b/src/cloudflare/types/api_gateway/operation_list_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -11,7 +11,7 @@ class OperationListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/api_gateway/operations/label_bulk_create_params.py b/src/cloudflare/types/api_gateway/operations/label_bulk_create_params.py index 61bbc4f0297..38044fe7423 100644 --- a/src/cloudflare/types/api_gateway/operations/label_bulk_create_params.py +++ b/src/cloudflare/types/api_gateway/operations/label_bulk_create_params.py @@ -10,7 +10,7 @@ class LabelBulkCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" selector: Required[Selector] diff --git a/src/cloudflare/types/api_gateway/operations/label_bulk_update_params.py b/src/cloudflare/types/api_gateway/operations/label_bulk_update_params.py index e4285241137..9c1f8a13085 100644 --- a/src/cloudflare/types/api_gateway/operations/label_bulk_update_params.py +++ b/src/cloudflare/types/api_gateway/operations/label_bulk_update_params.py @@ -10,7 +10,7 @@ class LabelBulkUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" managed: Required[Managed] diff --git a/src/cloudflare/types/api_gateway/operations/label_create_params.py b/src/cloudflare/types/api_gateway/operations/label_create_params.py index 686ce141486..232aabb3f0e 100644 --- a/src/cloudflare/types/api_gateway/operations/label_create_params.py +++ b/src/cloudflare/types/api_gateway/operations/label_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ...._types import SequenceNotStr @@ -10,7 +10,7 @@ class LabelCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" managed: SequenceNotStr[str] diff --git a/src/cloudflare/types/api_gateway/operations/label_update_params.py b/src/cloudflare/types/api_gateway/operations/label_update_params.py index a50108369a7..bedd3d0c7bc 100644 --- a/src/cloudflare/types/api_gateway/operations/label_update_params.py +++ b/src/cloudflare/types/api_gateway/operations/label_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ...._types import SequenceNotStr @@ -10,7 +10,7 @@ class LabelUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" managed: SequenceNotStr[str] diff --git a/src/cloudflare/types/api_gateway/operations/schema_validation_edit_params.py b/src/cloudflare/types/api_gateway/operations/schema_validation_edit_params.py index ac49e74f27c..c1de924961d 100644 --- a/src/cloudflare/types/api_gateway/operations/schema_validation_edit_params.py +++ b/src/cloudflare/types/api_gateway/operations/schema_validation_edit_params.py @@ -10,7 +10,7 @@ class SchemaValidationEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" settings_multiple_request: Required[SettingsMultipleRequestParam] diff --git a/src/cloudflare/types/api_gateway/operations/schema_validation_update_params.py b/src/cloudflare/types/api_gateway/operations/schema_validation_update_params.py index ce1a0354046..24045e2b141 100644 --- a/src/cloudflare/types/api_gateway/operations/schema_validation_update_params.py +++ b/src/cloudflare/types/api_gateway/operations/schema_validation_update_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["SchemaValidationUpdateParams"] class SchemaValidationUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" mitigation_action: Optional[Literal["log", "block", "none"]] diff --git a/src/cloudflare/types/api_gateway/schema_list_params.py b/src/cloudflare/types/api_gateway/schema_list_params.py index b80273584a1..412ae025937 100644 --- a/src/cloudflare/types/api_gateway/schema_list_params.py +++ b/src/cloudflare/types/api_gateway/schema_list_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -11,7 +11,7 @@ class SchemaListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] diff --git a/src/cloudflare/types/api_gateway/settings/schema_validation_edit_params.py b/src/cloudflare/types/api_gateway/settings/schema_validation_edit_params.py index 16b93fa100e..441140f8754 100644 --- a/src/cloudflare/types/api_gateway/settings/schema_validation_edit_params.py +++ b/src/cloudflare/types/api_gateway/settings/schema_validation_edit_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["SchemaValidationEditParams"] class SchemaValidationEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] diff --git a/src/cloudflare/types/api_gateway/settings/schema_validation_update_params.py b/src/cloudflare/types/api_gateway/settings/schema_validation_update_params.py index f77dd31637e..900abf9c95d 100644 --- a/src/cloudflare/types/api_gateway/settings/schema_validation_update_params.py +++ b/src/cloudflare/types/api_gateway/settings/schema_validation_update_params.py @@ -9,7 +9,7 @@ class SchemaValidationUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" validation_default_mitigation_action: Required[Literal["none", "log", "block"]] diff --git a/src/cloudflare/types/api_gateway/user_schema_create_params.py b/src/cloudflare/types/api_gateway/user_schema_create_params.py index 12dcf783e18..7fbbad14fd6 100644 --- a/src/cloudflare/types/api_gateway/user_schema_create_params.py +++ b/src/cloudflare/types/api_gateway/user_schema_create_params.py @@ -10,7 +10,7 @@ class UserSchemaCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" file: Required[FileTypes] diff --git a/src/cloudflare/types/api_gateway/user_schema_edit_params.py b/src/cloudflare/types/api_gateway/user_schema_edit_params.py index 085ba5a2fbf..35348f35000 100644 --- a/src/cloudflare/types/api_gateway/user_schema_edit_params.py +++ b/src/cloudflare/types/api_gateway/user_schema_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["UserSchemaEditParams"] class UserSchemaEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" validation_enabled: Literal[True] diff --git a/src/cloudflare/types/api_gateway/user_schema_get_params.py b/src/cloudflare/types/api_gateway/user_schema_get_params.py index 3fa24a59bce..ff04f2df466 100644 --- a/src/cloudflare/types/api_gateway/user_schema_get_params.py +++ b/src/cloudflare/types/api_gateway/user_schema_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["UserSchemaGetParams"] class UserSchemaGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" omit_source: bool diff --git a/src/cloudflare/types/api_gateway/user_schema_list_params.py b/src/cloudflare/types/api_gateway/user_schema_list_params.py index 4cb1bdbbcca..811922bb4ff 100644 --- a/src/cloudflare/types/api_gateway/user_schema_list_params.py +++ b/src/cloudflare/types/api_gateway/user_schema_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["UserSchemaListParams"] class UserSchemaListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" omit_source: bool diff --git a/src/cloudflare/types/api_gateway/user_schemas/host_list_params.py b/src/cloudflare/types/api_gateway/user_schemas/host_list_params.py index 5865ee0d036..f7106c44c4b 100644 --- a/src/cloudflare/types/api_gateway/user_schemas/host_list_params.py +++ b/src/cloudflare/types/api_gateway/user_schemas/host_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HostListParams"] class HostListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py b/src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py index 25cd71a53c6..e93c03d6f32 100644 --- a/src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py +++ b/src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ...._types import SequenceNotStr @@ -11,7 +11,7 @@ class OperationListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" endpoint: str diff --git a/src/cloudflare/types/argo/smart_routing_edit_params.py b/src/cloudflare/types/argo/smart_routing_edit_params.py index 6a0817f9c6a..9f4b6ebd4b2 100644 --- a/src/cloudflare/types/argo/smart_routing_edit_params.py +++ b/src/cloudflare/types/argo/smart_routing_edit_params.py @@ -8,7 +8,7 @@ class SmartRoutingEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Specifies the zone associated with the API call.""" value: Required[Literal["on", "off"]] diff --git a/src/cloudflare/types/argo/tiered_caching_edit_params.py b/src/cloudflare/types/argo/tiered_caching_edit_params.py index 1a1702873c2..e4391bb57a3 100644 --- a/src/cloudflare/types/argo/tiered_caching_edit_params.py +++ b/src/cloudflare/types/argo/tiered_caching_edit_params.py @@ -8,7 +8,7 @@ class TieredCachingEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" value: Required[Literal["on", "off"]] diff --git a/src/cloudflare/types/audit_logs/audit_log_list_params.py b/src/cloudflare/types/audit_logs/audit_log_list_params.py index 5b43966e45b..195fb62b337 100644 --- a/src/cloudflare/types/audit_logs/audit_log_list_params.py +++ b/src/cloudflare/types/audit_logs/audit_log_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import date, datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class AuditLogListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" id: str diff --git a/src/cloudflare/types/billing/usage_paygo_params.py b/src/cloudflare/types/billing/usage_paygo_params.py index 29409e92fd2..bafa06302bf 100644 --- a/src/cloudflare/types/billing/usage_paygo_params.py +++ b/src/cloudflare/types/billing/usage_paygo_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import date -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class UsagePaygoParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Represents a Cloudflare resource identifier tag.""" from_: Annotated[Union[str, date], PropertyInfo(alias="from", format="iso8601")] diff --git a/src/cloudflare/types/bot_management/bot_management_update_params.py b/src/cloudflare/types/bot_management/bot_management_update_params.py index eeaf0a45fc3..46a688eabad 100644 --- a/src/cloudflare/types/bot_management/bot_management_update_params.py +++ b/src/cloudflare/types/bot_management/bot_management_update_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Union -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Literal, TypeAlias, TypedDict __all__ = [ "BotManagementUpdateParams", @@ -15,7 +15,7 @@ class BotFightModeConfiguration(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] @@ -49,7 +49,7 @@ class BotFightModeConfiguration(TypedDict, total=False): class SuperBotFightModeDefinitelyConfiguration(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] @@ -96,7 +96,7 @@ class SuperBotFightModeDefinitelyConfiguration(TypedDict, total=False): class SuperBotFightModeLikelyConfiguration(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] @@ -146,7 +146,7 @@ class SuperBotFightModeLikelyConfiguration(TypedDict, total=False): class SubscriptionConfiguration(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] diff --git a/src/cloudflare/types/botnet_feed/asn_day_report_params.py b/src/cloudflare/types/botnet_feed/asn_day_report_params.py index 516f4c6d977..c946f360b0f 100755 --- a/src/cloudflare/types/botnet_feed/asn_day_report_params.py +++ b/src/cloudflare/types/botnet_feed/asn_day_report_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class ASNDayReportParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" date: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/brand_protection/logo_create_params.py b/src/cloudflare/types/brand_protection/logo_create_params.py index 2fd40da7f6b..708aff0f04a 100644 --- a/src/cloudflare/types/brand_protection/logo_create_params.py +++ b/src/cloudflare/types/brand_protection/logo_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import FileTypes @@ -10,7 +10,7 @@ class LogoCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str match_type: str diff --git a/src/cloudflare/types/brand_protection/logo_match_download_params.py b/src/cloudflare/types/brand_protection/logo_match_download_params.py index 7d69d0c35a3..ae3bb689b88 100644 --- a/src/cloudflare/types/brand_protection/logo_match_download_params.py +++ b/src/cloudflare/types/brand_protection/logo_match_download_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class LogoMatchDownloadParams(TypedDict, total=False): - account_id: Required[str] + account_id: str limit: str diff --git a/src/cloudflare/types/brand_protection/logo_match_get_params.py b/src/cloudflare/types/brand_protection/logo_match_get_params.py index 19bc5dd4f9b..508069acb3d 100644 --- a/src/cloudflare/types/brand_protection/logo_match_get_params.py +++ b/src/cloudflare/types/brand_protection/logo_match_get_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class LogoMatchGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str limit: str diff --git a/src/cloudflare/types/brand_protection/match_download_params.py b/src/cloudflare/types/brand_protection/match_download_params.py index c9c1474e874..935ea8bf044 100644 --- a/src/cloudflare/types/brand_protection/match_download_params.py +++ b/src/cloudflare/types/brand_protection/match_download_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["MatchDownloadParams"] class MatchDownloadParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: str diff --git a/src/cloudflare/types/brand_protection/match_get_params.py b/src/cloudflare/types/brand_protection/match_get_params.py index e328903a3ec..a581f9f110d 100644 --- a/src/cloudflare/types/brand_protection/match_get_params.py +++ b/src/cloudflare/types/brand_protection/match_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["MatchGetParams"] class MatchGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: str diff --git a/src/cloudflare/types/brand_protection/query_bulk_params.py b/src/cloudflare/types/brand_protection/query_bulk_params.py index 6d03a6801e1..9b80658d45e 100644 --- a/src/cloudflare/types/brand_protection/query_bulk_params.py +++ b/src/cloudflare/types/brand_protection/query_bulk_params.py @@ -3,12 +3,12 @@ from __future__ import annotations from typing import Dict, Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["QueryBulkParams"] class QueryBulkParams(TypedDict, total=False): - account_id: Required[str] + account_id: str queries: Iterable[Dict[str, object]] diff --git a/src/cloudflare/types/brand_protection/query_create_params.py b/src/cloudflare/types/brand_protection/query_create_params.py index 543c7bbbc71..f9dbc95be5b 100644 --- a/src/cloudflare/types/brand_protection/query_create_params.py +++ b/src/cloudflare/types/brand_protection/query_create_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class QueryCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: str diff --git a/src/cloudflare/types/brand_protection/query_delete_params.py b/src/cloudflare/types/brand_protection/query_delete_params.py index d4a095e924d..3ae73979ca0 100644 --- a/src/cloudflare/types/brand_protection/query_delete_params.py +++ b/src/cloudflare/types/brand_protection/query_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["QueryDeleteParams"] class QueryDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: str diff --git a/src/cloudflare/types/brand_protection/v2/logo_create_params.py b/src/cloudflare/types/brand_protection/v2/logo_create_params.py index ad48572ac3c..89aa53e2176 100644 --- a/src/cloudflare/types/brand_protection/v2/logo_create_params.py +++ b/src/cloudflare/types/brand_protection/v2/logo_create_params.py @@ -8,7 +8,7 @@ class LogoCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str image_data: Required[str] """Base64 encoded image data. diff --git a/src/cloudflare/types/brand_protection/v2/logo_get_params.py b/src/cloudflare/types/brand_protection/v2/logo_get_params.py index dc4293d9ca2..ecfbb9d9243 100644 --- a/src/cloudflare/types/brand_protection/v2/logo_get_params.py +++ b/src/cloudflare/types/brand_protection/v2/logo_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["LogoGetParams"] class LogoGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: str """Optional query ID to retrieve a specific logo query""" diff --git a/src/cloudflare/types/brand_protection/v2/logo_match_get_params.py b/src/cloudflare/types/brand_protection/v2/logo_match_get_params.py index 458551d3c18..a076bf76ca5 100644 --- a/src/cloudflare/types/brand_protection/v2/logo_match_get_params.py +++ b/src/cloudflare/types/brand_protection/v2/logo_match_get_params.py @@ -10,7 +10,7 @@ class LogoMatchGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str query_id: Required[str] diff --git a/src/cloudflare/types/brand_protection/v2/match_get_params.py b/src/cloudflare/types/brand_protection/v2/match_get_params.py index 9cffb97f539..1d4b394a83a 100644 --- a/src/cloudflare/types/brand_protection/v2/match_get_params.py +++ b/src/cloudflare/types/brand_protection/v2/match_get_params.py @@ -11,7 +11,7 @@ class MatchGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str query_id: Required[SequenceNotStr[str]] """Query ID or comma-separated list of Query IDs. diff --git a/src/cloudflare/types/brand_protection/v2/query_get_params.py b/src/cloudflare/types/brand_protection/v2/query_get_params.py index 9393cb8fb5d..e3b1a764181 100644 --- a/src/cloudflare/types/brand_protection/v2/query_get_params.py +++ b/src/cloudflare/types/brand_protection/v2/query_get_params.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["QueryGetParams"] class QueryGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: str diff --git a/src/cloudflare/types/browser_rendering/content_create_params.py b/src/cloudflare/types/browser_rendering/content_create_params.py index 81af5dbbcc2..7926cdde58a 100644 --- a/src/cloudflare/types/browser_rendering/content_create_params.py +++ b/src/cloudflare/types/browser_rendering/content_create_params.py @@ -30,7 +30,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: Required[str] @@ -262,7 +262,7 @@ class Variant0WaitForSelector(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" html: Required[str] diff --git a/src/cloudflare/types/browser_rendering/crawl_create_params.py b/src/cloudflare/types/browser_rendering/crawl_create_params.py index 938f0950b07..94fe0db30c6 100644 --- a/src/cloudflare/types/browser_rendering/crawl_create_params.py +++ b/src/cloudflare/types/browser_rendering/crawl_create_params.py @@ -31,7 +31,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: Required[str] @@ -380,7 +380,7 @@ class Variant0WaitForSelector(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" render: Required[Literal[False]] diff --git a/src/cloudflare/types/browser_rendering/crawl_get_params.py b/src/cloudflare/types/browser_rendering/crawl_get_params.py index eca4af2fddb..3d8e50e9026 100644 --- a/src/cloudflare/types/browser_rendering/crawl_get_params.py +++ b/src/cloudflare/types/browser_rendering/crawl_get_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -10,7 +10,7 @@ class CrawlGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" cache_ttl: Annotated[float, PropertyInfo(alias="cacheTTL")] diff --git a/src/cloudflare/types/browser_rendering/devtools/browser/target_create_params.py b/src/cloudflare/types/browser_rendering/devtools/browser/target_create_params.py index 7a0c744f9f1..a082065dd38 100644 --- a/src/cloudflare/types/browser_rendering/devtools/browser/target_create_params.py +++ b/src/cloudflare/types/browser_rendering/devtools/browser/target_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["TargetCreateParams"] class TargetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: str diff --git a/src/cloudflare/types/browser_rendering/devtools/browser_connect_params.py b/src/cloudflare/types/browser_rendering/devtools/browser_connect_params.py index cbc89a6e0fd..86c2233a81e 100644 --- a/src/cloudflare/types/browser_rendering/devtools/browser_connect_params.py +++ b/src/cloudflare/types/browser_rendering/devtools/browser_connect_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["BrowserConnectParams"] class BrowserConnectParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" keep_alive: float diff --git a/src/cloudflare/types/browser_rendering/devtools/browser_create_params.py b/src/cloudflare/types/browser_rendering/devtools/browser_create_params.py index f46a724665c..f5d5231f117 100644 --- a/src/cloudflare/types/browser_rendering/devtools/browser_create_params.py +++ b/src/cloudflare/types/browser_rendering/devtools/browser_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["BrowserCreateParams"] class BrowserCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" keep_alive: float diff --git a/src/cloudflare/types/browser_rendering/devtools/browser_launch_params.py b/src/cloudflare/types/browser_rendering/devtools/browser_launch_params.py index c9016c7fad9..7722caee55f 100644 --- a/src/cloudflare/types/browser_rendering/devtools/browser_launch_params.py +++ b/src/cloudflare/types/browser_rendering/devtools/browser_launch_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["BrowserLaunchParams"] class BrowserLaunchParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" keep_alive: float diff --git a/src/cloudflare/types/browser_rendering/devtools/session_list_params.py b/src/cloudflare/types/browser_rendering/devtools/session_list_params.py index 4a5795c6f28..1b281efeab4 100644 --- a/src/cloudflare/types/browser_rendering/devtools/session_list_params.py +++ b/src/cloudflare/types/browser_rendering/devtools/session_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SessionListParams"] class SessionListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" limit: float diff --git a/src/cloudflare/types/browser_rendering/json_create_params.py b/src/cloudflare/types/browser_rendering/json_create_params.py index e2cbe43fe43..0054379925e 100644 --- a/src/cloudflare/types/browser_rendering/json_create_params.py +++ b/src/cloudflare/types/browser_rendering/json_create_params.py @@ -34,7 +34,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" html: Required[str] @@ -305,7 +305,7 @@ class Variant0WaitForSelector(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: Required[str] diff --git a/src/cloudflare/types/browser_rendering/link_create_params.py b/src/cloudflare/types/browser_rendering/link_create_params.py index 1b0794aa544..8c1baf9b55c 100644 --- a/src/cloudflare/types/browser_rendering/link_create_params.py +++ b/src/cloudflare/types/browser_rendering/link_create_params.py @@ -30,7 +30,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" html: Required[str] @@ -269,7 +269,7 @@ class Variant0WaitForSelector(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: Required[str] diff --git a/src/cloudflare/types/browser_rendering/markdown_create_params.py b/src/cloudflare/types/browser_rendering/markdown_create_params.py index 132af3610a9..d3fee07ee90 100644 --- a/src/cloudflare/types/browser_rendering/markdown_create_params.py +++ b/src/cloudflare/types/browser_rendering/markdown_create_params.py @@ -30,7 +30,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: Required[str] @@ -262,7 +262,7 @@ class Variant0WaitForSelector(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" html: Required[str] diff --git a/src/cloudflare/types/browser_rendering/pdf_create_params.py b/src/cloudflare/types/browser_rendering/pdf_create_params.py index 7800a94fce7..205e5f547aa 100644 --- a/src/cloudflare/types/browser_rendering/pdf_create_params.py +++ b/src/cloudflare/types/browser_rendering/pdf_create_params.py @@ -34,7 +34,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" html: Required[str] @@ -336,7 +336,7 @@ class Variant0WaitForSelector(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: Required[str] diff --git a/src/cloudflare/types/browser_rendering/scrape_create_params.py b/src/cloudflare/types/browser_rendering/scrape_create_params.py index 118be807a0d..2b493d2fa2c 100644 --- a/src/cloudflare/types/browser_rendering/scrape_create_params.py +++ b/src/cloudflare/types/browser_rendering/scrape_create_params.py @@ -32,7 +32,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" elements: Required[Iterable[Variant0Element]] @@ -273,7 +273,7 @@ class Variant0WaitForSelector(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" elements: Required[Iterable[Variant1Element]] diff --git a/src/cloudflare/types/browser_rendering/screenshot_create_params.py b/src/cloudflare/types/browser_rendering/screenshot_create_params.py index b49d1a32a09..6a4b43a9ae7 100644 --- a/src/cloudflare/types/browser_rendering/screenshot_create_params.py +++ b/src/cloudflare/types/browser_rendering/screenshot_create_params.py @@ -34,7 +34,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" html: Required[str] @@ -310,7 +310,7 @@ class Variant0WaitForSelector(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: Required[str] diff --git a/src/cloudflare/types/browser_rendering/snapshot_create_params.py b/src/cloudflare/types/browser_rendering/snapshot_create_params.py index f9d887a1a98..c392ec2ac9a 100644 --- a/src/cloudflare/types/browser_rendering/snapshot_create_params.py +++ b/src/cloudflare/types/browser_rendering/snapshot_create_params.py @@ -34,7 +34,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" html: Required[str] @@ -301,7 +301,7 @@ class Variant0WaitForSelector(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: Required[str] diff --git a/src/cloudflare/types/cache/cache_purge_params.py b/src/cloudflare/types/cache/cache_purge_params.py index 800757500ba..da77007894d 100644 --- a/src/cloudflare/types/cache/cache_purge_params.py +++ b/src/cloudflare/types/cache/cache_purge_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Union, Iterable -from typing_extensions import Required, TypeAlias, TypedDict +from typing_extensions import TypeAlias, TypedDict from ..._types import SequenceNotStr @@ -20,7 +20,7 @@ class CachePurgeFlexPurgeByTags(TypedDict, total=False): - zone_id: Required[str] + zone_id: str tags: SequenceNotStr[str] """ @@ -30,7 +30,7 @@ class CachePurgeFlexPurgeByTags(TypedDict, total=False): class CachePurgeFlexPurgeByHostnames(TypedDict, total=False): - zone_id: Required[str] + zone_id: str hosts: SequenceNotStr[str] """ @@ -40,7 +40,7 @@ class CachePurgeFlexPurgeByHostnames(TypedDict, total=False): class CachePurgeFlexPurgeByPrefixes(TypedDict, total=False): - zone_id: Required[str] + zone_id: str prefixes: SequenceNotStr[str] """ @@ -50,7 +50,7 @@ class CachePurgeFlexPurgeByPrefixes(TypedDict, total=False): class CachePurgeEverything(TypedDict, total=False): - zone_id: Required[str] + zone_id: str purge_everything: bool """ @@ -60,7 +60,7 @@ class CachePurgeEverything(TypedDict, total=False): class CachePurgeSingleFile(TypedDict, total=False): - zone_id: Required[str] + zone_id: str files: SequenceNotStr[str] """ @@ -70,7 +70,7 @@ class CachePurgeSingleFile(TypedDict, total=False): class CachePurgeSingleFileWithURLAndHeaders(TypedDict, total=False): - zone_id: Required[str] + zone_id: str files: Iterable[CachePurgeSingleFileWithURLAndHeadersFile] """ diff --git a/src/cloudflare/types/cache/cache_reserve_clear_params.py b/src/cloudflare/types/cache/cache_reserve_clear_params.py index e549d5f3eca..2d95edc9094 100644 --- a/src/cloudflare/types/cache/cache_reserve_clear_params.py +++ b/src/cloudflare/types/cache/cache_reserve_clear_params.py @@ -8,7 +8,7 @@ class CacheReserveClearParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[object] diff --git a/src/cloudflare/types/cache/cache_reserve_edit_params.py b/src/cloudflare/types/cache/cache_reserve_edit_params.py index 5565b6cf2e9..9a69860a520 100644 --- a/src/cloudflare/types/cache/cache_reserve_edit_params.py +++ b/src/cloudflare/types/cache/cache_reserve_edit_params.py @@ -8,7 +8,7 @@ class CacheReserveEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" value: Required[Literal["on", "off"]] diff --git a/src/cloudflare/types/cache/regional_tiered_cache_edit_params.py b/src/cloudflare/types/cache/regional_tiered_cache_edit_params.py index f5d8b1ea299..c24302ef9f8 100644 --- a/src/cloudflare/types/cache/regional_tiered_cache_edit_params.py +++ b/src/cloudflare/types/cache/regional_tiered_cache_edit_params.py @@ -8,7 +8,7 @@ class RegionalTieredCacheEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" value: Required[Literal["on", "off"]] diff --git a/src/cloudflare/types/cache/smart_tiered_cache_edit_params.py b/src/cloudflare/types/cache/smart_tiered_cache_edit_params.py index fccba724a30..8a1b9dfaf69 100644 --- a/src/cloudflare/types/cache/smart_tiered_cache_edit_params.py +++ b/src/cloudflare/types/cache/smart_tiered_cache_edit_params.py @@ -8,7 +8,7 @@ class SmartTieredCacheEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" value: Required[Literal["on", "off"]] diff --git a/src/cloudflare/types/cache/variant_edit_params.py b/src/cloudflare/types/cache/variant_edit_params.py index d7b12d1a7a7..20e4a8e5325 100644 --- a/src/cloudflare/types/cache/variant_edit_params.py +++ b/src/cloudflare/types/cache/variant_edit_params.py @@ -10,7 +10,7 @@ class VariantEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" value: Required[Value] diff --git a/src/cloudflare/types/calls/sfu_create_params.py b/src/cloudflare/types/calls/sfu_create_params.py index 701904d9621..b9c0508b32e 100644 --- a/src/cloudflare/types/calls/sfu_create_params.py +++ b/src/cloudflare/types/calls/sfu_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SFUCreateParams"] class SFUCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" name: str diff --git a/src/cloudflare/types/calls/sfu_update_params.py b/src/cloudflare/types/calls/sfu_update_params.py index a6c9750c222..29c26ae021d 100644 --- a/src/cloudflare/types/calls/sfu_update_params.py +++ b/src/cloudflare/types/calls/sfu_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SFUUpdateParams"] class SFUUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" name: str diff --git a/src/cloudflare/types/calls/turn_create_params.py b/src/cloudflare/types/calls/turn_create_params.py index c81ae39b420..8c3b541b948 100644 --- a/src/cloudflare/types/calls/turn_create_params.py +++ b/src/cloudflare/types/calls/turn_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["TURNCreateParams"] class TURNCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" name: str diff --git a/src/cloudflare/types/calls/turn_update_params.py b/src/cloudflare/types/calls/turn_update_params.py index 98e663a8388..2e6ae6a76db 100644 --- a/src/cloudflare/types/calls/turn_update_params.py +++ b/src/cloudflare/types/calls/turn_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["TURNUpdateParams"] class TURNUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" name: str diff --git a/src/cloudflare/types/certificate_authorities/hostname_association_get_params.py b/src/cloudflare/types/certificate_authorities/hostname_association_get_params.py index f0383af9e5f..917f4db74c5 100644 --- a/src/cloudflare/types/certificate_authorities/hostname_association_get_params.py +++ b/src/cloudflare/types/certificate_authorities/hostname_association_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HostnameAssociationGetParams"] class HostnameAssociationGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" mtls_certificate_id: str diff --git a/src/cloudflare/types/certificate_authorities/hostname_association_update_params.py b/src/cloudflare/types/certificate_authorities/hostname_association_update_params.py index b0c621712c6..7bc8a445b96 100644 --- a/src/cloudflare/types/certificate_authorities/hostname_association_update_params.py +++ b/src/cloudflare/types/certificate_authorities/hostname_association_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr from .hostname_association import HostnameAssociation @@ -11,7 +11,7 @@ class HostnameAssociationUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" hostnames: SequenceNotStr[HostnameAssociation] diff --git a/src/cloudflare/types/client_certificates/client_certificate_create_params.py b/src/cloudflare/types/client_certificates/client_certificate_create_params.py index b2c10107501..50fec6feeea 100644 --- a/src/cloudflare/types/client_certificates/client_certificate_create_params.py +++ b/src/cloudflare/types/client_certificates/client_certificate_create_params.py @@ -8,7 +8,7 @@ class ClientCertificateCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" csr: Required[str] diff --git a/src/cloudflare/types/client_certificates/client_certificate_edit_params.py b/src/cloudflare/types/client_certificates/client_certificate_edit_params.py index 91c3632b733..8e853e80ee2 100644 --- a/src/cloudflare/types/client_certificates/client_certificate_edit_params.py +++ b/src/cloudflare/types/client_certificates/client_certificate_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ClientCertificateEditParams"] class ClientCertificateEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" reactivate: bool diff --git a/src/cloudflare/types/client_certificates/client_certificate_list_params.py b/src/cloudflare/types/client_certificates/client_certificate_list_params.py index 10dc96904dc..572cf7549f2 100644 --- a/src/cloudflare/types/client_certificates/client_certificate_list_params.py +++ b/src/cloudflare/types/client_certificates/client_certificate_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ClientCertificateListParams"] class ClientCertificateListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" limit: int diff --git a/src/cloudflare/types/cloud_connector/rule_update_params.py b/src/cloudflare/types/cloud_connector/rule_update_params.py index 29a4207e16b..eafafebd702 100644 --- a/src/cloudflare/types/cloud_connector/rule_update_params.py +++ b/src/cloudflare/types/cloud_connector/rule_update_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["RuleUpdateParams", "Rule", "RuleParameters"] class RuleUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" rules: Iterable[Rule] diff --git a/src/cloudflare/types/cloudforce_one/binary_storage_create_params.py b/src/cloudflare/types/cloudforce_one/binary_storage_create_params.py index ff8d1882de7..a0152eae6e6 100644 --- a/src/cloudflare/types/cloudforce_one/binary_storage_create_params.py +++ b/src/cloudflare/types/cloudforce_one/binary_storage_create_params.py @@ -10,7 +10,7 @@ class BinaryStorageCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" file: Required[FileTypes] diff --git a/src/cloudflare/types/cloudforce_one/request_create_params.py b/src/cloudflare/types/cloudforce_one/request_create_params.py index e145b6b4e5f..de41b6dfe9f 100644 --- a/src/cloudflare/types/cloudforce_one/request_create_params.py +++ b/src/cloudflare/types/cloudforce_one/request_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["RequestCreateParams"] class RequestCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" content: str diff --git a/src/cloudflare/types/cloudforce_one/request_list_params.py b/src/cloudflare/types/cloudforce_one/request_list_params.py index 385f0dc0d77..b017421c509 100644 --- a/src/cloudflare/types/cloudforce_one/request_list_params.py +++ b/src/cloudflare/types/cloudforce_one/request_list_params.py @@ -12,7 +12,7 @@ class RequestListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: Required[int] diff --git a/src/cloudflare/types/cloudforce_one/request_update_params.py b/src/cloudflare/types/cloudforce_one/request_update_params.py index ac96d7fb0ca..c17b7af762f 100644 --- a/src/cloudflare/types/cloudforce_one/request_update_params.py +++ b/src/cloudflare/types/cloudforce_one/request_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["RequestUpdateParams"] class RequestUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" content: str diff --git a/src/cloudflare/types/cloudforce_one/requests/asset_create_params.py b/src/cloudflare/types/cloudforce_one/requests/asset_create_params.py index 23f5455f55c..0c061155ff5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/asset_create_params.py +++ b/src/cloudflare/types/cloudforce_one/requests/asset_create_params.py @@ -8,7 +8,7 @@ class AssetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: Required[int] diff --git a/src/cloudflare/types/cloudforce_one/requests/asset_update_params.py b/src/cloudflare/types/cloudforce_one/requests/asset_update_params.py index edde12c4a66..6e8177d942c 100644 --- a/src/cloudflare/types/cloudforce_one/requests/asset_update_params.py +++ b/src/cloudflare/types/cloudforce_one/requests/asset_update_params.py @@ -8,7 +8,7 @@ class AssetUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" request_id: Required[str] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_create_params.py b/src/cloudflare/types/cloudforce_one/requests/message_create_params.py index eed1082151a..8033107ce0c 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_create_params.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["MessageCreateParams"] class MessageCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" content: str diff --git a/src/cloudflare/types/cloudforce_one/requests/message_get_params.py b/src/cloudflare/types/cloudforce_one/requests/message_get_params.py index f8a73ef040c..cbfd2ca6838 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_get_params.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_get_params.py @@ -12,7 +12,7 @@ class MessageGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: Required[int] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_update_params.py b/src/cloudflare/types/cloudforce_one/requests/message_update_params.py index c832ce22237..e71c470d05e 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_update_params.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_update_params.py @@ -8,7 +8,7 @@ class MessageUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" request_id: Required[str] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_create_params.py b/src/cloudflare/types/cloudforce_one/requests/priority_create_params.py index 58a30eaf6d7..e891d3ea8b5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_create_params.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_create_params.py @@ -11,7 +11,7 @@ class PriorityCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" labels: Required[SequenceNotStr[Label]] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_update_params.py b/src/cloudflare/types/cloudforce_one/requests/priority_update_params.py index 27a0b98135a..7501b09431d 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_update_params.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_update_params.py @@ -11,7 +11,7 @@ class PriorityUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" labels: Required[SequenceNotStr[Label]] diff --git a/src/cloudflare/types/cloudforce_one/scans/config_create_params.py b/src/cloudflare/types/cloudforce_one/scans/config_create_params.py index f974a52f24e..9e37cab73da 100644 --- a/src/cloudflare/types/cloudforce_one/scans/config_create_params.py +++ b/src/cloudflare/types/cloudforce_one/scans/config_create_params.py @@ -10,7 +10,7 @@ class ConfigCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Defines the Account ID.""" ips: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/cloudforce_one/scans/config_edit_params.py b/src/cloudflare/types/cloudforce_one/scans/config_edit_params.py index 57ced5e57e8..21ab1f46707 100644 --- a/src/cloudflare/types/cloudforce_one/scans/config_edit_params.py +++ b/src/cloudflare/types/cloudforce_one/scans/config_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ...._types import SequenceNotStr @@ -10,7 +10,7 @@ class ConfigEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Defines the Account ID.""" frequency: float diff --git a/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_params.py b/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_params.py index 772769f2651..eae89e43b42 100644 --- a/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_params.py @@ -13,7 +13,7 @@ class ThreatEventBulkCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" data: Required[Iterable[Data]] diff --git a/src/cloudflare/types/cloudforce_one/threat_event_create_params.py b/src/cloudflare/types/cloudforce_one/threat_event_create_params.py index 8a06c593aee..5ceb622bd2e 100644 --- a/src/cloudflare/types/cloudforce_one/threat_event_create_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_event_create_params.py @@ -13,7 +13,7 @@ class ThreatEventCreateParams(TypedDict, total=False): - path_account_id: Required[Annotated[str, PropertyInfo(alias="account_id")]] + path_account_id: Annotated[str, PropertyInfo(alias="account_id")] """Account ID.""" category: Required[str] diff --git a/src/cloudflare/types/cloudforce_one/threat_event_edit_params.py b/src/cloudflare/types/cloudforce_one/threat_event_edit_params.py index 7aed383f6f5..de1ad63adc9 100644 --- a/src/cloudflare/types/cloudforce_one/threat_event_edit_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_event_edit_params.py @@ -12,7 +12,7 @@ class ThreatEventEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" dataset_id: Required[Annotated[str, PropertyInfo(alias="datasetId")]] diff --git a/src/cloudflare/types/cloudforce_one/threat_event_list_params.py b/src/cloudflare/types/cloudforce_one/threat_event_list_params.py index 4b602ab804b..a5fbc858698 100644 --- a/src/cloudflare/types/cloudforce_one/threat_event_list_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_event_list_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class ThreatEventListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" cursor: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/attacker_list_params.py b/src/cloudflare/types/cloudforce_one/threat_events/attacker_list_params.py index e0d50581e80..5d810b0f3f8 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/attacker_list_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/attacker_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -11,7 +11,7 @@ class AttackerListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" dataset_ids: Annotated[SequenceNotStr[str], PropertyInfo(alias="datasetIds")] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_create_params.py b/src/cloudflare/types/cloudforce_one/threat_events/category_create_params.py index 6c8699bb75c..5662b5cb70c 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/category_create_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_create_params.py @@ -11,7 +11,7 @@ class CategoryCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" kill_chain: Required[Annotated[float, PropertyInfo(alias="killChain")]] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_edit_params.py b/src/cloudflare/types/cloudforce_one/threat_events/category_edit_params.py index bdf4a4f3de4..a62fc42c6e9 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/category_edit_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -11,7 +11,7 @@ class CategoryEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" kill_chain: Annotated[float, PropertyInfo(alias="killChain")] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_list_params.py b/src/cloudflare/types/cloudforce_one/threat_events/category_list_params.py index fa43c1a4b41..f88052373f2 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/category_list_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -11,7 +11,7 @@ class CategoryListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" dataset_ids: Annotated[SequenceNotStr[str], PropertyInfo(alias="datasetIds")] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_params.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_params.py index dfeaa66e4c5..81be710172b 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_params.py @@ -10,7 +10,7 @@ class DatasetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" is_public: Required[Annotated[bool, PropertyInfo(alias="isPublic")]] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_params.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_params.py index 105e8e30834..f2c5d8dfe5c 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_params.py @@ -10,7 +10,7 @@ class DatasetEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" is_public: Required[Annotated[bool, PropertyInfo(alias="isPublic")]] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/event_tag_create_params.py b/src/cloudflare/types/cloudforce_one/threat_events/event_tag_create_params.py index 8a28221ab3e..1eb31d9c1f5 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/event_tag_create_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/event_tag_create_params.py @@ -10,7 +10,7 @@ class EventTagCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" tags: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_params.py b/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_params.py index c1a14dd1a1a..55594177450 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_params.py @@ -8,7 +8,7 @@ class RawEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" event_id: Required[str] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/tag_create_params.py b/src/cloudflare/types/cloudforce_one/threat_events/tag_create_params.py index 85452744e19..996feef9203 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/tag_create_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/tag_create_params.py @@ -11,7 +11,7 @@ class TagCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" value: Required[str] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/target_industry_list_params.py b/src/cloudflare/types/cloudforce_one/threat_events/target_industry_list_params.py index 2fde8d89e9a..71ff9323b0b 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/target_industry_list_params.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/target_industry_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -11,7 +11,7 @@ class TargetIndustryListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" dataset_ids: Annotated[SequenceNotStr[str], PropertyInfo(alias="datasetIds")] diff --git a/src/cloudflare/types/connectivity/directory/service_create_params.py b/src/cloudflare/types/connectivity/directory/service_create_params.py index ec11d783cc7..95569979c1e 100644 --- a/src/cloudflare/types/connectivity/directory/service_create_params.py +++ b/src/cloudflare/types/connectivity/directory/service_create_params.py @@ -35,7 +35,7 @@ class InfraHTTPServiceConfig(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" host: Required[InfraHTTPServiceConfigHost] @@ -123,7 +123,7 @@ class InfraHTTPServiceConfigTLSSettings(TypedDict, total=False): class InfraTCPServiceConfig(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" host: Required[InfraTCPServiceConfigHost] diff --git a/src/cloudflare/types/connectivity/directory/service_list_params.py b/src/cloudflare/types/connectivity/directory/service_list_params.py index 1be439eda3f..46869aba6ec 100644 --- a/src/cloudflare/types/connectivity/directory/service_list_params.py +++ b/src/cloudflare/types/connectivity/directory/service_list_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ServiceListParams"] class ServiceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" page: int diff --git a/src/cloudflare/types/connectivity/directory/service_update_params.py b/src/cloudflare/types/connectivity/directory/service_update_params.py index b53bbdf393e..934b4abc380 100644 --- a/src/cloudflare/types/connectivity/directory/service_update_params.py +++ b/src/cloudflare/types/connectivity/directory/service_update_params.py @@ -35,7 +35,7 @@ class InfraHTTPServiceConfig(TypedDict, total=False): - account_id: Required[str] + account_id: str host: Required[InfraHTTPServiceConfigHost] @@ -122,7 +122,7 @@ class InfraHTTPServiceConfigTLSSettings(TypedDict, total=False): class InfraTCPServiceConfig(TypedDict, total=False): - account_id: Required[str] + account_id: str host: Required[InfraTCPServiceConfigHost] diff --git a/src/cloudflare/types/content_scanning/content_scanning_create_params.py b/src/cloudflare/types/content_scanning/content_scanning_create_params.py index ddfc7e607e4..29309f0bed2 100644 --- a/src/cloudflare/types/content_scanning/content_scanning_create_params.py +++ b/src/cloudflare/types/content_scanning/content_scanning_create_params.py @@ -8,7 +8,7 @@ class ContentScanningCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" value: Required[Literal["enabled", "disabled"]] diff --git a/src/cloudflare/types/content_scanning/content_scanning_update_params.py b/src/cloudflare/types/content_scanning/content_scanning_update_params.py index 4f50aaa3e87..c228a9c9af7 100644 --- a/src/cloudflare/types/content_scanning/content_scanning_update_params.py +++ b/src/cloudflare/types/content_scanning/content_scanning_update_params.py @@ -8,7 +8,7 @@ class ContentScanningUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" value: Required[Literal["enabled", "disabled"]] diff --git a/src/cloudflare/types/content_scanning/payload_create_params.py b/src/cloudflare/types/content_scanning/payload_create_params.py index d4cc40f8d10..b3d41ef63fa 100644 --- a/src/cloudflare/types/content_scanning/payload_create_params.py +++ b/src/cloudflare/types/content_scanning/payload_create_params.py @@ -9,7 +9,7 @@ class PayloadCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/custom_certificates/custom_certificate_create_params.py b/src/cloudflare/types/custom_certificates/custom_certificate_create_params.py index d63b4653aa7..76c2615f3de 100644 --- a/src/cloudflare/types/custom_certificates/custom_certificate_create_params.py +++ b/src/cloudflare/types/custom_certificates/custom_certificate_create_params.py @@ -11,7 +11,7 @@ class CustomCertificateCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" certificate: Required[str] diff --git a/src/cloudflare/types/custom_certificates/custom_certificate_edit_params.py b/src/cloudflare/types/custom_certificates/custom_certificate_edit_params.py index c9bfbfc785e..96101cb151c 100644 --- a/src/cloudflare/types/custom_certificates/custom_certificate_edit_params.py +++ b/src/cloudflare/types/custom_certificates/custom_certificate_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from .geo_restrictions_param import GeoRestrictionsParam from ..custom_hostnames.bundle_method import BundleMethod @@ -11,7 +11,7 @@ class CustomCertificateEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" bundle_method: BundleMethod diff --git a/src/cloudflare/types/custom_certificates/custom_certificate_list_params.py b/src/cloudflare/types/custom_certificates/custom_certificate_list_params.py index 20c06cc0e2f..0059ab4c732 100644 --- a/src/cloudflare/types/custom_certificates/custom_certificate_list_params.py +++ b/src/cloudflare/types/custom_certificates/custom_certificate_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["CustomCertificateListParams"] class CustomCertificateListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" match: Literal["any", "all"] diff --git a/src/cloudflare/types/custom_certificates/prioritize_update_params.py b/src/cloudflare/types/custom_certificates/prioritize_update_params.py index faae994d81c..686b50e66d7 100644 --- a/src/cloudflare/types/custom_certificates/prioritize_update_params.py +++ b/src/cloudflare/types/custom_certificates/prioritize_update_params.py @@ -9,7 +9,7 @@ class PrioritizeUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" certificates: Required[Iterable[Certificate]] diff --git a/src/cloudflare/types/custom_hostnames/certificate_pack/certificate_update_params.py b/src/cloudflare/types/custom_hostnames/certificate_pack/certificate_update_params.py index 802bf9b20ac..aecae78b244 100644 --- a/src/cloudflare/types/custom_hostnames/certificate_pack/certificate_update_params.py +++ b/src/cloudflare/types/custom_hostnames/certificate_pack/certificate_update_params.py @@ -8,7 +8,7 @@ class CertificateUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" custom_hostname_id: Required[str] diff --git a/src/cloudflare/types/custom_hostnames/custom_hostname_create_params.py b/src/cloudflare/types/custom_hostnames/custom_hostname_create_params.py index 7def1e47df9..37952d65974 100644 --- a/src/cloudflare/types/custom_hostnames/custom_hostname_create_params.py +++ b/src/cloudflare/types/custom_hostnames/custom_hostname_create_params.py @@ -15,7 +15,7 @@ class CustomHostnameCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" hostname: Required[str] diff --git a/src/cloudflare/types/custom_hostnames/custom_hostname_edit_params.py b/src/cloudflare/types/custom_hostnames/custom_hostname_edit_params.py index 9372bd89fa1..46efb43f36b 100644 --- a/src/cloudflare/types/custom_hostnames/custom_hostname_edit_params.py +++ b/src/cloudflare/types/custom_hostnames/custom_hostname_edit_params.py @@ -15,7 +15,7 @@ class CustomHostnameEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" custom_metadata: Dict[str, str] diff --git a/src/cloudflare/types/custom_hostnames/custom_hostname_list_params.py b/src/cloudflare/types/custom_hostnames/custom_hostname_list_params.py index d6dbca994e7..416f55637a7 100644 --- a/src/cloudflare/types/custom_hostnames/custom_hostname_list_params.py +++ b/src/cloudflare/types/custom_hostnames/custom_hostname_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["CustomHostnameListParams", "Hostname"] class CustomHostnameListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" id: str diff --git a/src/cloudflare/types/custom_hostnames/fallback_origin_update_params.py b/src/cloudflare/types/custom_hostnames/fallback_origin_update_params.py index d03e8bacde4..3e4992b432d 100644 --- a/src/cloudflare/types/custom_hostnames/fallback_origin_update_params.py +++ b/src/cloudflare/types/custom_hostnames/fallback_origin_update_params.py @@ -8,7 +8,7 @@ class FallbackOriginUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" origin: Required[str] diff --git a/src/cloudflare/types/custom_nameservers/custom_nameserver_create_params.py b/src/cloudflare/types/custom_nameservers/custom_nameserver_create_params.py index 52dbcf63825..f5171543549 100644 --- a/src/cloudflare/types/custom_nameservers/custom_nameserver_create_params.py +++ b/src/cloudflare/types/custom_nameservers/custom_nameserver_create_params.py @@ -8,7 +8,7 @@ class CustomNameserverCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" ns_name: Required[str] diff --git a/src/cloudflare/types/d1/database/time_travel_get_bookmark_params.py b/src/cloudflare/types/d1/database/time_travel_get_bookmark_params.py index 690290b6676..bb788f9e7f6 100644 --- a/src/cloudflare/types/d1/database/time_travel_get_bookmark_params.py +++ b/src/cloudflare/types/d1/database/time_travel_get_bookmark_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class TimeTravelGetBookmarkParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" timestamp: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/d1/database/time_travel_restore_params.py b/src/cloudflare/types/d1/database/time_travel_restore_params.py index ef86ba6d9ac..bbebd542a0b 100644 --- a/src/cloudflare/types/d1/database/time_travel_restore_params.py +++ b/src/cloudflare/types/d1/database/time_travel_restore_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class TimeTravelRestoreParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" bookmark: str diff --git a/src/cloudflare/types/d1/database_create_params.py b/src/cloudflare/types/d1/database_create_params.py index 54fc7485a7f..93d1d5fe0c4 100644 --- a/src/cloudflare/types/d1/database_create_params.py +++ b/src/cloudflare/types/d1/database_create_params.py @@ -8,7 +8,7 @@ class DatabaseCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: Required[str] diff --git a/src/cloudflare/types/d1/database_edit_params.py b/src/cloudflare/types/d1/database_edit_params.py index 4dfec27b80e..91457865c31 100644 --- a/src/cloudflare/types/d1/database_edit_params.py +++ b/src/cloudflare/types/d1/database_edit_params.py @@ -8,7 +8,7 @@ class DatabaseEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" read_replication: ReadReplication diff --git a/src/cloudflare/types/d1/database_export_params.py b/src/cloudflare/types/d1/database_export_params.py index cfe21f17154..9f63b8edb7e 100644 --- a/src/cloudflare/types/d1/database_export_params.py +++ b/src/cloudflare/types/d1/database_export_params.py @@ -10,7 +10,7 @@ class DatabaseExportParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" output_format: Required[Literal["polling"]] diff --git a/src/cloudflare/types/d1/database_import_params.py b/src/cloudflare/types/d1/database_import_params.py index 63afb92175e..644dc0e7da1 100644 --- a/src/cloudflare/types/d1/database_import_params.py +++ b/src/cloudflare/types/d1/database_import_params.py @@ -9,7 +9,7 @@ class Init(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" action: Required[Literal["init"]] @@ -24,7 +24,7 @@ class Init(TypedDict, total=False): class Ingest(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" action: Required[Literal["ingest"]] @@ -41,7 +41,7 @@ class Ingest(TypedDict, total=False): class Poll(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" action: Required[Literal["poll"]] diff --git a/src/cloudflare/types/d1/database_list_params.py b/src/cloudflare/types/d1/database_list_params.py index a3fc5dc12e9..ddaee8b9fc9 100644 --- a/src/cloudflare/types/d1/database_list_params.py +++ b/src/cloudflare/types/d1/database_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DatabaseListParams"] class DatabaseListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: str diff --git a/src/cloudflare/types/d1/database_query_params.py b/src/cloudflare/types/d1/database_query_params.py index afd658c44b2..0e3a7dfb02f 100644 --- a/src/cloudflare/types/d1/database_query_params.py +++ b/src/cloudflare/types/d1/database_query_params.py @@ -11,7 +11,7 @@ class D1SingleQuery(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" sql: Required[str] @@ -25,7 +25,7 @@ class D1SingleQuery(TypedDict, total=False): class MultipleQueries(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" batch: Required[Iterable[MultipleQueriesBatch]] diff --git a/src/cloudflare/types/d1/database_raw_params.py b/src/cloudflare/types/d1/database_raw_params.py index ee9268e9649..af9cfb57a5d 100644 --- a/src/cloudflare/types/d1/database_raw_params.py +++ b/src/cloudflare/types/d1/database_raw_params.py @@ -11,7 +11,7 @@ class D1SingleQuery(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" sql: Required[str] @@ -25,7 +25,7 @@ class D1SingleQuery(TypedDict, total=False): class MultipleQueries(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" batch: Required[Iterable[MultipleQueriesBatch]] diff --git a/src/cloudflare/types/d1/database_update_params.py b/src/cloudflare/types/d1/database_update_params.py index 24355c484a5..6759c940fa1 100644 --- a/src/cloudflare/types/d1/database_update_params.py +++ b/src/cloudflare/types/d1/database_update_params.py @@ -8,7 +8,7 @@ class DatabaseUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" read_replication: Required[ReadReplication] diff --git a/src/cloudflare/types/diagnostics/endpoint_healthcheck_create_params.py b/src/cloudflare/types/diagnostics/endpoint_healthcheck_create_params.py index f47f969bac2..d7fd6bc3c2d 100644 --- a/src/cloudflare/types/diagnostics/endpoint_healthcheck_create_params.py +++ b/src/cloudflare/types/diagnostics/endpoint_healthcheck_create_params.py @@ -8,7 +8,7 @@ class EndpointHealthcheckCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" check_type: Required[Literal["icmp"]] diff --git a/src/cloudflare/types/diagnostics/endpoint_healthcheck_update_params.py b/src/cloudflare/types/diagnostics/endpoint_healthcheck_update_params.py index 85e0b0b7077..28db1f47f90 100644 --- a/src/cloudflare/types/diagnostics/endpoint_healthcheck_update_params.py +++ b/src/cloudflare/types/diagnostics/endpoint_healthcheck_update_params.py @@ -8,7 +8,7 @@ class EndpointHealthcheckUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" check_type: Required[Literal["icmp"]] diff --git a/src/cloudflare/types/diagnostics/traceroute_create_params.py b/src/cloudflare/types/diagnostics/traceroute_create_params.py index 8e7419b2acc..abcba8459c2 100644 --- a/src/cloudflare/types/diagnostics/traceroute_create_params.py +++ b/src/cloudflare/types/diagnostics/traceroute_create_params.py @@ -10,7 +10,7 @@ class TracerouteCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" targets: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/dns/analytics/report_get_params.py b/src/cloudflare/types/dns/analytics/report_get_params.py index aba9c385ba9..70755a0c160 100644 --- a/src/cloudflare/types/dns/analytics/report_get_params.py +++ b/src/cloudflare/types/dns/analytics/report_get_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class ReportGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" dimensions: str diff --git a/src/cloudflare/types/dns/analytics/reports/bytime_get_params.py b/src/cloudflare/types/dns/analytics/reports/bytime_get_params.py index c4cd5738dea..74f2856102d 100644 --- a/src/cloudflare/types/dns/analytics/reports/bytime_get_params.py +++ b/src/cloudflare/types/dns/analytics/reports/bytime_get_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ....._utils import PropertyInfo @@ -12,7 +12,7 @@ class BytimeGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" dimensions: str diff --git a/src/cloudflare/types/dns/dnssec_edit_params.py b/src/cloudflare/types/dns/dnssec_edit_params.py index 3e8e050f7ea..e1eca51b1e8 100644 --- a/src/cloudflare/types/dns/dnssec_edit_params.py +++ b/src/cloudflare/types/dns/dnssec_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["DNSSECEditParams"] class DNSSECEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" dnssec_multi_signer: bool diff --git a/src/cloudflare/types/dns/record_batch_params.py b/src/cloudflare/types/dns/record_batch_params.py index 62fa8a549a0..72c18d9a4da 100644 --- a/src/cloudflare/types/dns/record_batch_params.py +++ b/src/cloudflare/types/dns/record_batch_params.py @@ -41,7 +41,7 @@ class RecordBatchParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" deletes: Iterable[Delete] diff --git a/src/cloudflare/types/dns/record_create_params.py b/src/cloudflare/types/dns/record_create_params.py index 9363eebfcd2..d45bb07c565 100644 --- a/src/cloudflare/types/dns/record_create_params.py +++ b/src/cloudflare/types/dns/record_create_params.py @@ -70,7 +70,7 @@ class ARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -132,7 +132,7 @@ class ARecordSettings(TypedDict, total=False): class AAAARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -194,7 +194,7 @@ class AAAARecordSettings(TypedDict, total=False): class CNAMERecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -261,7 +261,7 @@ class CNAMERecordSettings(TypedDict, total=False): class MXRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -327,7 +327,7 @@ class MXRecordSettings(TypedDict, total=False): class NSRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -386,7 +386,7 @@ class NSRecordSettings(TypedDict, total=False): class DNSRecordsOpenpgpkeyRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -445,7 +445,7 @@ class DNSRecordsOpenpgpkeyRecordSettings(TypedDict, total=False): class PTRRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -504,7 +504,7 @@ class PTRRecordSettings(TypedDict, total=False): class TXTRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -571,7 +571,7 @@ class TXTRecordSettings(TypedDict, total=False): class CAARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -643,7 +643,7 @@ class CAARecordSettings(TypedDict, total=False): class CERTRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -718,7 +718,7 @@ class CERTRecordSettings(TypedDict, total=False): class DNSKEYRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -793,7 +793,7 @@ class DNSKEYRecordSettings(TypedDict, total=False): class DSRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -868,7 +868,7 @@ class DSRecordSettings(TypedDict, total=False): class HTTPSRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -940,7 +940,7 @@ class HTTPSRecordSettings(TypedDict, total=False): class LOCRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1039,7 +1039,7 @@ class LOCRecordSettings(TypedDict, total=False): class NAPTRRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1120,7 +1120,7 @@ class NAPTRRecordSettings(TypedDict, total=False): class SMIMEARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1195,7 +1195,7 @@ class SMIMEARecordSettings(TypedDict, total=False): class SRVRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1274,7 +1274,7 @@ class SRVRecordSettings(TypedDict, total=False): class SSHFPRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1346,7 +1346,7 @@ class SSHFPRecordSettings(TypedDict, total=False): class SVCBRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1418,7 +1418,7 @@ class SVCBRecordSettings(TypedDict, total=False): class TLSARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1493,7 +1493,7 @@ class TLSARecordSettings(TypedDict, total=False): class URIRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/dns/record_edit_params.py b/src/cloudflare/types/dns/record_edit_params.py index e17c3865ee3..cea103a95eb 100644 --- a/src/cloudflare/types/dns/record_edit_params.py +++ b/src/cloudflare/types/dns/record_edit_params.py @@ -70,7 +70,7 @@ class ARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -132,7 +132,7 @@ class ARecordSettings(TypedDict, total=False): class AAAARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -194,7 +194,7 @@ class AAAARecordSettings(TypedDict, total=False): class CNAMERecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -261,7 +261,7 @@ class CNAMERecordSettings(TypedDict, total=False): class MXRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -327,7 +327,7 @@ class MXRecordSettings(TypedDict, total=False): class NSRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -386,7 +386,7 @@ class NSRecordSettings(TypedDict, total=False): class DNSRecordsOpenpgpkeyRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -445,7 +445,7 @@ class DNSRecordsOpenpgpkeyRecordSettings(TypedDict, total=False): class PTRRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -504,7 +504,7 @@ class PTRRecordSettings(TypedDict, total=False): class TXTRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -571,7 +571,7 @@ class TXTRecordSettings(TypedDict, total=False): class CAARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -643,7 +643,7 @@ class CAARecordSettings(TypedDict, total=False): class CERTRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -718,7 +718,7 @@ class CERTRecordSettings(TypedDict, total=False): class DNSKEYRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -793,7 +793,7 @@ class DNSKEYRecordSettings(TypedDict, total=False): class DSRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -868,7 +868,7 @@ class DSRecordSettings(TypedDict, total=False): class HTTPSRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -940,7 +940,7 @@ class HTTPSRecordSettings(TypedDict, total=False): class LOCRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1039,7 +1039,7 @@ class LOCRecordSettings(TypedDict, total=False): class NAPTRRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1120,7 +1120,7 @@ class NAPTRRecordSettings(TypedDict, total=False): class SMIMEARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1195,7 +1195,7 @@ class SMIMEARecordSettings(TypedDict, total=False): class SRVRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1274,7 +1274,7 @@ class SRVRecordSettings(TypedDict, total=False): class SSHFPRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1346,7 +1346,7 @@ class SSHFPRecordSettings(TypedDict, total=False): class SVCBRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1418,7 +1418,7 @@ class SVCBRecordSettings(TypedDict, total=False): class TLSARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1493,7 +1493,7 @@ class TLSARecordSettings(TypedDict, total=False): class URIRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/dns/record_import_params.py b/src/cloudflare/types/dns/record_import_params.py index 36d58d3607c..75a3ee05fe9 100644 --- a/src/cloudflare/types/dns/record_import_params.py +++ b/src/cloudflare/types/dns/record_import_params.py @@ -8,7 +8,7 @@ class RecordImportParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" file: Required[str] diff --git a/src/cloudflare/types/dns/record_list_params.py b/src/cloudflare/types/dns/record_list_params.py index c69ac2400bc..8a050a75372 100644 --- a/src/cloudflare/types/dns/record_list_params.py +++ b/src/cloudflare/types/dns/record_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..shared.sort_direction import SortDirection @@ -10,7 +10,7 @@ class RecordListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" comment: Comment diff --git a/src/cloudflare/types/dns/record_scan_params.py b/src/cloudflare/types/dns/record_scan_params.py index 096c48fc645..36c2343be93 100644 --- a/src/cloudflare/types/dns/record_scan_params.py +++ b/src/cloudflare/types/dns/record_scan_params.py @@ -8,7 +8,7 @@ class RecordScanParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[object] diff --git a/src/cloudflare/types/dns/record_scan_review_params.py b/src/cloudflare/types/dns/record_scan_review_params.py index 249dba460f3..af9063883c6 100644 --- a/src/cloudflare/types/dns/record_scan_review_params.py +++ b/src/cloudflare/types/dns/record_scan_review_params.py @@ -39,7 +39,7 @@ class RecordScanReviewParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" accepts: Iterable[Accept] diff --git a/src/cloudflare/types/dns/record_update_params.py b/src/cloudflare/types/dns/record_update_params.py index bb4e7a6cd17..08daa1a1785 100644 --- a/src/cloudflare/types/dns/record_update_params.py +++ b/src/cloudflare/types/dns/record_update_params.py @@ -70,7 +70,7 @@ class ARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -132,7 +132,7 @@ class ARecordSettings(TypedDict, total=False): class AAAARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -194,7 +194,7 @@ class AAAARecordSettings(TypedDict, total=False): class CNAMERecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -261,7 +261,7 @@ class CNAMERecordSettings(TypedDict, total=False): class MXRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -327,7 +327,7 @@ class MXRecordSettings(TypedDict, total=False): class NSRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -386,7 +386,7 @@ class NSRecordSettings(TypedDict, total=False): class DNSRecordsOpenpgpkeyRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -445,7 +445,7 @@ class DNSRecordsOpenpgpkeyRecordSettings(TypedDict, total=False): class PTRRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -504,7 +504,7 @@ class PTRRecordSettings(TypedDict, total=False): class TXTRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -571,7 +571,7 @@ class TXTRecordSettings(TypedDict, total=False): class CAARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -643,7 +643,7 @@ class CAARecordSettings(TypedDict, total=False): class CERTRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -718,7 +718,7 @@ class CERTRecordSettings(TypedDict, total=False): class DNSKEYRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -793,7 +793,7 @@ class DNSKEYRecordSettings(TypedDict, total=False): class DSRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -868,7 +868,7 @@ class DSRecordSettings(TypedDict, total=False): class HTTPSRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -940,7 +940,7 @@ class HTTPSRecordSettings(TypedDict, total=False): class LOCRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1039,7 +1039,7 @@ class LOCRecordSettings(TypedDict, total=False): class NAPTRRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1120,7 +1120,7 @@ class NAPTRRecordSettings(TypedDict, total=False): class SMIMEARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1195,7 +1195,7 @@ class SMIMEARecordSettings(TypedDict, total=False): class SRVRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1274,7 +1274,7 @@ class SRVRecordSettings(TypedDict, total=False): class SSHFPRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1346,7 +1346,7 @@ class SSHFPRecordSettings(TypedDict, total=False): class SVCBRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1418,7 +1418,7 @@ class SVCBRecordSettings(TypedDict, total=False): class TLSARecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] @@ -1493,7 +1493,7 @@ class TLSARecordSettings(TypedDict, total=False): class URIRecord(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/dns/settings/account/view_create_params.py b/src/cloudflare/types/dns/settings/account/view_create_params.py index 52f64cd69cf..ef9a36945f2 100644 --- a/src/cloudflare/types/dns/settings/account/view_create_params.py +++ b/src/cloudflare/types/dns/settings/account/view_create_params.py @@ -10,7 +10,7 @@ class ViewCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/dns/settings/account/view_edit_params.py b/src/cloudflare/types/dns/settings/account/view_edit_params.py index 9160eb261e7..75c61b0d37e 100644 --- a/src/cloudflare/types/dns/settings/account/view_edit_params.py +++ b/src/cloudflare/types/dns/settings/account/view_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ....._types import SequenceNotStr @@ -10,7 +10,7 @@ class ViewEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: str diff --git a/src/cloudflare/types/dns/settings/account/view_list_params.py b/src/cloudflare/types/dns/settings/account/view_list_params.py index 30aa2c6e47d..38c36ae816c 100644 --- a/src/cloudflare/types/dns/settings/account/view_list_params.py +++ b/src/cloudflare/types/dns/settings/account/view_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ViewListParams", "Name"] class ViewListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/dns/settings/account_edit_params.py b/src/cloudflare/types/dns/settings/account_edit_params.py index a0c45ebf444..2cbbb17cbc7 100644 --- a/src/cloudflare/types/dns/settings/account_edit_params.py +++ b/src/cloudflare/types/dns/settings/account_edit_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["AccountEditParams", "ZoneDefaults", "ZoneDefaultsInternalDNS", "ZoneDefaultsNameservers", "ZoneDefaultsSOA"] class AccountEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" zone_defaults: ZoneDefaults diff --git a/src/cloudflare/types/dns/settings/zone_edit_params.py b/src/cloudflare/types/dns/settings/zone_edit_params.py index b413561f0e4..4898e8f07f7 100644 --- a/src/cloudflare/types/dns/settings/zone_edit_params.py +++ b/src/cloudflare/types/dns/settings/zone_edit_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ZoneEditParams", "InternalDNS", "Nameservers", "SOA"] class ZoneEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" flatten_all_cnames: bool diff --git a/src/cloudflare/types/dns/zone_transfers/acl_create_params.py b/src/cloudflare/types/dns/zone_transfers/acl_create_params.py index 45b0f0d7811..9b6a18f77e4 100644 --- a/src/cloudflare/types/dns/zone_transfers/acl_create_params.py +++ b/src/cloudflare/types/dns/zone_transfers/acl_create_params.py @@ -8,7 +8,7 @@ class ACLCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str ip_range: Required[str] """Allowed IPv4/IPv6 address range of primary or secondary nameservers. diff --git a/src/cloudflare/types/dns/zone_transfers/acl_update_params.py b/src/cloudflare/types/dns/zone_transfers/acl_update_params.py index 205f1f8daed..9382152f8aa 100644 --- a/src/cloudflare/types/dns/zone_transfers/acl_update_params.py +++ b/src/cloudflare/types/dns/zone_transfers/acl_update_params.py @@ -8,7 +8,7 @@ class ACLUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str ip_range: Required[str] """Allowed IPv4/IPv6 address range of primary or secondary nameservers. diff --git a/src/cloudflare/types/dns/zone_transfers/force_axfr_create_params.py b/src/cloudflare/types/dns/zone_transfers/force_axfr_create_params.py index 892842697cb..16e3986146f 100644 --- a/src/cloudflare/types/dns/zone_transfers/force_axfr_create_params.py +++ b/src/cloudflare/types/dns/zone_transfers/force_axfr_create_params.py @@ -8,6 +8,6 @@ class ForceAXFRCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str body: Required[object] diff --git a/src/cloudflare/types/dns/zone_transfers/incoming_create_params.py b/src/cloudflare/types/dns/zone_transfers/incoming_create_params.py index 961ace68261..49f3dde2e1a 100644 --- a/src/cloudflare/types/dns/zone_transfers/incoming_create_params.py +++ b/src/cloudflare/types/dns/zone_transfers/incoming_create_params.py @@ -10,7 +10,7 @@ class IncomingCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str auto_refresh_seconds: Required[float] """ diff --git a/src/cloudflare/types/dns/zone_transfers/incoming_update_params.py b/src/cloudflare/types/dns/zone_transfers/incoming_update_params.py index 9fb936a108d..16963fe0439 100644 --- a/src/cloudflare/types/dns/zone_transfers/incoming_update_params.py +++ b/src/cloudflare/types/dns/zone_transfers/incoming_update_params.py @@ -10,7 +10,7 @@ class IncomingUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str auto_refresh_seconds: Required[float] """ diff --git a/src/cloudflare/types/dns/zone_transfers/outgoing_create_params.py b/src/cloudflare/types/dns/zone_transfers/outgoing_create_params.py index eb52b533c3e..186e0d76d1c 100644 --- a/src/cloudflare/types/dns/zone_transfers/outgoing_create_params.py +++ b/src/cloudflare/types/dns/zone_transfers/outgoing_create_params.py @@ -10,7 +10,7 @@ class OutgoingCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str name: Required[str] """Zone name.""" diff --git a/src/cloudflare/types/dns/zone_transfers/outgoing_disable_params.py b/src/cloudflare/types/dns/zone_transfers/outgoing_disable_params.py index 08d06c56acf..8bbd4760d2b 100644 --- a/src/cloudflare/types/dns/zone_transfers/outgoing_disable_params.py +++ b/src/cloudflare/types/dns/zone_transfers/outgoing_disable_params.py @@ -8,6 +8,6 @@ class OutgoingDisableParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str body: Required[object] diff --git a/src/cloudflare/types/dns/zone_transfers/outgoing_enable_params.py b/src/cloudflare/types/dns/zone_transfers/outgoing_enable_params.py index 93e197b2bac..1e26da6a722 100644 --- a/src/cloudflare/types/dns/zone_transfers/outgoing_enable_params.py +++ b/src/cloudflare/types/dns/zone_transfers/outgoing_enable_params.py @@ -8,6 +8,6 @@ class OutgoingEnableParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str body: Required[object] diff --git a/src/cloudflare/types/dns/zone_transfers/outgoing_force_notify_params.py b/src/cloudflare/types/dns/zone_transfers/outgoing_force_notify_params.py index 7835ae3d3ca..1b78778cad5 100644 --- a/src/cloudflare/types/dns/zone_transfers/outgoing_force_notify_params.py +++ b/src/cloudflare/types/dns/zone_transfers/outgoing_force_notify_params.py @@ -8,6 +8,6 @@ class OutgoingForceNotifyParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str body: Required[object] diff --git a/src/cloudflare/types/dns/zone_transfers/outgoing_update_params.py b/src/cloudflare/types/dns/zone_transfers/outgoing_update_params.py index f9ac9478654..a1a8aa6bbb5 100644 --- a/src/cloudflare/types/dns/zone_transfers/outgoing_update_params.py +++ b/src/cloudflare/types/dns/zone_transfers/outgoing_update_params.py @@ -10,7 +10,7 @@ class OutgoingUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str name: Required[str] """Zone name.""" diff --git a/src/cloudflare/types/dns/zone_transfers/peer_create_params.py b/src/cloudflare/types/dns/zone_transfers/peer_create_params.py index 6e4dfbf4275..d7b6be36a6a 100644 --- a/src/cloudflare/types/dns/zone_transfers/peer_create_params.py +++ b/src/cloudflare/types/dns/zone_transfers/peer_create_params.py @@ -8,7 +8,7 @@ class PeerCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] """The name of the peer.""" diff --git a/src/cloudflare/types/dns/zone_transfers/peer_update_params.py b/src/cloudflare/types/dns/zone_transfers/peer_update_params.py index a8b0f30a4bf..e5958e097de 100644 --- a/src/cloudflare/types/dns/zone_transfers/peer_update_params.py +++ b/src/cloudflare/types/dns/zone_transfers/peer_update_params.py @@ -8,7 +8,7 @@ class PeerUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] """The name of the peer.""" diff --git a/src/cloudflare/types/dns/zone_transfers/tsig_create_params.py b/src/cloudflare/types/dns/zone_transfers/tsig_create_params.py index 81d9ae16367..dc6526717d9 100644 --- a/src/cloudflare/types/dns/zone_transfers/tsig_create_params.py +++ b/src/cloudflare/types/dns/zone_transfers/tsig_create_params.py @@ -8,7 +8,7 @@ class TSIGCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str algo: Required[str] """TSIG algorithm.""" diff --git a/src/cloudflare/types/dns/zone_transfers/tsig_update_params.py b/src/cloudflare/types/dns/zone_transfers/tsig_update_params.py index 459c53962d4..bb475ea1651 100644 --- a/src/cloudflare/types/dns/zone_transfers/tsig_update_params.py +++ b/src/cloudflare/types/dns/zone_transfers/tsig_update_params.py @@ -8,7 +8,7 @@ class TSIGUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str algo: Required[str] """TSIG algorithm.""" diff --git a/src/cloudflare/types/dns_firewall/analytics/report_get_params.py b/src/cloudflare/types/dns_firewall/analytics/report_get_params.py index 8ef5f5c9902..5eca2d1b754 100644 --- a/src/cloudflare/types/dns_firewall/analytics/report_get_params.py +++ b/src/cloudflare/types/dns_firewall/analytics/report_get_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class ReportGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dimensions: str diff --git a/src/cloudflare/types/dns_firewall/analytics/reports/bytime_get_params.py b/src/cloudflare/types/dns_firewall/analytics/reports/bytime_get_params.py index e335fd562be..67cd6040c2f 100644 --- a/src/cloudflare/types/dns_firewall/analytics/reports/bytime_get_params.py +++ b/src/cloudflare/types/dns_firewall/analytics/reports/bytime_get_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ....._utils import PropertyInfo @@ -12,7 +12,7 @@ class BytimeGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dimensions: str diff --git a/src/cloudflare/types/dns_firewall/dns_firewall_create_params.py b/src/cloudflare/types/dns_firewall/dns_firewall_create_params.py index 996bf478de0..74268771db0 100644 --- a/src/cloudflare/types/dns_firewall/dns_firewall_create_params.py +++ b/src/cloudflare/types/dns_firewall/dns_firewall_create_params.py @@ -13,7 +13,7 @@ class DNSFirewallCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/dns_firewall/dns_firewall_edit_params.py b/src/cloudflare/types/dns_firewall/dns_firewall_edit_params.py index 54db8800756..f1b4a351829 100644 --- a/src/cloudflare/types/dns_firewall/dns_firewall_edit_params.py +++ b/src/cloudflare/types/dns_firewall/dns_firewall_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr from .upstream_ips import UpstreamIPs @@ -13,7 +13,7 @@ class DNSFirewallEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" attack_mitigation: Optional[AttackMitigationParam] diff --git a/src/cloudflare/types/dns_firewall/dns_firewall_list_params.py b/src/cloudflare/types/dns_firewall/dns_firewall_list_params.py index 7be6cb9e4c5..7df34f308a0 100644 --- a/src/cloudflare/types/dns_firewall/dns_firewall_list_params.py +++ b/src/cloudflare/types/dns_firewall/dns_firewall_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DNSFirewallListParams"] class DNSFirewallListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: float diff --git a/src/cloudflare/types/dns_firewall/reverse_dns_edit_params.py b/src/cloudflare/types/dns_firewall/reverse_dns_edit_params.py index 3dcee9d7c76..c6a853475d3 100644 --- a/src/cloudflare/types/dns_firewall/reverse_dns_edit_params.py +++ b/src/cloudflare/types/dns_firewall/reverse_dns_edit_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Dict -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ReverseDNSEditParams"] class ReverseDNSEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" ptr: Dict[str, str] diff --git a/src/cloudflare/types/durable_objects/namespace_list_params.py b/src/cloudflare/types/durable_objects/namespace_list_params.py index fbcee077363..aa39c922733 100644 --- a/src/cloudflare/types/durable_objects/namespace_list_params.py +++ b/src/cloudflare/types/durable_objects/namespace_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["NamespaceListParams"] class NamespaceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/durable_objects/namespaces/object_list_params.py b/src/cloudflare/types/durable_objects/namespaces/object_list_params.py index c9aed59a0d1..252e27e8458 100644 --- a/src/cloudflare/types/durable_objects/namespaces/object_list_params.py +++ b/src/cloudflare/types/durable_objects/namespaces/object_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ObjectListParams"] class ObjectListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" cursor: str diff --git a/src/cloudflare/types/email_routing/address_create_params.py b/src/cloudflare/types/email_routing/address_create_params.py index fa5067b932d..e4d64087f6d 100644 --- a/src/cloudflare/types/email_routing/address_create_params.py +++ b/src/cloudflare/types/email_routing/address_create_params.py @@ -8,7 +8,7 @@ class AddressCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" email: Required[str] diff --git a/src/cloudflare/types/email_routing/address_list_params.py b/src/cloudflare/types/email_routing/address_list_params.py index 8e345e2e994..b13a4d2549f 100644 --- a/src/cloudflare/types/email_routing/address_list_params.py +++ b/src/cloudflare/types/email_routing/address_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["AddressListParams"] class AddressListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/email_routing/dns_create_params.py b/src/cloudflare/types/email_routing/dns_create_params.py index 1d46da69429..ed934b84fb8 100644 --- a/src/cloudflare/types/email_routing/dns_create_params.py +++ b/src/cloudflare/types/email_routing/dns_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DNSCreateParams"] class DNSCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: str diff --git a/src/cloudflare/types/email_routing/dns_edit_params.py b/src/cloudflare/types/email_routing/dns_edit_params.py index 67ec9ed80d9..2a0c20eb0db 100644 --- a/src/cloudflare/types/email_routing/dns_edit_params.py +++ b/src/cloudflare/types/email_routing/dns_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DNSEditParams"] class DNSEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: str diff --git a/src/cloudflare/types/email_routing/dns_get_params.py b/src/cloudflare/types/email_routing/dns_get_params.py index 926b1619307..faba4bcc344 100644 --- a/src/cloudflare/types/email_routing/dns_get_params.py +++ b/src/cloudflare/types/email_routing/dns_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DNSGetParams"] class DNSGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" subdomain: str diff --git a/src/cloudflare/types/email_routing/email_routing_disable_params.py b/src/cloudflare/types/email_routing/email_routing_disable_params.py index 94f4891ad9b..a2f7b245760 100644 --- a/src/cloudflare/types/email_routing/email_routing_disable_params.py +++ b/src/cloudflare/types/email_routing/email_routing_disable_params.py @@ -8,7 +8,7 @@ class EmailRoutingDisableParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[object] diff --git a/src/cloudflare/types/email_routing/email_routing_enable_params.py b/src/cloudflare/types/email_routing/email_routing_enable_params.py index 5feb5e016fa..6289d4e5fa4 100644 --- a/src/cloudflare/types/email_routing/email_routing_enable_params.py +++ b/src/cloudflare/types/email_routing/email_routing_enable_params.py @@ -8,7 +8,7 @@ class EmailRoutingEnableParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[object] diff --git a/src/cloudflare/types/email_routing/rule_create_params.py b/src/cloudflare/types/email_routing/rule_create_params.py index 9c99864160e..2a96fdb1a31 100644 --- a/src/cloudflare/types/email_routing/rule_create_params.py +++ b/src/cloudflare/types/email_routing/rule_create_params.py @@ -12,7 +12,7 @@ class RuleCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" actions: Required[Iterable[ActionParam]] diff --git a/src/cloudflare/types/email_routing/rule_list_params.py b/src/cloudflare/types/email_routing/rule_list_params.py index bb27b3d4885..cdb5b69aa03 100644 --- a/src/cloudflare/types/email_routing/rule_list_params.py +++ b/src/cloudflare/types/email_routing/rule_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["RuleListParams"] class RuleListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" enabled: Literal[True, False] diff --git a/src/cloudflare/types/email_routing/rule_update_params.py b/src/cloudflare/types/email_routing/rule_update_params.py index eaa7f60e258..9712f7338fd 100644 --- a/src/cloudflare/types/email_routing/rule_update_params.py +++ b/src/cloudflare/types/email_routing/rule_update_params.py @@ -12,7 +12,7 @@ class RuleUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" actions: Required[Iterable[ActionParam]] diff --git a/src/cloudflare/types/email_routing/rules/catch_all_update_params.py b/src/cloudflare/types/email_routing/rules/catch_all_update_params.py index 950fb1e1b36..e0afc3456cd 100644 --- a/src/cloudflare/types/email_routing/rules/catch_all_update_params.py +++ b/src/cloudflare/types/email_routing/rules/catch_all_update_params.py @@ -12,7 +12,7 @@ class CatchAllUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" actions: Required[Iterable[CatchAllActionParam]] diff --git a/src/cloudflare/types/email_security/investigate/move_bulk_params.py b/src/cloudflare/types/email_security/investigate/move_bulk_params.py index b269132b524..95c5b5d2783 100644 --- a/src/cloudflare/types/email_security/investigate/move_bulk_params.py +++ b/src/cloudflare/types/email_security/investigate/move_bulk_params.py @@ -10,7 +10,7 @@ class MoveBulkParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" destination: Required[ diff --git a/src/cloudflare/types/email_security/investigate/move_create_params.py b/src/cloudflare/types/email_security/investigate/move_create_params.py index c4c977447e5..87efbf79446 100644 --- a/src/cloudflare/types/email_security/investigate/move_create_params.py +++ b/src/cloudflare/types/email_security/investigate/move_create_params.py @@ -8,7 +8,7 @@ class MoveCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" destination: Required[ diff --git a/src/cloudflare/types/email_security/investigate/preview_create_params.py b/src/cloudflare/types/email_security/investigate/preview_create_params.py index f14b41a6449..af4a02f9e99 100644 --- a/src/cloudflare/types/email_security/investigate/preview_create_params.py +++ b/src/cloudflare/types/email_security/investigate/preview_create_params.py @@ -8,7 +8,7 @@ class PreviewCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" postfix_id: Required[str] diff --git a/src/cloudflare/types/email_security/investigate/reclassify_create_params.py b/src/cloudflare/types/email_security/investigate/reclassify_create_params.py index 9bc5a664d51..5e27d769563 100644 --- a/src/cloudflare/types/email_security/investigate/reclassify_create_params.py +++ b/src/cloudflare/types/email_security/investigate/reclassify_create_params.py @@ -8,7 +8,7 @@ class ReclassifyCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" expected_disposition: Required[Literal["NONE", "BULK", "MALICIOUS", "SPAM", "SPOOF", "SUSPICIOUS"]] diff --git a/src/cloudflare/types/email_security/investigate/release_bulk_params.py b/src/cloudflare/types/email_security/investigate/release_bulk_params.py index fa6f4ef65b3..42c984afdda 100644 --- a/src/cloudflare/types/email_security/investigate/release_bulk_params.py +++ b/src/cloudflare/types/email_security/investigate/release_bulk_params.py @@ -10,7 +10,7 @@ class ReleaseBulkParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" body: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/email_security/investigate/trace_get_params.py b/src/cloudflare/types/email_security/investigate/trace_get_params.py index d4d5cf33670..aaa0a513c3e 100644 --- a/src/cloudflare/types/email_security/investigate/trace_get_params.py +++ b/src/cloudflare/types/email_security/investigate/trace_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["TraceGetParams"] class TraceGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" submission: bool diff --git a/src/cloudflare/types/email_security/investigate_get_params.py b/src/cloudflare/types/email_security/investigate_get_params.py index 083388f1cad..e523a890dc2 100644 --- a/src/cloudflare/types/email_security/investigate_get_params.py +++ b/src/cloudflare/types/email_security/investigate_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["InvestigateGetParams"] class InvestigateGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" submission: bool diff --git a/src/cloudflare/types/email_security/investigate_list_params.py b/src/cloudflare/types/email_security/investigate_list_params.py index cfd21fbcaef..960e2998fba 100644 --- a/src/cloudflare/types/email_security/investigate_list_params.py +++ b/src/cloudflare/types/email_security/investigate_list_params.py @@ -4,7 +4,7 @@ from typing import Union, Optional from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class InvestigateListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" action_log: bool diff --git a/src/cloudflare/types/email_security/phishguard/report_list_params.py b/src/cloudflare/types/email_security/phishguard/report_list_params.py index d138ab6e96c..3947050a3af 100644 --- a/src/cloudflare/types/email_security/phishguard/report_list_params.py +++ b/src/cloudflare/types/email_security/phishguard/report_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import date, datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class ReportListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" end: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/email_security/settings/allow_policy_create_params.py b/src/cloudflare/types/email_security/settings/allow_policy_create_params.py index 9c0e132e1b2..8757340bfb4 100644 --- a/src/cloudflare/types/email_security/settings/allow_policy_create_params.py +++ b/src/cloudflare/types/email_security/settings/allow_policy_create_params.py @@ -9,7 +9,7 @@ class AllowPolicyCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" is_acceptable_sender: Required[bool] diff --git a/src/cloudflare/types/email_security/settings/allow_policy_edit_params.py b/src/cloudflare/types/email_security/settings/allow_policy_edit_params.py index 6b4de29a3bb..d26d1e6cc99 100644 --- a/src/cloudflare/types/email_security/settings/allow_policy_edit_params.py +++ b/src/cloudflare/types/email_security/settings/allow_policy_edit_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["AllowPolicyEditParams"] class AllowPolicyEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" comments: Optional[str] diff --git a/src/cloudflare/types/email_security/settings/allow_policy_list_params.py b/src/cloudflare/types/email_security/settings/allow_policy_list_params.py index 85380271064..90c79372744 100644 --- a/src/cloudflare/types/email_security/settings/allow_policy_list_params.py +++ b/src/cloudflare/types/email_security/settings/allow_policy_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["AllowPolicyListParams"] class AllowPolicyListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/email_security/settings/block_sender_create_params.py b/src/cloudflare/types/email_security/settings/block_sender_create_params.py index dc5290d600f..afeaeba6cfc 100644 --- a/src/cloudflare/types/email_security/settings/block_sender_create_params.py +++ b/src/cloudflare/types/email_security/settings/block_sender_create_params.py @@ -9,7 +9,7 @@ class BlockSenderCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" is_regex: Required[bool] diff --git a/src/cloudflare/types/email_security/settings/block_sender_edit_params.py b/src/cloudflare/types/email_security/settings/block_sender_edit_params.py index 19f2d23458a..716e8a2a1e5 100644 --- a/src/cloudflare/types/email_security/settings/block_sender_edit_params.py +++ b/src/cloudflare/types/email_security/settings/block_sender_edit_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["BlockSenderEditParams"] class BlockSenderEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" comments: Optional[str] diff --git a/src/cloudflare/types/email_security/settings/block_sender_list_params.py b/src/cloudflare/types/email_security/settings/block_sender_list_params.py index 712ad5932dd..56195b56848 100644 --- a/src/cloudflare/types/email_security/settings/block_sender_list_params.py +++ b/src/cloudflare/types/email_security/settings/block_sender_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["BlockSenderListParams"] class BlockSenderListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/email_security/settings/domain_edit_params.py b/src/cloudflare/types/email_security/settings/domain_edit_params.py index bf6dec63309..167d443d595 100644 --- a/src/cloudflare/types/email_security/settings/domain_edit_params.py +++ b/src/cloudflare/types/email_security/settings/domain_edit_params.py @@ -11,7 +11,7 @@ class DomainEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" ip_restrictions: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/email_security/settings/domain_list_params.py b/src/cloudflare/types/email_security/settings/domain_list_params.py index 6546a419a74..6c9a82aeeb0 100644 --- a/src/cloudflare/types/email_security/settings/domain_list_params.py +++ b/src/cloudflare/types/email_security/settings/domain_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ...._types import SequenceNotStr @@ -10,7 +10,7 @@ class DomainListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" active_delivery_mode: Literal["DIRECT", "BCC", "JOURNAL", "API", "RETRO_SCAN"] diff --git a/src/cloudflare/types/email_security/settings/impersonation_registry_create_params.py b/src/cloudflare/types/email_security/settings/impersonation_registry_create_params.py index db25db7e746..f9008beaf3e 100644 --- a/src/cloudflare/types/email_security/settings/impersonation_registry_create_params.py +++ b/src/cloudflare/types/email_security/settings/impersonation_registry_create_params.py @@ -8,7 +8,7 @@ class ImpersonationRegistryCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" email: Required[str] diff --git a/src/cloudflare/types/email_security/settings/impersonation_registry_edit_params.py b/src/cloudflare/types/email_security/settings/impersonation_registry_edit_params.py index 8dceb0e75f7..c62b6dd4707 100644 --- a/src/cloudflare/types/email_security/settings/impersonation_registry_edit_params.py +++ b/src/cloudflare/types/email_security/settings/impersonation_registry_edit_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ImpersonationRegistryEditParams"] class ImpersonationRegistryEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" email: Optional[str] diff --git a/src/cloudflare/types/email_security/settings/impersonation_registry_list_params.py b/src/cloudflare/types/email_security/settings/impersonation_registry_list_params.py index 49a2b1ddf0a..26aa1ab4d4f 100644 --- a/src/cloudflare/types/email_security/settings/impersonation_registry_list_params.py +++ b/src/cloudflare/types/email_security/settings/impersonation_registry_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ImpersonationRegistryListParams"] class ImpersonationRegistryListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/email_security/settings/trusted_domain_create_params.py b/src/cloudflare/types/email_security/settings/trusted_domain_create_params.py index 3159478e22d..2c0e719c06f 100644 --- a/src/cloudflare/types/email_security/settings/trusted_domain_create_params.py +++ b/src/cloudflare/types/email_security/settings/trusted_domain_create_params.py @@ -9,7 +9,7 @@ class EmailSecurityCreateTrustedDomain(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" is_recent: Required[bool] @@ -32,7 +32,7 @@ class EmailSecurityCreateTrustedDomain(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" body: Required[Iterable[Variant1Body]] diff --git a/src/cloudflare/types/email_security/settings/trusted_domain_edit_params.py b/src/cloudflare/types/email_security/settings/trusted_domain_edit_params.py index 90d1acfc7c0..07cf42555a5 100644 --- a/src/cloudflare/types/email_security/settings/trusted_domain_edit_params.py +++ b/src/cloudflare/types/email_security/settings/trusted_domain_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["TrustedDomainEditParams"] class TrustedDomainEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" comments: str diff --git a/src/cloudflare/types/email_security/settings/trusted_domain_list_params.py b/src/cloudflare/types/email_security/settings/trusted_domain_list_params.py index b9446971853..28ca7c472dc 100644 --- a/src/cloudflare/types/email_security/settings/trusted_domain_list_params.py +++ b/src/cloudflare/types/email_security/settings/trusted_domain_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["TrustedDomainListParams"] class TrustedDomainListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/email_security/submission_list_params.py b/src/cloudflare/types/email_security/submission_list_params.py index 225fb097290..c95f44da77d 100644 --- a/src/cloudflare/types/email_security/submission_list_params.py +++ b/src/cloudflare/types/email_security/submission_list_params.py @@ -4,7 +4,7 @@ from typing import Union, Optional from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class SubmissionListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" customer_status: Literal["escalated", "reviewed", "unreviewed"] diff --git a/src/cloudflare/types/email_sending/email_sending_send_params.py b/src/cloudflare/types/email_sending/email_sending_send_params.py index ff540c47c02..b994ba54b5d 100644 --- a/src/cloudflare/types/email_sending/email_sending_send_params.py +++ b/src/cloudflare/types/email_sending/email_sending_send_params.py @@ -21,7 +21,7 @@ class EmailSendingSendParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of the account.""" from_: Required[Annotated[From, PropertyInfo(alias="from")]] diff --git a/src/cloudflare/types/email_sending/email_sending_send_raw_params.py b/src/cloudflare/types/email_sending/email_sending_send_raw_params.py index 41efcc174c7..296b6c85c56 100644 --- a/src/cloudflare/types/email_sending/email_sending_send_raw_params.py +++ b/src/cloudflare/types/email_sending/email_sending_send_raw_params.py @@ -11,7 +11,7 @@ class EmailSendingSendRawParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier of the account.""" from_: Required[Annotated[str, PropertyInfo(alias="from")]] diff --git a/src/cloudflare/types/email_sending/subdomain_create_params.py b/src/cloudflare/types/email_sending/subdomain_create_params.py index 75a009bf3e5..6eacd252670 100644 --- a/src/cloudflare/types/email_sending/subdomain_create_params.py +++ b/src/cloudflare/types/email_sending/subdomain_create_params.py @@ -8,7 +8,7 @@ class SubdomainCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/filters/filter_bulk_delete_params.py b/src/cloudflare/types/filters/filter_bulk_delete_params.py index 7150780b6bd..3971271000f 100644 --- a/src/cloudflare/types/filters/filter_bulk_delete_params.py +++ b/src/cloudflare/types/filters/filter_bulk_delete_params.py @@ -10,7 +10,7 @@ class FilterBulkDeleteParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" id: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/filters/filter_bulk_update_params.py b/src/cloudflare/types/filters/filter_bulk_update_params.py index 23cc086a37b..e8e846da6e4 100644 --- a/src/cloudflare/types/filters/filter_bulk_update_params.py +++ b/src/cloudflare/types/filters/filter_bulk_update_params.py @@ -9,7 +9,7 @@ class FilterBulkUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/filters/filter_create_params.py b/src/cloudflare/types/filters/filter_create_params.py index f21059d8cb8..fad67e30f77 100644 --- a/src/cloudflare/types/filters/filter_create_params.py +++ b/src/cloudflare/types/filters/filter_create_params.py @@ -11,7 +11,7 @@ class FilterCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" body: Required[Iterable[FirewallFilterParam]] diff --git a/src/cloudflare/types/filters/filter_list_params.py b/src/cloudflare/types/filters/filter_list_params.py index d64f470e5eb..90555b9820c 100644 --- a/src/cloudflare/types/filters/filter_list_params.py +++ b/src/cloudflare/types/filters/filter_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["FilterListParams"] class FilterListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" id: str diff --git a/src/cloudflare/types/filters/filter_update_params.py b/src/cloudflare/types/filters/filter_update_params.py index 38f6c3af411..ec439209dcf 100644 --- a/src/cloudflare/types/filters/filter_update_params.py +++ b/src/cloudflare/types/filters/filter_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["FilterUpdateParams"] class FilterUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" description: str diff --git a/src/cloudflare/types/firewall/lockdown_create_params.py b/src/cloudflare/types/firewall/lockdown_create_params.py index b25d78212dd..bfd96ed5c25 100644 --- a/src/cloudflare/types/firewall/lockdown_create_params.py +++ b/src/cloudflare/types/firewall/lockdown_create_params.py @@ -12,7 +12,7 @@ class LockdownCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" configurations: Required[ConfigurationParam] diff --git a/src/cloudflare/types/firewall/lockdown_list_params.py b/src/cloudflare/types/firewall/lockdown_list_params.py index 85b6a5cb4f0..644942d6ec3 100644 --- a/src/cloudflare/types/firewall/lockdown_list_params.py +++ b/src/cloudflare/types/firewall/lockdown_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class LockdownListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" created_on: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/firewall/lockdown_update_params.py b/src/cloudflare/types/firewall/lockdown_update_params.py index 79c4db1b756..5dda981da13 100644 --- a/src/cloudflare/types/firewall/lockdown_update_params.py +++ b/src/cloudflare/types/firewall/lockdown_update_params.py @@ -12,7 +12,7 @@ class LockdownUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" configurations: Required[ConfigurationParam] diff --git a/src/cloudflare/types/firewall/rule_bulk_edit_params.py b/src/cloudflare/types/firewall/rule_bulk_edit_params.py index 1ac14b38861..612cf917805 100644 --- a/src/cloudflare/types/firewall/rule_bulk_edit_params.py +++ b/src/cloudflare/types/firewall/rule_bulk_edit_params.py @@ -8,7 +8,7 @@ class RuleBulkEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" body: Required[object] diff --git a/src/cloudflare/types/firewall/rule_bulk_update_params.py b/src/cloudflare/types/firewall/rule_bulk_update_params.py index 2f5e7331b4c..241c96be1bb 100644 --- a/src/cloudflare/types/firewall/rule_bulk_update_params.py +++ b/src/cloudflare/types/firewall/rule_bulk_update_params.py @@ -8,7 +8,7 @@ class RuleBulkUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" body: Required[object] diff --git a/src/cloudflare/types/firewall/rule_create_params.py b/src/cloudflare/types/firewall/rule_create_params.py index a11900bed22..be6cac35f57 100644 --- a/src/cloudflare/types/firewall/rule_create_params.py +++ b/src/cloudflare/types/firewall/rule_create_params.py @@ -10,7 +10,7 @@ class RuleCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" action: Required[Action] diff --git a/src/cloudflare/types/firewall/rule_list_params.py b/src/cloudflare/types/firewall/rule_list_params.py index 8cfb84bcb12..9fc0d6d002e 100644 --- a/src/cloudflare/types/firewall/rule_list_params.py +++ b/src/cloudflare/types/firewall/rule_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["RuleListParams"] class RuleListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" id: str diff --git a/src/cloudflare/types/firewall/rule_update_params.py b/src/cloudflare/types/firewall/rule_update_params.py index cde6e776dd3..8259ab50fde 100644 --- a/src/cloudflare/types/firewall/rule_update_params.py +++ b/src/cloudflare/types/firewall/rule_update_params.py @@ -10,7 +10,7 @@ class RuleUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" action: Required[Action] diff --git a/src/cloudflare/types/firewall/ua_rule_create_params.py b/src/cloudflare/types/firewall/ua_rule_create_params.py index 01e49728041..41f451f14c3 100644 --- a/src/cloudflare/types/firewall/ua_rule_create_params.py +++ b/src/cloudflare/types/firewall/ua_rule_create_params.py @@ -8,7 +8,7 @@ class UARuleCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" configuration: Required[Configuration] diff --git a/src/cloudflare/types/firewall/ua_rule_list_params.py b/src/cloudflare/types/firewall/ua_rule_list_params.py index c40c8bd6cde..658a7d9b9b8 100644 --- a/src/cloudflare/types/firewall/ua_rule_list_params.py +++ b/src/cloudflare/types/firewall/ua_rule_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["UARuleListParams"] class UARuleListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" description: str diff --git a/src/cloudflare/types/firewall/ua_rule_update_params.py b/src/cloudflare/types/firewall/ua_rule_update_params.py index eb27661492d..c79606c34eb 100644 --- a/src/cloudflare/types/firewall/ua_rule_update_params.py +++ b/src/cloudflare/types/firewall/ua_rule_update_params.py @@ -15,7 +15,7 @@ class UARuleUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" configuration: Required[Configuration] diff --git a/src/cloudflare/types/firewall/waf/override_create_params.py b/src/cloudflare/types/firewall/waf/override_create_params.py index d280db03748..f61dc086967 100644 --- a/src/cloudflare/types/firewall/waf/override_create_params.py +++ b/src/cloudflare/types/firewall/waf/override_create_params.py @@ -11,7 +11,7 @@ class OverrideCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" urls: Required[SequenceNotStr[OverrideURL]] diff --git a/src/cloudflare/types/firewall/waf/override_list_params.py b/src/cloudflare/types/firewall/waf/override_list_params.py index 12d8111435e..ce5f5154cb4 100644 --- a/src/cloudflare/types/firewall/waf/override_list_params.py +++ b/src/cloudflare/types/firewall/waf/override_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["OverrideListParams"] class OverrideListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" page: float diff --git a/src/cloudflare/types/firewall/waf/override_update_params.py b/src/cloudflare/types/firewall/waf/override_update_params.py index 2c138cbd98a..5a033f16a7b 100644 --- a/src/cloudflare/types/firewall/waf/override_update_params.py +++ b/src/cloudflare/types/firewall/waf/override_update_params.py @@ -13,7 +13,7 @@ class OverrideUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" id: Required[str] diff --git a/src/cloudflare/types/firewall/waf/package_list_params.py b/src/cloudflare/types/firewall/waf/package_list_params.py index 364d1f35f07..fb8d67ed714 100644 --- a/src/cloudflare/types/firewall/waf/package_list_params.py +++ b/src/cloudflare/types/firewall/waf/package_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["PackageListParams"] class PackageListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/firewall/waf/packages/group_edit_params.py b/src/cloudflare/types/firewall/waf/packages/group_edit_params.py index 2134f85a1e0..9cb33853236 100644 --- a/src/cloudflare/types/firewall/waf/packages/group_edit_params.py +++ b/src/cloudflare/types/firewall/waf/packages/group_edit_params.py @@ -8,7 +8,7 @@ class GroupEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier of a schema.""" package_id: Required[str] diff --git a/src/cloudflare/types/firewall/waf/packages/group_list_params.py b/src/cloudflare/types/firewall/waf/packages/group_list_params.py index d7e0dea3b06..6ce99c88034 100644 --- a/src/cloudflare/types/firewall/waf/packages/group_list_params.py +++ b/src/cloudflare/types/firewall/waf/packages/group_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["GroupListParams"] class GroupListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier of a schema.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/firewall/waf/packages/rule_edit_params.py b/src/cloudflare/types/firewall/waf/packages/rule_edit_params.py index b9a3c69b7a2..2c6396b114c 100644 --- a/src/cloudflare/types/firewall/waf/packages/rule_edit_params.py +++ b/src/cloudflare/types/firewall/waf/packages/rule_edit_params.py @@ -8,7 +8,7 @@ class RuleEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier of a schema.""" package_id: Required[str] diff --git a/src/cloudflare/types/firewall/waf/packages/rule_list_params.py b/src/cloudflare/types/firewall/waf/packages/rule_list_params.py index 0288be1e0fa..43df7a129bd 100644 --- a/src/cloudflare/types/firewall/waf/packages/rule_list_params.py +++ b/src/cloudflare/types/firewall/waf/packages/rule_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["RuleListParams"] class RuleListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier of a schema.""" description: str diff --git a/src/cloudflare/types/fraud/fraud_update_params.py b/src/cloudflare/types/fraud/fraud_update_params.py index 78d59357e8c..ecb14d675be 100644 --- a/src/cloudflare/types/fraud/fraud_update_params.py +++ b/src/cloudflare/types/fraud/fraud_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class FraudUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" user_profiles: Literal["enabled", "disabled"] diff --git a/src/cloudflare/types/google_tag_gateway/config_update_params.py b/src/cloudflare/types/google_tag_gateway/config_update_params.py index 0fb64062ed9..747ac98abbd 100644 --- a/src/cloudflare/types/google_tag_gateway/config_update_params.py +++ b/src/cloudflare/types/google_tag_gateway/config_update_params.py @@ -11,7 +11,7 @@ class ConfigUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" enabled: Required[bool] diff --git a/src/cloudflare/types/healthchecks/healthcheck_create_params.py b/src/cloudflare/types/healthchecks/healthcheck_create_params.py index 90a2b01f73f..5340b2e1c3e 100644 --- a/src/cloudflare/types/healthchecks/healthcheck_create_params.py +++ b/src/cloudflare/types/healthchecks/healthcheck_create_params.py @@ -14,7 +14,7 @@ class HealthcheckCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" address: Required[str] diff --git a/src/cloudflare/types/healthchecks/healthcheck_edit_params.py b/src/cloudflare/types/healthchecks/healthcheck_edit_params.py index 605ca984c32..a9a3fc2d3b6 100644 --- a/src/cloudflare/types/healthchecks/healthcheck_edit_params.py +++ b/src/cloudflare/types/healthchecks/healthcheck_edit_params.py @@ -14,7 +14,7 @@ class HealthcheckEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" address: Required[str] diff --git a/src/cloudflare/types/healthchecks/healthcheck_list_params.py b/src/cloudflare/types/healthchecks/healthcheck_list_params.py index 919be7432fb..a99bd2b8407 100644 --- a/src/cloudflare/types/healthchecks/healthcheck_list_params.py +++ b/src/cloudflare/types/healthchecks/healthcheck_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HealthcheckListParams"] class HealthcheckListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" page: float diff --git a/src/cloudflare/types/healthchecks/healthcheck_update_params.py b/src/cloudflare/types/healthchecks/healthcheck_update_params.py index 834571fde52..b8dce39ac02 100644 --- a/src/cloudflare/types/healthchecks/healthcheck_update_params.py +++ b/src/cloudflare/types/healthchecks/healthcheck_update_params.py @@ -14,7 +14,7 @@ class HealthcheckUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" address: Required[str] diff --git a/src/cloudflare/types/healthchecks/preview_create_params.py b/src/cloudflare/types/healthchecks/preview_create_params.py index 8020a44e035..41b14b58cce 100644 --- a/src/cloudflare/types/healthchecks/preview_create_params.py +++ b/src/cloudflare/types/healthchecks/preview_create_params.py @@ -14,7 +14,7 @@ class PreviewCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" address: Required[str] diff --git a/src/cloudflare/types/hostnames/settings/tls_update_params.py b/src/cloudflare/types/hostnames/settings/tls_update_params.py index 90e8a461362..a111d434eac 100644 --- a/src/cloudflare/types/hostnames/settings/tls_update_params.py +++ b/src/cloudflare/types/hostnames/settings/tls_update_params.py @@ -10,7 +10,7 @@ class TLSUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" setting_id: Required[Literal["ciphers", "min_tls_version", "http2"]] diff --git a/src/cloudflare/types/hyperdrive/config_create_params.py b/src/cloudflare/types/hyperdrive/config_create_params.py index eeea86a6aed..8cca81962eb 100644 --- a/src/cloudflare/types/hyperdrive/config_create_params.py +++ b/src/cloudflare/types/hyperdrive/config_create_params.py @@ -19,7 +19,7 @@ class ConfigCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Define configurations using a unique string identifier.""" name: Required[str] diff --git a/src/cloudflare/types/hyperdrive/config_edit_params.py b/src/cloudflare/types/hyperdrive/config_edit_params.py index 97687cce4e7..8b5331133c2 100644 --- a/src/cloudflare/types/hyperdrive/config_edit_params.py +++ b/src/cloudflare/types/hyperdrive/config_edit_params.py @@ -20,7 +20,7 @@ class ConfigEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Define configurations using a unique string identifier.""" caching: Caching diff --git a/src/cloudflare/types/hyperdrive/config_update_params.py b/src/cloudflare/types/hyperdrive/config_update_params.py index 3bb71bcea7c..22dda91d257 100644 --- a/src/cloudflare/types/hyperdrive/config_update_params.py +++ b/src/cloudflare/types/hyperdrive/config_update_params.py @@ -19,7 +19,7 @@ class ConfigUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Define configurations using a unique string identifier.""" name: Required[str] diff --git a/src/cloudflare/types/iam/permission_group_list_params.py b/src/cloudflare/types/iam/permission_group_list_params.py index 04f58ce75ce..55b2cd6a8f0 100644 --- a/src/cloudflare/types/iam/permission_group_list_params.py +++ b/src/cloudflare/types/iam/permission_group_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PermissionGroupListParams"] class PermissionGroupListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" id: str diff --git a/src/cloudflare/types/iam/resource_group_create_params.py b/src/cloudflare/types/iam/resource_group_create_params.py index f732c8d93d1..8d40344c688 100644 --- a/src/cloudflare/types/iam/resource_group_create_params.py +++ b/src/cloudflare/types/iam/resource_group_create_params.py @@ -9,7 +9,7 @@ class ResourceGroupCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: Required[str] diff --git a/src/cloudflare/types/iam/resource_group_list_params.py b/src/cloudflare/types/iam/resource_group_list_params.py index 847d73fcdac..8698adff09d 100644 --- a/src/cloudflare/types/iam/resource_group_list_params.py +++ b/src/cloudflare/types/iam/resource_group_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ResourceGroupListParams"] class ResourceGroupListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" id: str diff --git a/src/cloudflare/types/iam/resource_group_update_params.py b/src/cloudflare/types/iam/resource_group_update_params.py index 14274c889a0..589d9dd1608 100644 --- a/src/cloudflare/types/iam/resource_group_update_params.py +++ b/src/cloudflare/types/iam/resource_group_update_params.py @@ -9,7 +9,7 @@ class ResourceGroupUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: str diff --git a/src/cloudflare/types/iam/sso_create_params.py b/src/cloudflare/types/iam/sso_create_params.py index ec1076e8d0a..666fee43912 100644 --- a/src/cloudflare/types/iam/sso_create_params.py +++ b/src/cloudflare/types/iam/sso_create_params.py @@ -8,7 +8,7 @@ class SSOCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" email_domain: Required[str] diff --git a/src/cloudflare/types/iam/sso_update_params.py b/src/cloudflare/types/iam/sso_update_params.py index 6f337f80b01..add3b23a702 100644 --- a/src/cloudflare/types/iam/sso_update_params.py +++ b/src/cloudflare/types/iam/sso_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SSOUpdateParams"] class SSOUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" enabled: bool diff --git a/src/cloudflare/types/iam/user_group_create_params.py b/src/cloudflare/types/iam/user_group_create_params.py index 84d18d7aa2b..76e64e058db 100644 --- a/src/cloudflare/types/iam/user_group_create_params.py +++ b/src/cloudflare/types/iam/user_group_create_params.py @@ -9,7 +9,7 @@ class UserGroupCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: Required[str] diff --git a/src/cloudflare/types/iam/user_group_list_params.py b/src/cloudflare/types/iam/user_group_list_params.py index 8280bb6c3e0..11b09bafb8c 100644 --- a/src/cloudflare/types/iam/user_group_list_params.py +++ b/src/cloudflare/types/iam/user_group_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -10,7 +10,7 @@ class UserGroupListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" id: str diff --git a/src/cloudflare/types/iam/user_group_update_params.py b/src/cloudflare/types/iam/user_group_update_params.py index 19d6be93124..59885183c15 100644 --- a/src/cloudflare/types/iam/user_group_update_params.py +++ b/src/cloudflare/types/iam/user_group_update_params.py @@ -9,7 +9,7 @@ class UserGroupUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" name: str diff --git a/src/cloudflare/types/iam/user_groups/member_create_params.py b/src/cloudflare/types/iam/user_groups/member_create_params.py index e1cfe45ece1..ca4c234cfbf 100644 --- a/src/cloudflare/types/iam/user_groups/member_create_params.py +++ b/src/cloudflare/types/iam/user_groups/member_create_params.py @@ -9,7 +9,7 @@ class MemberCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/iam/user_groups/member_list_params.py b/src/cloudflare/types/iam/user_groups/member_list_params.py index 49532964553..25f81527a16 100644 --- a/src/cloudflare/types/iam/user_groups/member_list_params.py +++ b/src/cloudflare/types/iam/user_groups/member_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["MemberListParams"] class MemberListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" page: float diff --git a/src/cloudflare/types/iam/user_groups/member_update_params.py b/src/cloudflare/types/iam/user_groups/member_update_params.py index 49c0ea06569..69f572b934c 100644 --- a/src/cloudflare/types/iam/user_groups/member_update_params.py +++ b/src/cloudflare/types/iam/user_groups/member_update_params.py @@ -9,7 +9,7 @@ class MemberUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/images/v1/variant_create_params.py b/src/cloudflare/types/images/v1/variant_create_params.py index ea2907aca25..e5f02341023 100644 --- a/src/cloudflare/types/images/v1/variant_create_params.py +++ b/src/cloudflare/types/images/v1/variant_create_params.py @@ -10,7 +10,7 @@ class VariantCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" id: Required[str] diff --git a/src/cloudflare/types/images/v1/variant_edit_params.py b/src/cloudflare/types/images/v1/variant_edit_params.py index 8f36382f9af..51203ed6fdc 100644 --- a/src/cloudflare/types/images/v1/variant_edit_params.py +++ b/src/cloudflare/types/images/v1/variant_edit_params.py @@ -10,7 +10,7 @@ class VariantEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" options: Required[Options] diff --git a/src/cloudflare/types/images/v1_create_params.py b/src/cloudflare/types/images/v1_create_params.py index 87764baa3a7..00eef1e087e 100644 --- a/src/cloudflare/types/images/v1_create_params.py +++ b/src/cloudflare/types/images/v1_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._types import FileTypes from ..._utils import PropertyInfo @@ -11,7 +11,7 @@ class V1CreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" id: str diff --git a/src/cloudflare/types/images/v1_edit_params.py b/src/cloudflare/types/images/v1_edit_params.py index 47b3f325861..7473842ce3c 100644 --- a/src/cloudflare/types/images/v1_edit_params.py +++ b/src/cloudflare/types/images/v1_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -10,7 +10,7 @@ class V1EditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" creator: str diff --git a/src/cloudflare/types/images/v1_list_params.py b/src/cloudflare/types/images/v1_list_params.py index 4e726436864..390f47274fa 100644 --- a/src/cloudflare/types/images/v1_list_params.py +++ b/src/cloudflare/types/images/v1_list_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["V1ListParams"] class V1ListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" creator: Optional[str] diff --git a/src/cloudflare/types/images/v2/direct_upload_create_params.py b/src/cloudflare/types/images/v2/direct_upload_create_params.py index f4c7b7971b1..0a9dd905fe3 100644 --- a/src/cloudflare/types/images/v2/direct_upload_create_params.py +++ b/src/cloudflare/types/images/v2/direct_upload_create_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class DirectUploadCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" id: str diff --git a/src/cloudflare/types/images/v2_list_params.py b/src/cloudflare/types/images/v2_list_params.py index 05b6d34de6d..158ca0420a7 100644 --- a/src/cloudflare/types/images/v2_list_params.py +++ b/src/cloudflare/types/images/v2_list_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -11,7 +11,7 @@ class V2ListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier tag.""" continuation_token: Optional[str] diff --git a/src/cloudflare/types/intel/attack_surface_report/issue_class_params.py b/src/cloudflare/types/intel/attack_surface_report/issue_class_params.py index dea6bc517db..cb9d40f1b0e 100644 --- a/src/cloudflare/types/intel/attack_surface_report/issue_class_params.py +++ b/src/cloudflare/types/intel/attack_surface_report/issue_class_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -14,7 +14,7 @@ class IssueClassParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dismissed: bool diff --git a/src/cloudflare/types/intel/attack_surface_report/issue_dismiss_params.py b/src/cloudflare/types/intel/attack_surface_report/issue_dismiss_params.py index 9e99366289a..c251faddaed 100644 --- a/src/cloudflare/types/intel/attack_surface_report/issue_dismiss_params.py +++ b/src/cloudflare/types/intel/attack_surface_report/issue_dismiss_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["IssueDismissParams"] class IssueDismissParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dismiss: bool diff --git a/src/cloudflare/types/intel/attack_surface_report/issue_list_params.py b/src/cloudflare/types/intel/attack_surface_report/issue_list_params.py index 2966798f2b0..15df237aa6c 100644 --- a/src/cloudflare/types/intel/attack_surface_report/issue_list_params.py +++ b/src/cloudflare/types/intel/attack_surface_report/issue_list_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -14,7 +14,7 @@ class IssueListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dismissed: bool diff --git a/src/cloudflare/types/intel/attack_surface_report/issue_severity_params.py b/src/cloudflare/types/intel/attack_surface_report/issue_severity_params.py index be70edbc260..8b3debd0d12 100644 --- a/src/cloudflare/types/intel/attack_surface_report/issue_severity_params.py +++ b/src/cloudflare/types/intel/attack_surface_report/issue_severity_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -14,7 +14,7 @@ class IssueSeverityParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dismissed: bool diff --git a/src/cloudflare/types/intel/attack_surface_report/issue_type_params.py b/src/cloudflare/types/intel/attack_surface_report/issue_type_params.py index 25cd8bde53f..8be99bb2c3b 100644 --- a/src/cloudflare/types/intel/attack_surface_report/issue_type_params.py +++ b/src/cloudflare/types/intel/attack_surface_report/issue_type_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -14,7 +14,7 @@ class IssueTypeParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dismissed: bool diff --git a/src/cloudflare/types/intel/dns_list_params.py b/src/cloudflare/types/intel/dns_list_params.py index 0d040386777..d65519fa6c7 100644 --- a/src/cloudflare/types/intel/dns_list_params.py +++ b/src/cloudflare/types/intel/dns_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import date -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class DNSListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" ipv4: str diff --git a/src/cloudflare/types/intel/domain_get_params.py b/src/cloudflare/types/intel/domain_get_params.py index 42ba437d630..d700eb7b0e6 100644 --- a/src/cloudflare/types/intel/domain_get_params.py +++ b/src/cloudflare/types/intel/domain_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DomainGetParams"] class DomainGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" domain: str diff --git a/src/cloudflare/types/intel/domain_history_get_params.py b/src/cloudflare/types/intel/domain_history_get_params.py index a4715231d50..8e2479ee4b9 100644 --- a/src/cloudflare/types/intel/domain_history_get_params.py +++ b/src/cloudflare/types/intel/domain_history_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DomainHistoryGetParams"] class DomainHistoryGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" domain: str diff --git a/src/cloudflare/types/intel/domains/bulk_get_params.py b/src/cloudflare/types/intel/domains/bulk_get_params.py index 5fd9ed9f983..04bfcf0fb92 100644 --- a/src/cloudflare/types/intel/domains/bulk_get_params.py +++ b/src/cloudflare/types/intel/domains/bulk_get_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ...._types import SequenceNotStr @@ -10,7 +10,7 @@ class BulkGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" domain: SequenceNotStr[str] diff --git a/src/cloudflare/types/intel/indicator_feed_create_params.py b/src/cloudflare/types/intel/indicator_feed_create_params.py index f5e9d38e6b4..90a850c9215 100644 --- a/src/cloudflare/types/intel/indicator_feed_create_params.py +++ b/src/cloudflare/types/intel/indicator_feed_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["IndicatorFeedCreateParams"] class IndicatorFeedCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" description: str diff --git a/src/cloudflare/types/intel/indicator_feed_update_params.py b/src/cloudflare/types/intel/indicator_feed_update_params.py index 8709cabc628..2553b63b6eb 100644 --- a/src/cloudflare/types/intel/indicator_feed_update_params.py +++ b/src/cloudflare/types/intel/indicator_feed_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["IndicatorFeedUpdateParams"] class IndicatorFeedUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" description: str diff --git a/src/cloudflare/types/intel/indicator_feeds/permission_create_params.py b/src/cloudflare/types/intel/indicator_feeds/permission_create_params.py index 2b6cedb4150..70b13b60b79 100644 --- a/src/cloudflare/types/intel/indicator_feeds/permission_create_params.py +++ b/src/cloudflare/types/intel/indicator_feeds/permission_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PermissionCreateParams"] class PermissionCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" account_tag: str diff --git a/src/cloudflare/types/intel/indicator_feeds/permission_delete_params.py b/src/cloudflare/types/intel/indicator_feeds/permission_delete_params.py index 7720a9680ab..2ab9fce8c89 100644 --- a/src/cloudflare/types/intel/indicator_feeds/permission_delete_params.py +++ b/src/cloudflare/types/intel/indicator_feeds/permission_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PermissionDeleteParams"] class PermissionDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" account_tag: str diff --git a/src/cloudflare/types/intel/indicator_feeds/snapshot_update_params.py b/src/cloudflare/types/intel/indicator_feeds/snapshot_update_params.py index ec0d386ca4f..ee38fd8b059 100644 --- a/src/cloudflare/types/intel/indicator_feeds/snapshot_update_params.py +++ b/src/cloudflare/types/intel/indicator_feeds/snapshot_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SnapshotUpdateParams"] class SnapshotUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" source: str diff --git a/src/cloudflare/types/intel/ip_get_params.py b/src/cloudflare/types/intel/ip_get_params.py index ac4b4ee5f88..446652d86f0 100644 --- a/src/cloudflare/types/intel/ip_get_params.py +++ b/src/cloudflare/types/intel/ip_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["IPGetParams"] class IPGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" ipv4: str diff --git a/src/cloudflare/types/intel/miscategorization_create_params.py b/src/cloudflare/types/intel/miscategorization_create_params.py index 3be6db1feeb..929afefc733 100644 --- a/src/cloudflare/types/intel/miscategorization_create_params.py +++ b/src/cloudflare/types/intel/miscategorization_create_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Iterable, Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["MiscategorizationCreateParams"] class MiscategorizationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" content_adds: Iterable[int] diff --git a/src/cloudflare/types/intel/whois_get_params.py b/src/cloudflare/types/intel/whois_get_params.py index 6bcf3ee91d0..9d1ba62e454 100644 --- a/src/cloudflare/types/intel/whois_get_params.py +++ b/src/cloudflare/types/intel/whois_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["WhoisGetParams"] class WhoisGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Use to uniquely identify or reference the resource.""" domain: str diff --git a/src/cloudflare/types/keyless_certificates/keyless_certificate_create_params.py b/src/cloudflare/types/keyless_certificates/keyless_certificate_create_params.py index 77056c21b7d..282a7092927 100644 --- a/src/cloudflare/types/keyless_certificates/keyless_certificate_create_params.py +++ b/src/cloudflare/types/keyless_certificates/keyless_certificate_create_params.py @@ -11,7 +11,7 @@ class KeylessCertificateCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" certificate: Required[str] diff --git a/src/cloudflare/types/keyless_certificates/keyless_certificate_edit_params.py b/src/cloudflare/types/keyless_certificates/keyless_certificate_edit_params.py index 298e4bfe4b6..51de2990b6d 100644 --- a/src/cloudflare/types/keyless_certificates/keyless_certificate_edit_params.py +++ b/src/cloudflare/types/keyless_certificates/keyless_certificate_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from .tunnel_param import TunnelParam @@ -10,7 +10,7 @@ class KeylessCertificateEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" enabled: bool diff --git a/src/cloudflare/types/kv/namespace_bulk_delete_params.py b/src/cloudflare/types/kv/namespace_bulk_delete_params.py index b5c49385eb5..8bdb4fa7ccf 100644 --- a/src/cloudflare/types/kv/namespace_bulk_delete_params.py +++ b/src/cloudflare/types/kv/namespace_bulk_delete_params.py @@ -10,7 +10,7 @@ class NamespaceBulkDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" body: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/kv/namespace_bulk_get_params.py b/src/cloudflare/types/kv/namespace_bulk_get_params.py index 4f5db117c23..c0c85df59c8 100644 --- a/src/cloudflare/types/kv/namespace_bulk_get_params.py +++ b/src/cloudflare/types/kv/namespace_bulk_get_params.py @@ -11,7 +11,7 @@ class NamespaceBulkGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" keys: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/kv/namespace_bulk_update_params.py b/src/cloudflare/types/kv/namespace_bulk_update_params.py index d56c1a14bbb..a159c3e35fe 100644 --- a/src/cloudflare/types/kv/namespace_bulk_update_params.py +++ b/src/cloudflare/types/kv/namespace_bulk_update_params.py @@ -9,7 +9,7 @@ class NamespaceBulkUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/kv/namespace_create_params.py b/src/cloudflare/types/kv/namespace_create_params.py index 85397033b26..ed0c33d606c 100644 --- a/src/cloudflare/types/kv/namespace_create_params.py +++ b/src/cloudflare/types/kv/namespace_create_params.py @@ -8,7 +8,7 @@ class NamespaceCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" title: Required[str] diff --git a/src/cloudflare/types/kv/namespace_list_params.py b/src/cloudflare/types/kv/namespace_list_params.py index 8c217e6fef4..5cc982a7e96 100644 --- a/src/cloudflare/types/kv/namespace_list_params.py +++ b/src/cloudflare/types/kv/namespace_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["NamespaceListParams"] class NamespaceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/kv/namespace_update_params.py b/src/cloudflare/types/kv/namespace_update_params.py index 71f317ca4e4..f113a945292 100644 --- a/src/cloudflare/types/kv/namespace_update_params.py +++ b/src/cloudflare/types/kv/namespace_update_params.py @@ -8,7 +8,7 @@ class NamespaceUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" title: Required[str] diff --git a/src/cloudflare/types/kv/namespaces/key_bulk_delete_params.py b/src/cloudflare/types/kv/namespaces/key_bulk_delete_params.py index 4ca950ad537..522f5ae7585 100644 --- a/src/cloudflare/types/kv/namespaces/key_bulk_delete_params.py +++ b/src/cloudflare/types/kv/namespaces/key_bulk_delete_params.py @@ -10,7 +10,7 @@ class KeyBulkDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" body: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/kv/namespaces/key_bulk_get_params.py b/src/cloudflare/types/kv/namespaces/key_bulk_get_params.py index 807dcd6a7f6..f978cb2bf6d 100644 --- a/src/cloudflare/types/kv/namespaces/key_bulk_get_params.py +++ b/src/cloudflare/types/kv/namespaces/key_bulk_get_params.py @@ -11,7 +11,7 @@ class KeyBulkGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" keys: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/kv/namespaces/key_bulk_update_params.py b/src/cloudflare/types/kv/namespaces/key_bulk_update_params.py index e7a48702ec1..4339061b8b8 100644 --- a/src/cloudflare/types/kv/namespaces/key_bulk_update_params.py +++ b/src/cloudflare/types/kv/namespaces/key_bulk_update_params.py @@ -9,7 +9,7 @@ class KeyBulkUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/kv/namespaces/key_list_params.py b/src/cloudflare/types/kv/namespaces/key_list_params.py index 804e1ee1c56..0914506952d 100644 --- a/src/cloudflare/types/kv/namespaces/key_list_params.py +++ b/src/cloudflare/types/kv/namespaces/key_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["KeyListParams"] class KeyListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" cursor: str diff --git a/src/cloudflare/types/kv/namespaces/value_update_params.py b/src/cloudflare/types/kv/namespaces/value_update_params.py index 320a496f11c..ccebae68bbf 100644 --- a/src/cloudflare/types/kv/namespaces/value_update_params.py +++ b/src/cloudflare/types/kv/namespaces/value_update_params.py @@ -11,7 +11,7 @@ class ValueUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" namespace_id: Required[str] diff --git a/src/cloudflare/types/leaked_credential_checks/detection_create_params.py b/src/cloudflare/types/leaked_credential_checks/detection_create_params.py index 4aa1306de9c..63051b483f0 100644 --- a/src/cloudflare/types/leaked_credential_checks/detection_create_params.py +++ b/src/cloudflare/types/leaked_credential_checks/detection_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DetectionCreateParams"] class DetectionCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" password: str diff --git a/src/cloudflare/types/leaked_credential_checks/detection_update_params.py b/src/cloudflare/types/leaked_credential_checks/detection_update_params.py index b89243110b3..72e0b69b0d8 100644 --- a/src/cloudflare/types/leaked_credential_checks/detection_update_params.py +++ b/src/cloudflare/types/leaked_credential_checks/detection_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DetectionUpdateParams"] class DetectionUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" password: str diff --git a/src/cloudflare/types/leaked_credential_checks/leaked_credential_check_create_params.py b/src/cloudflare/types/leaked_credential_checks/leaked_credential_check_create_params.py index 3e89ee960d5..bab18811219 100644 --- a/src/cloudflare/types/leaked_credential_checks/leaked_credential_check_create_params.py +++ b/src/cloudflare/types/leaked_credential_checks/leaked_credential_check_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["LeakedCredentialCheckCreateParams"] class LeakedCredentialCheckCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" enabled: bool diff --git a/src/cloudflare/types/load_balancers/load_balancer_create_params.py b/src/cloudflare/types/load_balancers/load_balancer_create_params.py index 39dcc94d3d3..65470830e70 100644 --- a/src/cloudflare/types/load_balancers/load_balancer_create_params.py +++ b/src/cloudflare/types/load_balancers/load_balancer_create_params.py @@ -19,7 +19,7 @@ class LoadBalancerCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str default_pools: Required[SequenceNotStr[DefaultPools]] """A list of pool IDs ordered by their failover priority. diff --git a/src/cloudflare/types/load_balancers/load_balancer_edit_params.py b/src/cloudflare/types/load_balancers/load_balancer_edit_params.py index 88da48c58e3..bf49036e0b3 100644 --- a/src/cloudflare/types/load_balancers/load_balancer_edit_params.py +++ b/src/cloudflare/types/load_balancers/load_balancer_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr from .rules_param import RulesParam @@ -19,7 +19,7 @@ class LoadBalancerEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str adaptive_routing: AdaptiveRoutingParam """ diff --git a/src/cloudflare/types/load_balancers/load_balancer_update_params.py b/src/cloudflare/types/load_balancers/load_balancer_update_params.py index 0908929cb3e..8576639eedc 100644 --- a/src/cloudflare/types/load_balancers/load_balancer_update_params.py +++ b/src/cloudflare/types/load_balancers/load_balancer_update_params.py @@ -19,7 +19,7 @@ class LoadBalancerUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str default_pools: Required[SequenceNotStr[DefaultPools]] """A list of pool IDs ordered by their failover priority. diff --git a/src/cloudflare/types/load_balancers/monitor_create_params.py b/src/cloudflare/types/load_balancers/monitor_create_params.py index b68e28a1226..5dddeacf779 100644 --- a/src/cloudflare/types/load_balancers/monitor_create_params.py +++ b/src/cloudflare/types/load_balancers/monitor_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class MonitorCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" allow_insecure: bool diff --git a/src/cloudflare/types/load_balancers/monitor_edit_params.py b/src/cloudflare/types/load_balancers/monitor_edit_params.py index e826841b064..b96dc8f1aef 100644 --- a/src/cloudflare/types/load_balancers/monitor_edit_params.py +++ b/src/cloudflare/types/load_balancers/monitor_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class MonitorEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" allow_insecure: bool diff --git a/src/cloudflare/types/load_balancers/monitor_group_create_params.py b/src/cloudflare/types/load_balancers/monitor_group_create_params.py index 0d9b6714ddd..c1ca537ceef 100644 --- a/src/cloudflare/types/load_balancers/monitor_group_create_params.py +++ b/src/cloudflare/types/load_balancers/monitor_group_create_params.py @@ -9,7 +9,7 @@ class MonitorGroupCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" id: Required[str] diff --git a/src/cloudflare/types/load_balancers/monitor_group_edit_params.py b/src/cloudflare/types/load_balancers/monitor_group_edit_params.py index 212f85f5360..8fbc9d8e28d 100644 --- a/src/cloudflare/types/load_balancers/monitor_group_edit_params.py +++ b/src/cloudflare/types/load_balancers/monitor_group_edit_params.py @@ -9,7 +9,7 @@ class MonitorGroupEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" id: Required[str] diff --git a/src/cloudflare/types/load_balancers/monitor_group_update_params.py b/src/cloudflare/types/load_balancers/monitor_group_update_params.py index 9122012730b..13d183a5a4e 100644 --- a/src/cloudflare/types/load_balancers/monitor_group_update_params.py +++ b/src/cloudflare/types/load_balancers/monitor_group_update_params.py @@ -9,7 +9,7 @@ class MonitorGroupUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" id: Required[str] diff --git a/src/cloudflare/types/load_balancers/monitor_update_params.py b/src/cloudflare/types/load_balancers/monitor_update_params.py index 77c2394d060..b24b574a4bf 100644 --- a/src/cloudflare/types/load_balancers/monitor_update_params.py +++ b/src/cloudflare/types/load_balancers/monitor_update_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class MonitorUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" allow_insecure: bool diff --git a/src/cloudflare/types/load_balancers/monitors/preview_create_params.py b/src/cloudflare/types/load_balancers/monitors/preview_create_params.py index c9a8d5b7b68..2e2cdbbb7cc 100644 --- a/src/cloudflare/types/load_balancers/monitors/preview_create_params.py +++ b/src/cloudflare/types/load_balancers/monitors/preview_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class PreviewCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" allow_insecure: bool diff --git a/src/cloudflare/types/load_balancers/pool_bulk_edit_params.py b/src/cloudflare/types/load_balancers/pool_bulk_edit_params.py index af6bc6635c8..3d838087463 100644 --- a/src/cloudflare/types/load_balancers/pool_bulk_edit_params.py +++ b/src/cloudflare/types/load_balancers/pool_bulk_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["PoolBulkEditParams"] class PoolBulkEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" notification_email: Literal[""] diff --git a/src/cloudflare/types/load_balancers/pool_create_params.py b/src/cloudflare/types/load_balancers/pool_create_params.py index 08779830381..6e86952dd1c 100644 --- a/src/cloudflare/types/load_balancers/pool_create_params.py +++ b/src/cloudflare/types/load_balancers/pool_create_params.py @@ -14,7 +14,7 @@ class PoolCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/load_balancers/pool_edit_params.py b/src/cloudflare/types/load_balancers/pool_edit_params.py index e3f89941084..6b5257d99f8 100644 --- a/src/cloudflare/types/load_balancers/pool_edit_params.py +++ b/src/cloudflare/types/load_balancers/pool_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List, Iterable, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from .check_region import CheckRegion from .origin_param import OriginParam @@ -15,7 +15,7 @@ class PoolEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" check_regions: Optional[List[CheckRegion]] diff --git a/src/cloudflare/types/load_balancers/pool_list_params.py b/src/cloudflare/types/load_balancers/pool_list_params.py index 35367c51396..5c2f6673a2d 100644 --- a/src/cloudflare/types/load_balancers/pool_list_params.py +++ b/src/cloudflare/types/load_balancers/pool_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PoolListParams"] class PoolListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" monitor: str diff --git a/src/cloudflare/types/load_balancers/pool_update_params.py b/src/cloudflare/types/load_balancers/pool_update_params.py index bfcf15e6b84..c5b35c8d7a8 100644 --- a/src/cloudflare/types/load_balancers/pool_update_params.py +++ b/src/cloudflare/types/load_balancers/pool_update_params.py @@ -15,7 +15,7 @@ class PoolUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/load_balancers/pools/health_create_params.py b/src/cloudflare/types/load_balancers/pools/health_create_params.py index 4cc0852bba0..f71a9cd8a79 100644 --- a/src/cloudflare/types/load_balancers/pools/health_create_params.py +++ b/src/cloudflare/types/load_balancers/pools/health_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class HealthCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" allow_insecure: bool diff --git a/src/cloudflare/types/load_balancers/region_list_params.py b/src/cloudflare/types/load_balancers/region_list_params.py index 8dbdd2156b8..a6a8751f157 100644 --- a/src/cloudflare/types/load_balancers/region_list_params.py +++ b/src/cloudflare/types/load_balancers/region_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["RegionListParams"] class RegionListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" country_code_a2: str diff --git a/src/cloudflare/types/load_balancers/search_list_params.py b/src/cloudflare/types/load_balancers/search_list_params.py index 73c63622446..9d10e2f5b56 100644 --- a/src/cloudflare/types/load_balancers/search_list_params.py +++ b/src/cloudflare/types/load_balancers/search_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["SearchListParams"] class SearchListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: float diff --git a/src/cloudflare/types/logpush/edge_create_params.py b/src/cloudflare/types/logpush/edge_create_params.py index 339abcf0286..27ae9e7609c 100644 --- a/src/cloudflare/types/logpush/edge_create_params.py +++ b/src/cloudflare/types/logpush/edge_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["EdgeCreateParams"] class EdgeCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" fields: str diff --git a/src/cloudflare/types/logs/control/cmb/config_create_params.py b/src/cloudflare/types/logs/control/cmb/config_create_params.py index 4fb77a53222..2a7d6621af2 100644 --- a/src/cloudflare/types/logs/control/cmb/config_create_params.py +++ b/src/cloudflare/types/logs/control/cmb/config_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ConfigCreateParams"] class ConfigCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" allow_out_of_region_access: bool diff --git a/src/cloudflare/types/logs/control/retention_create_params.py b/src/cloudflare/types/logs/control/retention_create_params.py index 7d14eaf90f6..ce89e881a72 100644 --- a/src/cloudflare/types/logs/control/retention_create_params.py +++ b/src/cloudflare/types/logs/control/retention_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["RetentionCreateParams"] class RetentionCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" flag: bool diff --git a/src/cloudflare/types/logs/rayid_get_params.py b/src/cloudflare/types/logs/rayid_get_params.py index d80a596c1a4..2c6d1b19f81 100644 --- a/src/cloudflare/types/logs/rayid_get_params.py +++ b/src/cloudflare/types/logs/rayid_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["RayIDGetParams"] class RayIDGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" fields: str diff --git a/src/cloudflare/types/logs/received_get_params.py b/src/cloudflare/types/logs/received_get_params.py index 859b062c5a4..afe8a96c6a5 100644 --- a/src/cloudflare/types/logs/received_get_params.py +++ b/src/cloudflare/types/logs/received_get_params.py @@ -9,7 +9,7 @@ class ReceivedGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" end: Required[Union[str, int]] diff --git a/src/cloudflare/types/magic_cloud_networking/catalog_sync_create_params.py b/src/cloudflare/types/magic_cloud_networking/catalog_sync_create_params.py index 18c8dd7a081..cf1851eb702 100644 --- a/src/cloudflare/types/magic_cloud_networking/catalog_sync_create_params.py +++ b/src/cloudflare/types/magic_cloud_networking/catalog_sync_create_params.py @@ -8,7 +8,7 @@ class CatalogSyncCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str destination_type: Required[Literal["NONE", "ZERO_TRUST_LIST"]] diff --git a/src/cloudflare/types/magic_cloud_networking/catalog_sync_delete_params.py b/src/cloudflare/types/magic_cloud_networking/catalog_sync_delete_params.py index b8422d6eef9..d3f1be943e1 100644 --- a/src/cloudflare/types/magic_cloud_networking/catalog_sync_delete_params.py +++ b/src/cloudflare/types/magic_cloud_networking/catalog_sync_delete_params.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CatalogSyncDeleteParams"] class CatalogSyncDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str delete_destination: bool diff --git a/src/cloudflare/types/magic_cloud_networking/catalog_sync_edit_params.py b/src/cloudflare/types/magic_cloud_networking/catalog_sync_edit_params.py index 4d4c617d89a..7bab333f808 100644 --- a/src/cloudflare/types/magic_cloud_networking/catalog_sync_edit_params.py +++ b/src/cloudflare/types/magic_cloud_networking/catalog_sync_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["CatalogSyncEditParams"] class CatalogSyncEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str description: str diff --git a/src/cloudflare/types/magic_cloud_networking/catalog_sync_update_params.py b/src/cloudflare/types/magic_cloud_networking/catalog_sync_update_params.py index b3503d5f411..eb4e3f376d6 100644 --- a/src/cloudflare/types/magic_cloud_networking/catalog_sync_update_params.py +++ b/src/cloudflare/types/magic_cloud_networking/catalog_sync_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["CatalogSyncUpdateParams"] class CatalogSyncUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str description: str diff --git a/src/cloudflare/types/magic_cloud_networking/catalog_syncs/prebuilt_policy_list_params.py b/src/cloudflare/types/magic_cloud_networking/catalog_syncs/prebuilt_policy_list_params.py index d13cde44409..eab714d7aea 100644 --- a/src/cloudflare/types/magic_cloud_networking/catalog_syncs/prebuilt_policy_list_params.py +++ b/src/cloudflare/types/magic_cloud_networking/catalog_syncs/prebuilt_policy_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["PrebuiltPolicyListParams"] class PrebuiltPolicyListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str destination_type: Literal["NONE", "ZERO_TRUST_LIST"] """Specify type of destination, omit to return all.""" diff --git a/src/cloudflare/types/magic_cloud_networking/cloud_integration_create_params.py b/src/cloudflare/types/magic_cloud_networking/cloud_integration_create_params.py index 066d1a6d3bd..5881c5c470a 100644 --- a/src/cloudflare/types/magic_cloud_networking/cloud_integration_create_params.py +++ b/src/cloudflare/types/magic_cloud_networking/cloud_integration_create_params.py @@ -8,7 +8,7 @@ class CloudIntegrationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str cloud_type: Required[Literal["AWS", "AZURE", "GOOGLE", "CLOUDFLARE"]] diff --git a/src/cloudflare/types/magic_cloud_networking/cloud_integration_discover_params.py b/src/cloudflare/types/magic_cloud_networking/cloud_integration_discover_params.py index f54258bfcbe..aa9d3fd7121 100644 --- a/src/cloudflare/types/magic_cloud_networking/cloud_integration_discover_params.py +++ b/src/cloudflare/types/magic_cloud_networking/cloud_integration_discover_params.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CloudIntegrationDiscoverParams"] class CloudIntegrationDiscoverParams(TypedDict, total=False): - account_id: Required[str] + account_id: str v2: bool diff --git a/src/cloudflare/types/magic_cloud_networking/cloud_integration_edit_params.py b/src/cloudflare/types/magic_cloud_networking/cloud_integration_edit_params.py index e069ee25408..c61e0dc37bf 100644 --- a/src/cloudflare/types/magic_cloud_networking/cloud_integration_edit_params.py +++ b/src/cloudflare/types/magic_cloud_networking/cloud_integration_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CloudIntegrationEditParams"] class CloudIntegrationEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str aws_arn: str diff --git a/src/cloudflare/types/magic_cloud_networking/cloud_integration_get_params.py b/src/cloudflare/types/magic_cloud_networking/cloud_integration_get_params.py index 4a26230bc6f..351552b3b11 100644 --- a/src/cloudflare/types/magic_cloud_networking/cloud_integration_get_params.py +++ b/src/cloudflare/types/magic_cloud_networking/cloud_integration_get_params.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CloudIntegrationGetParams"] class CloudIntegrationGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str status: bool diff --git a/src/cloudflare/types/magic_cloud_networking/cloud_integration_list_params.py b/src/cloudflare/types/magic_cloud_networking/cloud_integration_list_params.py index 94bead9742a..44ccaa4ee44 100644 --- a/src/cloudflare/types/magic_cloud_networking/cloud_integration_list_params.py +++ b/src/cloudflare/types/magic_cloud_networking/cloud_integration_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CloudIntegrationListParams"] class CloudIntegrationListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str cloudflare: bool diff --git a/src/cloudflare/types/magic_cloud_networking/cloud_integration_update_params.py b/src/cloudflare/types/magic_cloud_networking/cloud_integration_update_params.py index 9321e19b5d8..474e6389a70 100644 --- a/src/cloudflare/types/magic_cloud_networking/cloud_integration_update_params.py +++ b/src/cloudflare/types/magic_cloud_networking/cloud_integration_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CloudIntegrationUpdateParams"] class CloudIntegrationUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str aws_arn: str diff --git a/src/cloudflare/types/magic_cloud_networking/on_ramp_create_params.py b/src/cloudflare/types/magic_cloud_networking/on_ramp_create_params.py index 2893b07cfec..e4d908708cc 100644 --- a/src/cloudflare/types/magic_cloud_networking/on_ramp_create_params.py +++ b/src/cloudflare/types/magic_cloud_networking/on_ramp_create_params.py @@ -10,7 +10,7 @@ class OnRampCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str cloud_type: Required[Literal["AWS", "AZURE", "GOOGLE"]] diff --git a/src/cloudflare/types/magic_cloud_networking/on_ramp_delete_params.py b/src/cloudflare/types/magic_cloud_networking/on_ramp_delete_params.py index 6ace6d226de..e1a84679631 100644 --- a/src/cloudflare/types/magic_cloud_networking/on_ramp_delete_params.py +++ b/src/cloudflare/types/magic_cloud_networking/on_ramp_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["OnRampDeleteParams"] class OnRampDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str destroy: bool diff --git a/src/cloudflare/types/magic_cloud_networking/on_ramp_edit_params.py b/src/cloudflare/types/magic_cloud_networking/on_ramp_edit_params.py index 04cb0a141e5..c090a078955 100644 --- a/src/cloudflare/types/magic_cloud_networking/on_ramp_edit_params.py +++ b/src/cloudflare/types/magic_cloud_networking/on_ramp_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class OnRampEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str attached_hubs: SequenceNotStr[str] diff --git a/src/cloudflare/types/magic_cloud_networking/on_ramp_get_params.py b/src/cloudflare/types/magic_cloud_networking/on_ramp_get_params.py index b3c8a9df5a2..4d1d34abafc 100644 --- a/src/cloudflare/types/magic_cloud_networking/on_ramp_get_params.py +++ b/src/cloudflare/types/magic_cloud_networking/on_ramp_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["OnRampGetParams"] class OnRampGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str planned_resources: bool diff --git a/src/cloudflare/types/magic_cloud_networking/on_ramp_list_params.py b/src/cloudflare/types/magic_cloud_networking/on_ramp_list_params.py index b7c660ad5c4..da82c3a2f7b 100644 --- a/src/cloudflare/types/magic_cloud_networking/on_ramp_list_params.py +++ b/src/cloudflare/types/magic_cloud_networking/on_ramp_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["OnRampListParams"] class OnRampListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str desc: bool diff --git a/src/cloudflare/types/magic_cloud_networking/on_ramp_update_params.py b/src/cloudflare/types/magic_cloud_networking/on_ramp_update_params.py index bbcd6aae218..b95345fb37b 100644 --- a/src/cloudflare/types/magic_cloud_networking/on_ramp_update_params.py +++ b/src/cloudflare/types/magic_cloud_networking/on_ramp_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class OnRampUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str attached_hubs: SequenceNotStr[str] diff --git a/src/cloudflare/types/magic_cloud_networking/on_ramps/address_space_edit_params.py b/src/cloudflare/types/magic_cloud_networking/on_ramps/address_space_edit_params.py index 09fc69ad5fa..3373cd8ae46 100644 --- a/src/cloudflare/types/magic_cloud_networking/on_ramps/address_space_edit_params.py +++ b/src/cloudflare/types/magic_cloud_networking/on_ramps/address_space_edit_params.py @@ -10,6 +10,6 @@ class AddressSpaceEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str prefixes: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/magic_cloud_networking/on_ramps/address_space_update_params.py b/src/cloudflare/types/magic_cloud_networking/on_ramps/address_space_update_params.py index ed1ef67b196..be7bd19b1f7 100644 --- a/src/cloudflare/types/magic_cloud_networking/on_ramps/address_space_update_params.py +++ b/src/cloudflare/types/magic_cloud_networking/on_ramps/address_space_update_params.py @@ -10,6 +10,6 @@ class AddressSpaceUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str prefixes: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/magic_cloud_networking/resource_export_params.py b/src/cloudflare/types/magic_cloud_networking/resource_export_params.py index 73d6753fcc2..4fa80ae90af 100644 --- a/src/cloudflare/types/magic_cloud_networking/resource_export_params.py +++ b/src/cloudflare/types/magic_cloud_networking/resource_export_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -11,7 +11,7 @@ class ResourceExportParams(TypedDict, total=False): - account_id: Required[str] + account_id: str desc: bool diff --git a/src/cloudflare/types/magic_cloud_networking/resource_get_params.py b/src/cloudflare/types/magic_cloud_networking/resource_get_params.py index e3f392e392a..24e9a01f861 100644 --- a/src/cloudflare/types/magic_cloud_networking/resource_get_params.py +++ b/src/cloudflare/types/magic_cloud_networking/resource_get_params.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ResourceGetParams"] class ResourceGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str v2: bool diff --git a/src/cloudflare/types/magic_cloud_networking/resource_list_params.py b/src/cloudflare/types/magic_cloud_networking/resource_list_params.py index d48313a1b22..95edf7d2d94 100644 --- a/src/cloudflare/types/magic_cloud_networking/resource_list_params.py +++ b/src/cloudflare/types/magic_cloud_networking/resource_list_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -11,7 +11,7 @@ class ResourceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str cloudflare: bool diff --git a/src/cloudflare/types/magic_cloud_networking/resource_policy_preview_params.py b/src/cloudflare/types/magic_cloud_networking/resource_policy_preview_params.py index 81c74c2fef6..132050189e7 100644 --- a/src/cloudflare/types/magic_cloud_networking/resource_policy_preview_params.py +++ b/src/cloudflare/types/magic_cloud_networking/resource_policy_preview_params.py @@ -8,6 +8,6 @@ class ResourcePolicyPreviewParams(TypedDict, total=False): - account_id: Required[str] + account_id: str policy: Required[str] diff --git a/src/cloudflare/types/magic_network_monitoring/config_create_params.py b/src/cloudflare/types/magic_network_monitoring/config_create_params.py index c6736af91a2..b14c8fd4ee0 100644 --- a/src/cloudflare/types/magic_network_monitoring/config_create_params.py +++ b/src/cloudflare/types/magic_network_monitoring/config_create_params.py @@ -11,7 +11,7 @@ class ConfigCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str default_sampling: Required[float] """Fallback sampling rate of flow messages being sent in packets per second. diff --git a/src/cloudflare/types/magic_network_monitoring/config_edit_params.py b/src/cloudflare/types/magic_network_monitoring/config_edit_params.py index 4248ff62f9d..53175b7822e 100644 --- a/src/cloudflare/types/magic_network_monitoring/config_edit_params.py +++ b/src/cloudflare/types/magic_network_monitoring/config_edit_params.py @@ -11,7 +11,7 @@ class ConfigEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str default_sampling: float """Fallback sampling rate of flow messages being sent in packets per second. diff --git a/src/cloudflare/types/magic_network_monitoring/config_update_params.py b/src/cloudflare/types/magic_network_monitoring/config_update_params.py index 04530d1c37a..2102b658128 100644 --- a/src/cloudflare/types/magic_network_monitoring/config_update_params.py +++ b/src/cloudflare/types/magic_network_monitoring/config_update_params.py @@ -11,7 +11,7 @@ class ConfigUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str default_sampling: Required[float] """Fallback sampling rate of flow messages being sent in packets per second. diff --git a/src/cloudflare/types/magic_network_monitoring/rule_create_params.py b/src/cloudflare/types/magic_network_monitoring/rule_create_params.py index 52508e9e9c6..da89855d6e6 100644 --- a/src/cloudflare/types/magic_network_monitoring/rule_create_params.py +++ b/src/cloudflare/types/magic_network_monitoring/rule_create_params.py @@ -11,7 +11,7 @@ class RuleCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str automatic_advertisement: Required[Optional[bool]] """ diff --git a/src/cloudflare/types/magic_network_monitoring/rule_edit_params.py b/src/cloudflare/types/magic_network_monitoring/rule_edit_params.py index f446992f9f5..7d8692467f1 100644 --- a/src/cloudflare/types/magic_network_monitoring/rule_edit_params.py +++ b/src/cloudflare/types/magic_network_monitoring/rule_edit_params.py @@ -11,7 +11,7 @@ class RuleEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str automatic_advertisement: Required[Optional[bool]] """ diff --git a/src/cloudflare/types/magic_network_monitoring/rule_update_params.py b/src/cloudflare/types/magic_network_monitoring/rule_update_params.py index a20cd0e2800..aa67dff760c 100644 --- a/src/cloudflare/types/magic_network_monitoring/rule_update_params.py +++ b/src/cloudflare/types/magic_network_monitoring/rule_update_params.py @@ -11,7 +11,7 @@ class RuleUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str automatic_advertisement: Required[Optional[bool]] """ diff --git a/src/cloudflare/types/magic_network_monitoring/rules/advertisement_edit_params.py b/src/cloudflare/types/magic_network_monitoring/rules/advertisement_edit_params.py index ece6f001327..7ac6aac7182 100644 --- a/src/cloudflare/types/magic_network_monitoring/rules/advertisement_edit_params.py +++ b/src/cloudflare/types/magic_network_monitoring/rules/advertisement_edit_params.py @@ -8,6 +8,6 @@ class AdvertisementEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[object] diff --git a/src/cloudflare/types/magic_transit/app_create_params.py b/src/cloudflare/types/magic_transit/app_create_params.py index 33512d9db4e..12be828243a 100644 --- a/src/cloudflare/types/magic_transit/app_create_params.py +++ b/src/cloudflare/types/magic_transit/app_create_params.py @@ -10,7 +10,7 @@ class AppCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" name: Required[str] diff --git a/src/cloudflare/types/magic_transit/app_edit_params.py b/src/cloudflare/types/magic_transit/app_edit_params.py index c9702e77697..16ed1b5df1f 100644 --- a/src/cloudflare/types/magic_transit/app_edit_params.py +++ b/src/cloudflare/types/magic_transit/app_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class AppEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" hostnames: SequenceNotStr[str] diff --git a/src/cloudflare/types/magic_transit/app_update_params.py b/src/cloudflare/types/magic_transit/app_update_params.py index 4af8c5f1a63..049137bea7d 100644 --- a/src/cloudflare/types/magic_transit/app_update_params.py +++ b/src/cloudflare/types/magic_transit/app_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class AppUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" hostnames: SequenceNotStr[str] diff --git a/src/cloudflare/types/magic_transit/cf_interconnect_bulk_update_params.py b/src/cloudflare/types/magic_transit/cf_interconnect_bulk_update_params.py index ab9e94f12de..215ae0a3e89 100644 --- a/src/cloudflare/types/magic_transit/cf_interconnect_bulk_update_params.py +++ b/src/cloudflare/types/magic_transit/cf_interconnect_bulk_update_params.py @@ -10,7 +10,7 @@ class CfInterconnectBulkUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" body: Required[object] diff --git a/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py b/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py index dea0aabfdeb..1848ca46ce7 100644 --- a/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py +++ b/src/cloudflare/types/magic_transit/cf_interconnect_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo from .health_check_param import HealthCheckParam @@ -11,7 +11,7 @@ class CfInterconnectUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" automatic_return_routing: bool diff --git a/src/cloudflare/types/magic_transit/connector_create_params.py b/src/cloudflare/types/magic_transit/connector_create_params.py index 8ada6bdf956..3f44971637e 100644 --- a/src/cloudflare/types/magic_transit/connector_create_params.py +++ b/src/cloudflare/types/magic_transit/connector_create_params.py @@ -11,7 +11,7 @@ class ConnectorCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" device: Required[Device] diff --git a/src/cloudflare/types/magic_transit/connector_edit_params.py b/src/cloudflare/types/magic_transit/connector_edit_params.py index 56b44c01e3d..6379bcda7d4 100644 --- a/src/cloudflare/types/magic_transit/connector_edit_params.py +++ b/src/cloudflare/types/magic_transit/connector_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -11,7 +11,7 @@ class ConnectorEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" activated: bool diff --git a/src/cloudflare/types/magic_transit/connector_update_params.py b/src/cloudflare/types/magic_transit/connector_update_params.py index 9b046f584cc..3f0981eed37 100644 --- a/src/cloudflare/types/magic_transit/connector_update_params.py +++ b/src/cloudflare/types/magic_transit/connector_update_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -11,7 +11,7 @@ class ConnectorUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" activated: bool diff --git a/src/cloudflare/types/magic_transit/connectors/event_list_params.py b/src/cloudflare/types/magic_transit/connectors/event_list_params.py index b8ba2917823..a16ed7d0a75 100644 --- a/src/cloudflare/types/magic_transit/connectors/event_list_params.py +++ b/src/cloudflare/types/magic_transit/connectors/event_list_params.py @@ -10,7 +10,7 @@ class EventListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" from_: Required[Annotated[float, PropertyInfo(alias="from")]] diff --git a/src/cloudflare/types/magic_transit/connectors/snapshot_list_params.py b/src/cloudflare/types/magic_transit/connectors/snapshot_list_params.py index b2c9a69b3a6..693d36aceb1 100644 --- a/src/cloudflare/types/magic_transit/connectors/snapshot_list_params.py +++ b/src/cloudflare/types/magic_transit/connectors/snapshot_list_params.py @@ -10,7 +10,7 @@ class SnapshotListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" from_: Required[Annotated[float, PropertyInfo(alias="from")]] diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_bulk_update_params.py b/src/cloudflare/types/magic_transit/gre_tunnel_bulk_update_params.py index 652e4f41702..c4d426e717c 100644 --- a/src/cloudflare/types/magic_transit/gre_tunnel_bulk_update_params.py +++ b/src/cloudflare/types/magic_transit/gre_tunnel_bulk_update_params.py @@ -10,7 +10,7 @@ class GRETunnelBulkUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" body: Required[object] diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_create_params.py b/src/cloudflare/types/magic_transit/gre_tunnel_create_params.py index 2e8e4a5b8e8..9f06fa59db8 100644 --- a/src/cloudflare/types/magic_transit/gre_tunnel_create_params.py +++ b/src/cloudflare/types/magic_transit/gre_tunnel_create_params.py @@ -20,7 +20,7 @@ class GRETunnelCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" cloudflare_gre_endpoint: Required[str] diff --git a/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py b/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py index 0081115a1d3..20e82286f02 100644 --- a/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py +++ b/src/cloudflare/types/magic_transit/gre_tunnel_update_params.py @@ -13,7 +13,7 @@ class GRETunnelUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" cloudflare_gre_endpoint: Required[str] diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_bulk_update_params.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_bulk_update_params.py index c35b7181e30..21878c492f1 100644 --- a/src/cloudflare/types/magic_transit/ipsec_tunnel_bulk_update_params.py +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_bulk_update_params.py @@ -10,7 +10,7 @@ class IPSECTunnelBulkUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" body: Required[object] diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_create_params.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_create_params.py index 1b6171df8e7..5015126da33 100644 --- a/src/cloudflare/types/magic_transit/ipsec_tunnel_create_params.py +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_create_params.py @@ -21,7 +21,7 @@ class IPSECTunnelCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" cloudflare_endpoint: Required[str] diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_params.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_params.py index 1066fa603d1..c2c4ae714f2 100644 --- a/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_params.py +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_psk_generate_params.py @@ -8,7 +8,7 @@ class IPSECTunnelPSKGenerateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" body: Required[object] diff --git a/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py index 459e55c76ed..1c7b84e6b4e 100644 --- a/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py +++ b/src/cloudflare/types/magic_transit/ipsec_tunnel_update_params.py @@ -21,7 +21,7 @@ class IPSECTunnelUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" cloudflare_endpoint: Required[str] diff --git a/src/cloudflare/types/magic_transit/pcap_create_params.py b/src/cloudflare/types/magic_transit/pcap_create_params.py index 9f45d7a7416..b0b1a4b7424 100644 --- a/src/cloudflare/types/magic_transit/pcap_create_params.py +++ b/src/cloudflare/types/magic_transit/pcap_create_params.py @@ -13,7 +13,7 @@ class MagicVisibilityPCAPsPCAPsRequestSimple(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" packet_limit: Required[float] @@ -44,7 +44,7 @@ class MagicVisibilityPCAPsPCAPsRequestSimple(TypedDict, total=False): class MagicVisibilityPCAPsPCAPsRequestFull(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" colo_name: Required[str] diff --git a/src/cloudflare/types/magic_transit/pcaps/ownership_create_params.py b/src/cloudflare/types/magic_transit/pcaps/ownership_create_params.py index 88697315303..564013fafe4 100644 --- a/src/cloudflare/types/magic_transit/pcaps/ownership_create_params.py +++ b/src/cloudflare/types/magic_transit/pcaps/ownership_create_params.py @@ -8,7 +8,7 @@ class OwnershipCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" destination_conf: Required[str] diff --git a/src/cloudflare/types/magic_transit/pcaps/ownership_validate_params.py b/src/cloudflare/types/magic_transit/pcaps/ownership_validate_params.py index 9e8b16ef326..f25d1516f08 100644 --- a/src/cloudflare/types/magic_transit/pcaps/ownership_validate_params.py +++ b/src/cloudflare/types/magic_transit/pcaps/ownership_validate_params.py @@ -8,7 +8,7 @@ class OwnershipValidateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" destination_conf: Required[str] diff --git a/src/cloudflare/types/magic_transit/route_bulk_update_params.py b/src/cloudflare/types/magic_transit/route_bulk_update_params.py index 9fe9f18041d..49008db4b0d 100644 --- a/src/cloudflare/types/magic_transit/route_bulk_update_params.py +++ b/src/cloudflare/types/magic_transit/route_bulk_update_params.py @@ -11,7 +11,7 @@ class RouteBulkUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" routes: Required[Iterable[Route]] diff --git a/src/cloudflare/types/magic_transit/route_create_params.py b/src/cloudflare/types/magic_transit/route_create_params.py index 44f903dc099..60f436eafa5 100644 --- a/src/cloudflare/types/magic_transit/route_create_params.py +++ b/src/cloudflare/types/magic_transit/route_create_params.py @@ -10,7 +10,7 @@ class RouteCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" nexthop: Required[str] diff --git a/src/cloudflare/types/magic_transit/route_update_params.py b/src/cloudflare/types/magic_transit/route_update_params.py index 14d10ad42c0..a54ecd0d8e9 100644 --- a/src/cloudflare/types/magic_transit/route_update_params.py +++ b/src/cloudflare/types/magic_transit/route_update_params.py @@ -10,7 +10,7 @@ class RouteUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" nexthop: Required[str] diff --git a/src/cloudflare/types/magic_transit/site_create_params.py b/src/cloudflare/types/magic_transit/site_create_params.py index 70a64bc5406..570a4a6475a 100644 --- a/src/cloudflare/types/magic_transit/site_create_params.py +++ b/src/cloudflare/types/magic_transit/site_create_params.py @@ -10,7 +10,7 @@ class SiteCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" name: Required[str] diff --git a/src/cloudflare/types/magic_transit/site_edit_params.py b/src/cloudflare/types/magic_transit/site_edit_params.py index eef65820c0b..d7f5db5a9f2 100644 --- a/src/cloudflare/types/magic_transit/site_edit_params.py +++ b/src/cloudflare/types/magic_transit/site_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from .site_location_param import SiteLocationParam @@ -10,7 +10,7 @@ class SiteEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" connector_id: str diff --git a/src/cloudflare/types/magic_transit/site_list_params.py b/src/cloudflare/types/magic_transit/site_list_params.py index d446c2a2809..88f6947310d 100644 --- a/src/cloudflare/types/magic_transit/site_list_params.py +++ b/src/cloudflare/types/magic_transit/site_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SiteListParams"] class SiteListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" connectorid: str diff --git a/src/cloudflare/types/magic_transit/site_update_params.py b/src/cloudflare/types/magic_transit/site_update_params.py index 4568612636c..27aab123ac6 100644 --- a/src/cloudflare/types/magic_transit/site_update_params.py +++ b/src/cloudflare/types/magic_transit/site_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from .site_location_param import SiteLocationParam @@ -10,7 +10,7 @@ class SiteUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" connector_id: str diff --git a/src/cloudflare/types/magic_transit/sites/acl_create_params.py b/src/cloudflare/types/magic_transit/sites/acl_create_params.py index c193c6d556c..7b57a3accb3 100644 --- a/src/cloudflare/types/magic_transit/sites/acl_create_params.py +++ b/src/cloudflare/types/magic_transit/sites/acl_create_params.py @@ -12,7 +12,7 @@ class ACLCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" lan_1: Required[ACLConfigurationParam] diff --git a/src/cloudflare/types/magic_transit/sites/acl_edit_params.py b/src/cloudflare/types/magic_transit/sites/acl_edit_params.py index 3280bbe53b2..0e7046c1a39 100644 --- a/src/cloudflare/types/magic_transit/sites/acl_edit_params.py +++ b/src/cloudflare/types/magic_transit/sites/acl_edit_params.py @@ -12,7 +12,7 @@ class ACLEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" site_id: Required[str] diff --git a/src/cloudflare/types/magic_transit/sites/acl_update_params.py b/src/cloudflare/types/magic_transit/sites/acl_update_params.py index 250ed85c126..0c7c3e79660 100644 --- a/src/cloudflare/types/magic_transit/sites/acl_update_params.py +++ b/src/cloudflare/types/magic_transit/sites/acl_update_params.py @@ -12,7 +12,7 @@ class ACLUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" site_id: Required[str] diff --git a/src/cloudflare/types/magic_transit/sites/lan_create_params.py b/src/cloudflare/types/magic_transit/sites/lan_create_params.py index ba7ea87f1a4..5cc86ab3876 100644 --- a/src/cloudflare/types/magic_transit/sites/lan_create_params.py +++ b/src/cloudflare/types/magic_transit/sites/lan_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from .nat_param import NatParam from .routed_subnet_param import RoutedSubnetParam @@ -13,7 +13,7 @@ class LANCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" bond_id: int diff --git a/src/cloudflare/types/magic_transit/sites/lan_edit_params.py b/src/cloudflare/types/magic_transit/sites/lan_edit_params.py index 36fd58040bf..cbbe6120380 100644 --- a/src/cloudflare/types/magic_transit/sites/lan_edit_params.py +++ b/src/cloudflare/types/magic_transit/sites/lan_edit_params.py @@ -13,7 +13,7 @@ class LANEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" site_id: Required[str] diff --git a/src/cloudflare/types/magic_transit/sites/lan_update_params.py b/src/cloudflare/types/magic_transit/sites/lan_update_params.py index db47e847eee..abd0bf1b830 100644 --- a/src/cloudflare/types/magic_transit/sites/lan_update_params.py +++ b/src/cloudflare/types/magic_transit/sites/lan_update_params.py @@ -13,7 +13,7 @@ class LANUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" site_id: Required[str] diff --git a/src/cloudflare/types/magic_transit/sites/wan_create_params.py b/src/cloudflare/types/magic_transit/sites/wan_create_params.py index 3538b8411e3..c720b18281e 100644 --- a/src/cloudflare/types/magic_transit/sites/wan_create_params.py +++ b/src/cloudflare/types/magic_transit/sites/wan_create_params.py @@ -10,7 +10,7 @@ class WANCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" physport: Required[int] diff --git a/src/cloudflare/types/magic_transit/sites/wan_edit_params.py b/src/cloudflare/types/magic_transit/sites/wan_edit_params.py index 33459da7830..ed2e47d3c26 100644 --- a/src/cloudflare/types/magic_transit/sites/wan_edit_params.py +++ b/src/cloudflare/types/magic_transit/sites/wan_edit_params.py @@ -10,7 +10,7 @@ class WANEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" site_id: Required[str] diff --git a/src/cloudflare/types/magic_transit/sites/wan_update_params.py b/src/cloudflare/types/magic_transit/sites/wan_update_params.py index 55e62875c5d..885d9c28b7e 100644 --- a/src/cloudflare/types/magic_transit/sites/wan_update_params.py +++ b/src/cloudflare/types/magic_transit/sites/wan_update_params.py @@ -10,7 +10,7 @@ class WANUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" site_id: Required[str] diff --git a/src/cloudflare/types/managed_transforms/managed_transform_edit_params.py b/src/cloudflare/types/managed_transforms/managed_transform_edit_params.py index 572146cec03..717369b3916 100644 --- a/src/cloudflare/types/managed_transforms/managed_transform_edit_params.py +++ b/src/cloudflare/types/managed_transforms/managed_transform_edit_params.py @@ -9,7 +9,7 @@ class ManagedTransformEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """The unique ID of the zone.""" managed_request_headers: Required[Iterable[ManagedRequestHeader]] diff --git a/src/cloudflare/types/mtls_certificates/mtls_certificate_create_params.py b/src/cloudflare/types/mtls_certificates/mtls_certificate_create_params.py index e5e955f7641..e8937505ac2 100644 --- a/src/cloudflare/types/mtls_certificates/mtls_certificate_create_params.py +++ b/src/cloudflare/types/mtls_certificates/mtls_certificate_create_params.py @@ -8,7 +8,7 @@ class MTLSCertificateCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" ca: Required[bool] diff --git a/src/cloudflare/types/mtls_certificates/mtls_certificate_list_params.py b/src/cloudflare/types/mtls_certificates/mtls_certificate_list_params.py index 68fe23c34a9..9d301e91d9c 100644 --- a/src/cloudflare/types/mtls_certificates/mtls_certificate_list_params.py +++ b/src/cloudflare/types/mtls_certificates/mtls_certificate_list_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["MTLSCertificateListParams"] class MTLSCertificateListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" type: List[Literal["custom", "gateway_managed", "access_managed"]] diff --git a/src/cloudflare/types/network_interconnects/cni_create_params.py b/src/cloudflare/types/network_interconnects/cni_create_params.py index 22518f602cf..c8c482501da 100644 --- a/src/cloudflare/types/network_interconnects/cni_create_params.py +++ b/src/cloudflare/types/network_interconnects/cni_create_params.py @@ -11,7 +11,7 @@ class CNICreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Customer account tag""" account: Required[str] diff --git a/src/cloudflare/types/network_interconnects/cni_list_params.py b/src/cloudflare/types/network_interconnects/cni_list_params.py index 105f62d5031..680513eca8d 100644 --- a/src/cloudflare/types/network_interconnects/cni_list_params.py +++ b/src/cloudflare/types/network_interconnects/cni_list_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CNIListParams"] class CNIListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Customer account tag""" cursor: Optional[int] diff --git a/src/cloudflare/types/network_interconnects/cni_update_params.py b/src/cloudflare/types/network_interconnects/cni_update_params.py index bddc5d5e666..b593a346287 100644 --- a/src/cloudflare/types/network_interconnects/cni_update_params.py +++ b/src/cloudflare/types/network_interconnects/cni_update_params.py @@ -11,7 +11,7 @@ class CNIUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Customer account tag""" id: Required[str] diff --git a/src/cloudflare/types/network_interconnects/interconnect_create_params.py b/src/cloudflare/types/network_interconnects/interconnect_create_params.py index c62824f18c9..89013b9cae7 100644 --- a/src/cloudflare/types/network_interconnects/interconnect_create_params.py +++ b/src/cloudflare/types/network_interconnects/interconnect_create_params.py @@ -9,7 +9,7 @@ class NscInterconnectCreatePhysicalBody(TypedDict, total=False): - account_id: Required[str] + account_id: str """Customer account tag""" account: Required[str] @@ -22,7 +22,7 @@ class NscInterconnectCreatePhysicalBody(TypedDict, total=False): class NscInterconnectCreateGcpPartnerBody(TypedDict, total=False): - account_id: Required[str] + account_id: str """Customer account tag""" account: Required[str] diff --git a/src/cloudflare/types/network_interconnects/interconnect_list_params.py b/src/cloudflare/types/network_interconnects/interconnect_list_params.py index 1b60b5ce038..967840ff3d5 100644 --- a/src/cloudflare/types/network_interconnects/interconnect_list_params.py +++ b/src/cloudflare/types/network_interconnects/interconnect_list_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["InterconnectListParams"] class InterconnectListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Customer account tag""" cursor: Optional[int] diff --git a/src/cloudflare/types/network_interconnects/setting_update_params.py b/src/cloudflare/types/network_interconnects/setting_update_params.py index f548ca5b4d7..e54768163cb 100644 --- a/src/cloudflare/types/network_interconnects/setting_update_params.py +++ b/src/cloudflare/types/network_interconnects/setting_update_params.py @@ -3,12 +3,12 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SettingUpdateParams"] class SettingUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str default_asn: Optional[int] diff --git a/src/cloudflare/types/network_interconnects/slot_list_params.py b/src/cloudflare/types/network_interconnects/slot_list_params.py index a788e11fb1e..ff462ef0bb7 100644 --- a/src/cloudflare/types/network_interconnects/slot_list_params.py +++ b/src/cloudflare/types/network_interconnects/slot_list_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SlotListParams"] class SlotListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Customer account tag""" address_contains: Optional[str] diff --git a/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_params.py b/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_params.py index bee5dfc4afb..f22ea0b9a8d 100644 --- a/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_params.py +++ b/src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_update_params.py @@ -8,7 +8,7 @@ class OriginPostQuantumEncryptionUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" value: Required[Literal["preferred", "supported", "off"]] diff --git a/src/cloudflare/types/origin_tls_client_auth/hostname_certificate_create_params.py b/src/cloudflare/types/origin_tls_client_auth/hostname_certificate_create_params.py index b319cad88e3..8b08618c9ce 100644 --- a/src/cloudflare/types/origin_tls_client_auth/hostname_certificate_create_params.py +++ b/src/cloudflare/types/origin_tls_client_auth/hostname_certificate_create_params.py @@ -8,7 +8,7 @@ class HostnameCertificateCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" certificate: Required[str] diff --git a/src/cloudflare/types/origin_tls_client_auth/hostname_update_params.py b/src/cloudflare/types/origin_tls_client_auth/hostname_update_params.py index 60eaf149a18..04efca1ba54 100644 --- a/src/cloudflare/types/origin_tls_client_auth/hostname_update_params.py +++ b/src/cloudflare/types/origin_tls_client_auth/hostname_update_params.py @@ -9,7 +9,7 @@ class HostnameUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" config: Required[Iterable[Config]] diff --git a/src/cloudflare/types/origin_tls_client_auth/origin_tls_client_auth_create_params.py b/src/cloudflare/types/origin_tls_client_auth/origin_tls_client_auth_create_params.py index 09889f17e00..d17edc735a1 100644 --- a/src/cloudflare/types/origin_tls_client_auth/origin_tls_client_auth_create_params.py +++ b/src/cloudflare/types/origin_tls_client_auth/origin_tls_client_auth_create_params.py @@ -8,7 +8,7 @@ class OriginTLSClientAuthCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" certificate: Required[str] diff --git a/src/cloudflare/types/origin_tls_client_auth/setting_update_params.py b/src/cloudflare/types/origin_tls_client_auth/setting_update_params.py index 2c61f7f44ca..a3872f7a0f1 100644 --- a/src/cloudflare/types/origin_tls_client_auth/setting_update_params.py +++ b/src/cloudflare/types/origin_tls_client_auth/setting_update_params.py @@ -8,7 +8,7 @@ class SettingUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" enabled: Required[bool] diff --git a/src/cloudflare/types/origin_tls_client_auth/zone_certificate_create_params.py b/src/cloudflare/types/origin_tls_client_auth/zone_certificate_create_params.py index ac2c5b87bd6..91bf7fc931f 100644 --- a/src/cloudflare/types/origin_tls_client_auth/zone_certificate_create_params.py +++ b/src/cloudflare/types/origin_tls_client_auth/zone_certificate_create_params.py @@ -8,7 +8,7 @@ class ZoneCertificateCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" certificate: Required[str] diff --git a/src/cloudflare/types/page_rules/page_rule_create_params.py b/src/cloudflare/types/page_rules/page_rule_create_params.py index 2450668fc39..dcbd49893d6 100644 --- a/src/cloudflare/types/page_rules/page_rule_create_params.py +++ b/src/cloudflare/types/page_rules/page_rule_create_params.py @@ -56,7 +56,7 @@ class PageRuleCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" actions: Required[Iterable[Action]] diff --git a/src/cloudflare/types/page_rules/page_rule_edit_params.py b/src/cloudflare/types/page_rules/page_rule_edit_params.py index ceb4965fb66..913ad68297a 100644 --- a/src/cloudflare/types/page_rules/page_rule_edit_params.py +++ b/src/cloudflare/types/page_rules/page_rule_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Union, Iterable -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Literal, TypeAlias, TypedDict from ..._types import SequenceNotStr from .target_param import TargetParam @@ -56,7 +56,7 @@ class PageRuleEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" actions: Iterable[Action] diff --git a/src/cloudflare/types/page_rules/page_rule_list_params.py b/src/cloudflare/types/page_rules/page_rule_list_params.py index 2e00e0732b7..fdf632d6a24 100644 --- a/src/cloudflare/types/page_rules/page_rule_list_params.py +++ b/src/cloudflare/types/page_rules/page_rule_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["PageRuleListParams"] class PageRuleListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/page_rules/page_rule_update_params.py b/src/cloudflare/types/page_rules/page_rule_update_params.py index baf13f4b982..e8ba92fefd4 100644 --- a/src/cloudflare/types/page_rules/page_rule_update_params.py +++ b/src/cloudflare/types/page_rules/page_rule_update_params.py @@ -56,7 +56,7 @@ class PageRuleUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" actions: Required[Iterable[Action]] diff --git a/src/cloudflare/types/page_shield/connection_list_params.py b/src/cloudflare/types/page_shield/connection_list_params.py index 7da26a46573..0cec56bb406 100644 --- a/src/cloudflare/types/page_shield/connection_list_params.py +++ b/src/cloudflare/types/page_shield/connection_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ConnectionListParams"] class ConnectionListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/page_shield/cookie_list_params.py b/src/cloudflare/types/page_shield/cookie_list_params.py index 2f1c508612b..f4046b75db4 100644 --- a/src/cloudflare/types/page_shield/cookie_list_params.py +++ b/src/cloudflare/types/page_shield/cookie_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["CookieListParams"] class CookieListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/page_shield/page_shield_update_params.py b/src/cloudflare/types/page_shield/page_shield_update_params.py index 123ba5bb1e0..3c427f1d5fd 100644 --- a/src/cloudflare/types/page_shield/page_shield_update_params.py +++ b/src/cloudflare/types/page_shield/page_shield_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PageShieldUpdateParams"] class PageShieldUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" enabled: bool diff --git a/src/cloudflare/types/page_shield/policy_create_params.py b/src/cloudflare/types/page_shield/policy_create_params.py index 9ff8c1bd62f..6da286a3d66 100644 --- a/src/cloudflare/types/page_shield/policy_create_params.py +++ b/src/cloudflare/types/page_shield/policy_create_params.py @@ -8,7 +8,7 @@ class PolicyCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" action: Required[Literal["allow", "log", "add_reporting_directives"]] diff --git a/src/cloudflare/types/page_shield/policy_update_params.py b/src/cloudflare/types/page_shield/policy_update_params.py index c0e6e0f9a2c..82162f22f60 100644 --- a/src/cloudflare/types/page_shield/policy_update_params.py +++ b/src/cloudflare/types/page_shield/policy_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["PolicyUpdateParams"] class PolicyUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" action: Literal["allow", "log", "add_reporting_directives"] diff --git a/src/cloudflare/types/page_shield/script_list_params.py b/src/cloudflare/types/page_shield/script_list_params.py index fea47abd515..60f2b9739a7 100644 --- a/src/cloudflare/types/page_shield/script_list_params.py +++ b/src/cloudflare/types/page_shield/script_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ScriptListParams"] class ScriptListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/pages/project_create_params.py b/src/cloudflare/types/pages/project_create_params.py index 321845dc2af..1de680bebd3 100644 --- a/src/cloudflare/types/pages/project_create_params.py +++ b/src/cloudflare/types/pages/project_create_params.py @@ -53,7 +53,7 @@ class ProjectCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/pages/project_edit_params.py b/src/cloudflare/types/pages/project_edit_params.py index 793b61adbe0..6ecbc903bbf 100644 --- a/src/cloudflare/types/pages/project_edit_params.py +++ b/src/cloudflare/types/pages/project_edit_params.py @@ -53,7 +53,7 @@ class ProjectEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" build_config: BuildConfig diff --git a/src/cloudflare/types/pages/project_list_params.py b/src/cloudflare/types/pages/project_list_params.py index a3331078193..55aa78571b1 100644 --- a/src/cloudflare/types/pages/project_list_params.py +++ b/src/cloudflare/types/pages/project_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ProjectListParams"] class ProjectListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/pages/projects/__init__.py b/src/cloudflare/types/pages/projects/__init__.py index 084d181817f..a8d8e653d0f 100644 --- a/src/cloudflare/types/pages/projects/__init__.py +++ b/src/cloudflare/types/pages/projects/__init__.py @@ -9,3 +9,4 @@ from .deployment_list_params import DeploymentListParams as DeploymentListParams from .domain_create_response import DomainCreateResponse as DomainCreateResponse from .deployment_create_params import DeploymentCreateParams as DeploymentCreateParams +from .deployment_delete_params import DeploymentDeleteParams as DeploymentDeleteParams diff --git a/src/cloudflare/types/pages/projects/deployment_create_params.py b/src/cloudflare/types/pages/projects/deployment_create_params.py index c9c36ee79d9..2ae80c3e641 100644 --- a/src/cloudflare/types/pages/projects/deployment_create_params.py +++ b/src/cloudflare/types/pages/projects/deployment_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ...._types import FileTypes from ...._utils import PropertyInfo @@ -11,7 +11,7 @@ class DeploymentCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" _headers: FileTypes diff --git a/src/cloudflare/types/pages/projects/deployment_delete_params.py b/src/cloudflare/types/pages/projects/deployment_delete_params.py new file mode 100644 index 00000000000..103a6fc3de8 --- /dev/null +++ b/src/cloudflare/types/pages/projects/deployment_delete_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["DeploymentDeleteParams"] + + +class DeploymentDeleteParams(TypedDict, total=False): + account_id: str + """Identifier.""" + + project_name: Required[str] + """Name of the project.""" + + force: bool + """ + Allow deletion of aliased non-production deployments when a normal delete would + be rejected. + """ diff --git a/src/cloudflare/types/pages/projects/deployment_list_params.py b/src/cloudflare/types/pages/projects/deployment_list_params.py index 596f1462e6b..824374f2a3e 100644 --- a/src/cloudflare/types/pages/projects/deployment_list_params.py +++ b/src/cloudflare/types/pages/projects/deployment_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["DeploymentListParams"] class DeploymentListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" env: Literal["production", "preview"] diff --git a/src/cloudflare/types/pages/projects/domain_create_params.py b/src/cloudflare/types/pages/projects/domain_create_params.py index 8e445ce2a62..c57c9b58680 100644 --- a/src/cloudflare/types/pages/projects/domain_create_params.py +++ b/src/cloudflare/types/pages/projects/domain_create_params.py @@ -8,7 +8,7 @@ class DomainCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/pipelines/pipeline_create_params.py b/src/cloudflare/types/pipelines/pipeline_create_params.py index a89e16e3ef7..792a90d8d5c 100644 --- a/src/cloudflare/types/pipelines/pipeline_create_params.py +++ b/src/cloudflare/types/pipelines/pipeline_create_params.py @@ -22,7 +22,7 @@ class PipelineCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" destination: Required[Destination] diff --git a/src/cloudflare/types/pipelines/pipeline_create_v1_params.py b/src/cloudflare/types/pipelines/pipeline_create_v1_params.py index 46ea0952d42..550dd02d753 100644 --- a/src/cloudflare/types/pipelines/pipeline_create_v1_params.py +++ b/src/cloudflare/types/pipelines/pipeline_create_v1_params.py @@ -8,7 +8,7 @@ class PipelineCreateV1Params(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" name: Required[str] diff --git a/src/cloudflare/types/pipelines/pipeline_list_params.py b/src/cloudflare/types/pipelines/pipeline_list_params.py index 85790ebefd2..a332769434c 100644 --- a/src/cloudflare/types/pipelines/pipeline_list_params.py +++ b/src/cloudflare/types/pipelines/pipeline_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PipelineListParams"] class PipelineListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" page: str diff --git a/src/cloudflare/types/pipelines/pipeline_list_v1_params.py b/src/cloudflare/types/pipelines/pipeline_list_v1_params.py index 47cc727832a..ad25af19331 100644 --- a/src/cloudflare/types/pipelines/pipeline_list_v1_params.py +++ b/src/cloudflare/types/pipelines/pipeline_list_v1_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PipelineListV1Params"] class PipelineListV1Params(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" page: float diff --git a/src/cloudflare/types/pipelines/pipeline_update_params.py b/src/cloudflare/types/pipelines/pipeline_update_params.py index fa8979811cf..1e8db14b9a1 100644 --- a/src/cloudflare/types/pipelines/pipeline_update_params.py +++ b/src/cloudflare/types/pipelines/pipeline_update_params.py @@ -22,7 +22,7 @@ class PipelineUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" destination: Required[Destination] diff --git a/src/cloudflare/types/pipelines/pipeline_validate_sql_params.py b/src/cloudflare/types/pipelines/pipeline_validate_sql_params.py index 99043e42118..46ddf33ba82 100644 --- a/src/cloudflare/types/pipelines/pipeline_validate_sql_params.py +++ b/src/cloudflare/types/pipelines/pipeline_validate_sql_params.py @@ -8,7 +8,7 @@ class PipelineValidateSqlParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" sql: Required[str] diff --git a/src/cloudflare/types/pipelines/sink_create_params.py b/src/cloudflare/types/pipelines/sink_create_params.py index fa0e23c63b1..530904171d2 100644 --- a/src/cloudflare/types/pipelines/sink_create_params.py +++ b/src/cloudflare/types/pipelines/sink_create_params.py @@ -38,7 +38,7 @@ class SinkCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" name: Required[str] diff --git a/src/cloudflare/types/pipelines/sink_delete_params.py b/src/cloudflare/types/pipelines/sink_delete_params.py index d20c8ee161a..0f22aab7c9e 100644 --- a/src/cloudflare/types/pipelines/sink_delete_params.py +++ b/src/cloudflare/types/pipelines/sink_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SinkDeleteParams"] class SinkDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" force: str diff --git a/src/cloudflare/types/pipelines/sink_list_params.py b/src/cloudflare/types/pipelines/sink_list_params.py index 1641ebedee9..d8db0afa0d6 100644 --- a/src/cloudflare/types/pipelines/sink_list_params.py +++ b/src/cloudflare/types/pipelines/sink_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SinkListParams"] class SinkListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" page: float diff --git a/src/cloudflare/types/pipelines/stream_create_params.py b/src/cloudflare/types/pipelines/stream_create_params.py index 14f128c820f..88dd9dbcf2f 100644 --- a/src/cloudflare/types/pipelines/stream_create_params.py +++ b/src/cloudflare/types/pipelines/stream_create_params.py @@ -35,7 +35,7 @@ class StreamCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" name: Required[str] diff --git a/src/cloudflare/types/pipelines/stream_delete_params.py b/src/cloudflare/types/pipelines/stream_delete_params.py index da55e85804e..02a1185dad9 100644 --- a/src/cloudflare/types/pipelines/stream_delete_params.py +++ b/src/cloudflare/types/pipelines/stream_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["StreamDeleteParams"] class StreamDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" force: str diff --git a/src/cloudflare/types/pipelines/stream_list_params.py b/src/cloudflare/types/pipelines/stream_list_params.py index 08a052ed46a..a1ef5c6643d 100644 --- a/src/cloudflare/types/pipelines/stream_list_params.py +++ b/src/cloudflare/types/pipelines/stream_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["StreamListParams"] class StreamListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" page: float diff --git a/src/cloudflare/types/pipelines/stream_update_params.py b/src/cloudflare/types/pipelines/stream_update_params.py index d2914d2e31b..be5e8d9f287 100644 --- a/src/cloudflare/types/pipelines/stream_update_params.py +++ b/src/cloudflare/types/pipelines/stream_update_params.py @@ -10,7 +10,7 @@ class StreamUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Specifies the public ID of the account.""" http: HTTP diff --git a/src/cloudflare/types/queues/consumer_create_params.py b/src/cloudflare/types/queues/consumer_create_params.py index 7aa340053a2..421964025b1 100644 --- a/src/cloudflare/types/queues/consumer_create_params.py +++ b/src/cloudflare/types/queues/consumer_create_params.py @@ -15,7 +15,7 @@ class MqWorkerConsumerRequest(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" script_name: Required[str] @@ -55,7 +55,7 @@ class MqWorkerConsumerRequestSettings(TypedDict, total=False): class MqHTTPConsumerRequest(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" type: Required[Literal["http_pull"]] diff --git a/src/cloudflare/types/queues/consumer_update_params.py b/src/cloudflare/types/queues/consumer_update_params.py index 6be97557103..0c92b9d848e 100644 --- a/src/cloudflare/types/queues/consumer_update_params.py +++ b/src/cloudflare/types/queues/consumer_update_params.py @@ -15,7 +15,7 @@ class MqWorkerConsumerRequest(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" queue_id: Required[str] @@ -58,7 +58,7 @@ class MqWorkerConsumerRequestSettings(TypedDict, total=False): class MqHTTPConsumerRequest(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" queue_id: Required[str] diff --git a/src/cloudflare/types/queues/message_ack_params.py b/src/cloudflare/types/queues/message_ack_params.py index 144cfac1f2f..442eab45027 100644 --- a/src/cloudflare/types/queues/message_ack_params.py +++ b/src/cloudflare/types/queues/message_ack_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["MessageAckParams", "Ack", "Retry"] class MessageAckParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" acks: Iterable[Ack] diff --git a/src/cloudflare/types/queues/message_bulk_push_params.py b/src/cloudflare/types/queues/message_bulk_push_params.py index 8057dcb6740..064b6dc9e5d 100644 --- a/src/cloudflare/types/queues/message_bulk_push_params.py +++ b/src/cloudflare/types/queues/message_bulk_push_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Literal, TypeAlias, TypedDict __all__ = ["MessageBulkPushParams", "Message", "MessageMqQueueMessageText", "MessageMqQueueMessageJson"] class MessageBulkPushParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" delay_seconds: float diff --git a/src/cloudflare/types/queues/message_bulk_push_response.py b/src/cloudflare/types/queues/message_bulk_push_response.py index 5b73580cbcb..9be05da6559 100644 --- a/src/cloudflare/types/queues/message_bulk_push_response.py +++ b/src/cloudflare/types/queues/message_bulk_push_response.py @@ -1,18 +1,39 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional -from typing_extensions import Literal +from typing import Optional from ..._models import BaseModel -from ..shared.response_info import ResponseInfo -__all__ = ["MessageBulkPushResponse"] +__all__ = ["MessageBulkPushResponse", "Metadata", "MetadataMetrics"] -class MessageBulkPushResponse(BaseModel): - errors: Optional[List[ResponseInfo]] = None +class MetadataMetrics(BaseModel): + """Best-effort metrics for the queue. + + Values may be approximate due to the distributed nature of queues. + """ + + backlog_bytes: float + """The size in bytes of unacknowledged messages in the queue.""" + + backlog_count: float + """The number of unacknowledged messages in the queue.""" + + oldest_message_timestamp_ms: float + """Unix timestamp in milliseconds of the oldest unacknowledged message in the + queue. - messages: Optional[List[str]] = None + Returns 0 if unknown. + """ - success: Optional[Literal[True]] = None - """Indicates if the API call was successful or not.""" + +class Metadata(BaseModel): + metrics: Optional[MetadataMetrics] = None + """Best-effort metrics for the queue. + + Values may be approximate due to the distributed nature of queues. + """ + + +class MessageBulkPushResponse(BaseModel): + metadata: Optional[Metadata] = None diff --git a/src/cloudflare/types/queues/message_pull_params.py b/src/cloudflare/types/queues/message_pull_params.py index 2613f621005..b157b065907 100644 --- a/src/cloudflare/types/queues/message_pull_params.py +++ b/src/cloudflare/types/queues/message_pull_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["MessagePullParams"] class MessagePullParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" batch_size: float diff --git a/src/cloudflare/types/queues/message_pull_response.py b/src/cloudflare/types/queues/message_pull_response.py index 529a7132788..e488704e6a7 100644 --- a/src/cloudflare/types/queues/message_pull_response.py +++ b/src/cloudflare/types/queues/message_pull_response.py @@ -4,7 +4,7 @@ from ..._models import BaseModel -__all__ = ["MessagePullResponse", "Message"] +__all__ = ["MessagePullResponse", "Message", "Metadata", "MetadataMetrics"] class Message(BaseModel): @@ -25,8 +25,38 @@ class Message(BaseModel): timestamp_ms: Optional[float] = None +class MetadataMetrics(BaseModel): + """Best-effort metrics for the queue. + + Values may be approximate due to the distributed nature of queues. + """ + + backlog_bytes: float + """The size in bytes of unacknowledged messages in the queue.""" + + backlog_count: float + """The number of unacknowledged messages in the queue.""" + + oldest_message_timestamp_ms: float + """Unix timestamp in milliseconds of the oldest unacknowledged message in the + queue. + + Returns 0 if unknown. + """ + + +class Metadata(BaseModel): + metrics: Optional[MetadataMetrics] = None + """Best-effort metrics for the queue. + + Values may be approximate due to the distributed nature of queues. + """ + + class MessagePullResponse(BaseModel): message_backlog_count: Optional[float] = None - """The number of unacknowledged messages in the queue""" + """The number of unacknowledged messages in the queue.""" messages: Optional[List[Message]] = None + + metadata: Optional[Metadata] = None diff --git a/src/cloudflare/types/queues/message_push_params.py b/src/cloudflare/types/queues/message_push_params.py index d01605820d9..f3af31dd53b 100644 --- a/src/cloudflare/types/queues/message_push_params.py +++ b/src/cloudflare/types/queues/message_push_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Union -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Literal, TypeAlias, TypedDict __all__ = ["MessagePushParams", "MqQueueMessageText", "MqQueueMessageJson"] class MqQueueMessageText(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" body: str @@ -24,7 +24,7 @@ class MqQueueMessageText(TypedDict, total=False): class MqQueueMessageJson(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" body: object diff --git a/src/cloudflare/types/queues/message_push_response.py b/src/cloudflare/types/queues/message_push_response.py index 73ae9465c1c..55e08abe51e 100644 --- a/src/cloudflare/types/queues/message_push_response.py +++ b/src/cloudflare/types/queues/message_push_response.py @@ -1,18 +1,39 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional -from typing_extensions import Literal +from typing import Optional from ..._models import BaseModel -from ..shared.response_info import ResponseInfo -__all__ = ["MessagePushResponse"] +__all__ = ["MessagePushResponse", "Metadata", "MetadataMetrics"] -class MessagePushResponse(BaseModel): - errors: Optional[List[ResponseInfo]] = None +class MetadataMetrics(BaseModel): + """Best-effort metrics for the queue. + + Values may be approximate due to the distributed nature of queues. + """ + + backlog_bytes: float + """The size in bytes of unacknowledged messages in the queue.""" + + backlog_count: float + """The number of unacknowledged messages in the queue.""" + + oldest_message_timestamp_ms: float + """Unix timestamp in milliseconds of the oldest unacknowledged message in the + queue. - messages: Optional[List[str]] = None + Returns 0 if unknown. + """ - success: Optional[Literal[True]] = None - """Indicates if the API call was successful or not.""" + +class Metadata(BaseModel): + metrics: Optional[MetadataMetrics] = None + """Best-effort metrics for the queue. + + Values may be approximate due to the distributed nature of queues. + """ + + +class MessagePushResponse(BaseModel): + metadata: Optional[Metadata] = None diff --git a/src/cloudflare/types/queues/purge_start_params.py b/src/cloudflare/types/queues/purge_start_params.py index c6f16dc04c0..14c81777756 100644 --- a/src/cloudflare/types/queues/purge_start_params.py +++ b/src/cloudflare/types/queues/purge_start_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PurgeStartParams"] class PurgeStartParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" delete_messages_permanently: bool diff --git a/src/cloudflare/types/queues/queue_create_params.py b/src/cloudflare/types/queues/queue_create_params.py index e14f226a015..a60768d4fd5 100644 --- a/src/cloudflare/types/queues/queue_create_params.py +++ b/src/cloudflare/types/queues/queue_create_params.py @@ -8,7 +8,7 @@ class QueueCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" queue_name: Required[str] diff --git a/src/cloudflare/types/queues/queue_edit_params.py b/src/cloudflare/types/queues/queue_edit_params.py index 5b99c17dda8..c1875aab60d 100644 --- a/src/cloudflare/types/queues/queue_edit_params.py +++ b/src/cloudflare/types/queues/queue_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["QueueEditParams", "Settings"] class QueueEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" queue_name: str diff --git a/src/cloudflare/types/queues/queue_update_params.py b/src/cloudflare/types/queues/queue_update_params.py index 9b53025f044..a2e42f28364 100644 --- a/src/cloudflare/types/queues/queue_update_params.py +++ b/src/cloudflare/types/queues/queue_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["QueueUpdateParams", "Settings"] class QueueUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" queue_name: str diff --git a/src/cloudflare/types/queues/subscription_create_params.py b/src/cloudflare/types/queues/subscription_create_params.py index 5540bee2746..292a7008012 100644 --- a/src/cloudflare/types/queues/subscription_create_params.py +++ b/src/cloudflare/types/queues/subscription_create_params.py @@ -23,7 +23,7 @@ class SubscriptionCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" destination: Destination diff --git a/src/cloudflare/types/queues/subscription_list_params.py b/src/cloudflare/types/queues/subscription_list_params.py index 362a6d63b93..6cb5f715ad3 100644 --- a/src/cloudflare/types/queues/subscription_list_params.py +++ b/src/cloudflare/types/queues/subscription_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["SubscriptionListParams"] class SubscriptionListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/queues/subscription_update_params.py b/src/cloudflare/types/queues/subscription_update_params.py index e1b9a00c85e..0c6962be86f 100644 --- a/src/cloudflare/types/queues/subscription_update_params.py +++ b/src/cloudflare/types/queues/subscription_update_params.py @@ -10,7 +10,7 @@ class SubscriptionUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """A Resource identifier.""" destination: Destination diff --git a/src/cloudflare/types/r2/bucket_create_params.py b/src/cloudflare/types/r2/bucket_create_params.py index ca5f063a071..aee6da847d2 100644 --- a/src/cloudflare/types/r2/bucket_create_params.py +++ b/src/cloudflare/types/r2/bucket_create_params.py @@ -10,7 +10,7 @@ class BucketCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" name: Required[str] diff --git a/src/cloudflare/types/r2/bucket_list_params.py b/src/cloudflare/types/r2/bucket_list_params.py index 6370982092d..aaeb3b98d2a 100644 --- a/src/cloudflare/types/r2/bucket_list_params.py +++ b/src/cloudflare/types/r2/bucket_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -10,7 +10,7 @@ class BucketListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" cursor: str diff --git a/src/cloudflare/types/r2/buckets/cors_update_params.py b/src/cloudflare/types/r2/buckets/cors_update_params.py index 7525dd3ce7d..1856cd3d9b8 100644 --- a/src/cloudflare/types/r2/buckets/cors_update_params.py +++ b/src/cloudflare/types/r2/buckets/cors_update_params.py @@ -12,7 +12,7 @@ class CORSUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" rules: Iterable[Rule] diff --git a/src/cloudflare/types/r2/buckets/domains/custom_create_params.py b/src/cloudflare/types/r2/buckets/domains/custom_create_params.py index 9c66d7810dd..11c695971bf 100644 --- a/src/cloudflare/types/r2/buckets/domains/custom_create_params.py +++ b/src/cloudflare/types/r2/buckets/domains/custom_create_params.py @@ -11,7 +11,7 @@ class CustomCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" domain: Required[str] diff --git a/src/cloudflare/types/r2/buckets/domains/custom_update_params.py b/src/cloudflare/types/r2/buckets/domains/custom_update_params.py index bf25374a084..7f7de4b2167 100644 --- a/src/cloudflare/types/r2/buckets/domains/custom_update_params.py +++ b/src/cloudflare/types/r2/buckets/domains/custom_update_params.py @@ -11,7 +11,7 @@ class CustomUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" bucket_name: Required[str] diff --git a/src/cloudflare/types/r2/buckets/domains/managed_update_params.py b/src/cloudflare/types/r2/buckets/domains/managed_update_params.py index 3c6275af635..8274a962f55 100644 --- a/src/cloudflare/types/r2/buckets/domains/managed_update_params.py +++ b/src/cloudflare/types/r2/buckets/domains/managed_update_params.py @@ -10,7 +10,7 @@ class ManagedUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" enabled: Required[bool] diff --git a/src/cloudflare/types/r2/buckets/event_notification_update_params.py b/src/cloudflare/types/r2/buckets/event_notification_update_params.py index c94ddbada0f..b8ddb17748b 100644 --- a/src/cloudflare/types/r2/buckets/event_notification_update_params.py +++ b/src/cloudflare/types/r2/buckets/event_notification_update_params.py @@ -11,7 +11,7 @@ class EventNotificationUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" bucket_name: Required[str] diff --git a/src/cloudflare/types/r2/buckets/lifecycle_update_params.py b/src/cloudflare/types/r2/buckets/lifecycle_update_params.py index abdbb29abce..67dff10c356 100644 --- a/src/cloudflare/types/r2/buckets/lifecycle_update_params.py +++ b/src/cloudflare/types/r2/buckets/lifecycle_update_params.py @@ -26,7 +26,7 @@ class LifecycleUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" rules: Iterable[Rule] diff --git a/src/cloudflare/types/r2/buckets/lock_update_params.py b/src/cloudflare/types/r2/buckets/lock_update_params.py index ca8ad5c4e40..20ebce87014 100644 --- a/src/cloudflare/types/r2/buckets/lock_update_params.py +++ b/src/cloudflare/types/r2/buckets/lock_update_params.py @@ -19,7 +19,7 @@ class LockUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" rules: Iterable[Rule] diff --git a/src/cloudflare/types/r2/buckets/sippy_update_params.py b/src/cloudflare/types/r2/buckets/sippy_update_params.py index 84ceaa1f875..c61abc13df2 100644 --- a/src/cloudflare/types/r2/buckets/sippy_update_params.py +++ b/src/cloudflare/types/r2/buckets/sippy_update_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Union -from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict +from typing_extensions import Literal, Annotated, TypeAlias, TypedDict from .provider import Provider from ...._utils import PropertyInfo @@ -23,7 +23,7 @@ class R2EnableSippyAws(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" destination: R2EnableSippyAwsDestination @@ -81,7 +81,7 @@ class R2EnableSippyAwsSource(TypedDict, total=False): class R2EnableSippyGcs(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" destination: R2EnableSippyGcsDestination @@ -136,7 +136,7 @@ class R2EnableSippyGcsSource(TypedDict, total=False): class R2EnableSippyS3(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" destination: R2EnableSippyS3Destination diff --git a/src/cloudflare/types/r2/super_slurper/connectivity_precheck_source_params.py b/src/cloudflare/types/r2/super_slurper/connectivity_precheck_source_params.py index 20b4aef74f0..2578aa16575 100644 --- a/src/cloudflare/types/r2/super_slurper/connectivity_precheck_source_params.py +++ b/src/cloudflare/types/r2/super_slurper/connectivity_precheck_source_params.py @@ -21,7 +21,7 @@ class R2SlurperS3SourceSchema(TypedDict, total=False): - account_id: Required[str] + account_id: str bucket: Required[str] @@ -45,7 +45,7 @@ class R2SlurperS3SourceSchemaSecret(TypedDict, total=False): class R2SlurperGcsSourceSchema(TypedDict, total=False): - account_id: Required[str] + account_id: str bucket: Required[str] @@ -65,7 +65,7 @@ class R2SlurperGcsSourceSchemaSecret(TypedDict, total=False): class R2SlurperR2SourceSchema(TypedDict, total=False): - account_id: Required[str] + account_id: str bucket: Required[str] diff --git a/src/cloudflare/types/r2/super_slurper/connectivity_precheck_target_params.py b/src/cloudflare/types/r2/super_slurper/connectivity_precheck_target_params.py index 90bb1438ff9..42da84f56fb 100644 --- a/src/cloudflare/types/r2/super_slurper/connectivity_precheck_target_params.py +++ b/src/cloudflare/types/r2/super_slurper/connectivity_precheck_target_params.py @@ -11,7 +11,7 @@ class ConnectivityPrecheckTargetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str bucket: Required[str] diff --git a/src/cloudflare/types/r2/super_slurper/job_create_params.py b/src/cloudflare/types/r2/super_slurper/job_create_params.py index 7c1a4c133e6..41ae96d621f 100644 --- a/src/cloudflare/types/r2/super_slurper/job_create_params.py +++ b/src/cloudflare/types/r2/super_slurper/job_create_params.py @@ -24,7 +24,7 @@ class JobCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str overwrite: bool diff --git a/src/cloudflare/types/r2/super_slurper/job_list_params.py b/src/cloudflare/types/r2/super_slurper/job_list_params.py index f1b0e487eb0..39d471ce4c5 100644 --- a/src/cloudflare/types/r2/super_slurper/job_list_params.py +++ b/src/cloudflare/types/r2/super_slurper/job_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["JobListParams"] class JobListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str limit: int diff --git a/src/cloudflare/types/r2/super_slurper/jobs/log_list_params.py b/src/cloudflare/types/r2/super_slurper/jobs/log_list_params.py index ff059a25e3c..09938d1dfc6 100644 --- a/src/cloudflare/types/r2/super_slurper/jobs/log_list_params.py +++ b/src/cloudflare/types/r2/super_slurper/jobs/log_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["LogListParams"] class LogListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str limit: int diff --git a/src/cloudflare/types/r2/temporary_credential_create_params.py b/src/cloudflare/types/r2/temporary_credential_create_params.py index f9b394c5eb6..7270f8b8daf 100644 --- a/src/cloudflare/types/r2/temporary_credential_create_params.py +++ b/src/cloudflare/types/r2/temporary_credential_create_params.py @@ -11,7 +11,7 @@ class TemporaryCredentialCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" bucket: Required[str] diff --git a/src/cloudflare/types/r2_data_catalog/credential_create_params.py b/src/cloudflare/types/r2_data_catalog/credential_create_params.py index f4bfaacdb58..093c7256da0 100644 --- a/src/cloudflare/types/r2_data_catalog/credential_create_params.py +++ b/src/cloudflare/types/r2_data_catalog/credential_create_params.py @@ -8,7 +8,7 @@ class CredentialCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Use this to identify the account.""" token: Required[str] diff --git a/src/cloudflare/types/r2_data_catalog/maintenance_config_update_params.py b/src/cloudflare/types/r2_data_catalog/maintenance_config_update_params.py index ddaed40f425..be58d4d01b4 100644 --- a/src/cloudflare/types/r2_data_catalog/maintenance_config_update_params.py +++ b/src/cloudflare/types/r2_data_catalog/maintenance_config_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["MaintenanceConfigUpdateParams", "Compaction", "SnapshotExpiration"] class MaintenanceConfigUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Use this to identify the account.""" compaction: Compaction diff --git a/src/cloudflare/types/r2_data_catalog/namespace_list_params.py b/src/cloudflare/types/r2_data_catalog/namespace_list_params.py index fb42c240184..94552200fdb 100644 --- a/src/cloudflare/types/r2_data_catalog/namespace_list_params.py +++ b/src/cloudflare/types/r2_data_catalog/namespace_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["NamespaceListParams"] class NamespaceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Use this to identify the account.""" page_size: int diff --git a/src/cloudflare/types/r2_data_catalog/namespaces/table_list_params.py b/src/cloudflare/types/r2_data_catalog/namespaces/table_list_params.py index e9b5044f6ee..c99368cd54d 100644 --- a/src/cloudflare/types/r2_data_catalog/namespaces/table_list_params.py +++ b/src/cloudflare/types/r2_data_catalog/namespaces/table_list_params.py @@ -8,7 +8,7 @@ class TableListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Use this to identify the account.""" bucket_name: Required[str] diff --git a/src/cloudflare/types/r2_data_catalog/namespaces/tables/maintenance_config_update_params.py b/src/cloudflare/types/r2_data_catalog/namespaces/tables/maintenance_config_update_params.py index 020ce8f3b6c..d508ec30773 100644 --- a/src/cloudflare/types/r2_data_catalog/namespaces/tables/maintenance_config_update_params.py +++ b/src/cloudflare/types/r2_data_catalog/namespaces/tables/maintenance_config_update_params.py @@ -8,7 +8,7 @@ class MaintenanceConfigUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Use this to identify the account.""" bucket_name: Required[str] diff --git a/src/cloudflare/types/radar/__init__.py b/src/cloudflare/types/radar/__init__.py index 67a0f0766e3..5132fde52ac 100644 --- a/src/cloudflare/types/radar/__init__.py +++ b/src/cloudflare/types/radar/__init__.py @@ -58,8 +58,10 @@ from .netflows_timeseries_response import NetFlowsTimeseriesResponse as NetFlowsTimeseriesResponse from .traffic_anomaly_get_response import TrafficAnomalyGetResponse as TrafficAnomalyGetResponse from .ct_timeseries_groups_response import CTTimeseriesGroupsResponse as CTTimeseriesGroupsResponse +from .agent_readiness_summary_params import AgentReadinessSummaryParams as AgentReadinessSummaryParams from .bot_timeseries_groups_response import BotTimeseriesGroupsResponse as BotTimeseriesGroupsResponse from .dns_timeseries_groups_v2_params import DNSTimeseriesGroupsV2Params as DNSTimeseriesGroupsV2Params +from .agent_readiness_summary_response import AgentReadinessSummaryResponse as AgentReadinessSummaryResponse from .http_timeseries_groups_v2_params import HTTPTimeseriesGroupsV2Params as HTTPTimeseriesGroupsV2Params from .ranking_timeseries_groups_params import RankingTimeseriesGroupsParams as RankingTimeseriesGroupsParams from .as112_timeseries_groups_v2_params import AS112TimeseriesGroupsV2Params as AS112TimeseriesGroupsV2Params diff --git a/src/cloudflare/types/radar/agent_readiness_summary_params.py b/src/cloudflare/types/radar/agent_readiness_summary_params.py new file mode 100644 index 00000000000..0b48188fc2d --- /dev/null +++ b/src/cloudflare/types/radar/agent_readiness_summary_params.py @@ -0,0 +1,26 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import datetime +from typing import Union +from typing_extensions import Literal, Annotated, TypedDict + +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo + +__all__ = ["AgentReadinessSummaryParams"] + + +class AgentReadinessSummaryParams(TypedDict, total=False): + date: Annotated[Union[str, datetime.date], PropertyInfo(format="iso8601")] + """Filters results by the specified date.""" + + domain_category: Annotated[SequenceNotStr[str], PropertyInfo(alias="domainCategory")] + """Filters results by domain category.""" + + format: Literal["JSON", "CSV"] + """Format in which results will be returned.""" + + name: SequenceNotStr[str] + """Array of names used to label the series in the response.""" diff --git a/src/cloudflare/types/radar/agent_readiness_summary_response.py b/src/cloudflare/types/radar/agent_readiness_summary_response.py new file mode 100644 index 00000000000..3d818960b25 --- /dev/null +++ b/src/cloudflare/types/radar/agent_readiness_summary_response.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["AgentReadinessSummaryResponse", "Meta", "MetaDomainCategory", "MetaUnit"] + + +class MetaDomainCategory(BaseModel): + name: str + """Sub-category name.""" + + value: int + """Number of successfully scanned domains in this sub-category.""" + + +class MetaUnit(BaseModel): + name: str + + value: str + + +class Meta(BaseModel): + date: str + """Date of the returned scan (YYYY-MM-DD). + + May differ from the requested date if no scan exists for that exact date. + """ + + domain_categories: List[MetaDomainCategory] = FieldInfo(alias="domainCategories") + """Available domain sub-categories with their scan counts. + + Use as filter options for the domainCategory parameter. + """ + + last_updated: datetime = FieldInfo(alias="lastUpdated") + """Timestamp of the last dataset update.""" + + normalization: Literal[ + "PERCENTAGE", + "MIN0_MAX", + "MIN_MAX", + "RAW_VALUES", + "PERCENTAGE_CHANGE", + "ROLLING_AVERAGE", + "OVERLAPPED_PERCENTAGE", + "RATIO", + ] + """Normalization method applied to the results. + + Refer to + [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + """ + + successful_domains: int = FieldInfo(alias="successfulDomains") + """Domains successfully scanned (excludes errors).""" + + total_domains: int = FieldInfo(alias="totalDomains") + """Total domains attempted in the scan.""" + + units: List[MetaUnit] + """Measurement units for the results.""" + + +class AgentReadinessSummaryResponse(BaseModel): + meta: Meta + + summary_0: Dict[str, str] diff --git a/src/cloudflare/types/radar/ai/__init__.py b/src/cloudflare/types/radar/ai/__init__.py index a86e9a183e7..ec486dc339b 100755 --- a/src/cloudflare/types/radar/ai/__init__.py +++ b/src/cloudflare/types/radar/ai/__init__.py @@ -13,14 +13,20 @@ from .inference_summary_v2_response import InferenceSummaryV2Response as InferenceSummaryV2Response from .bot_timeseries_groups_response import BotTimeseriesGroupsResponse as BotTimeseriesGroupsResponse from .timeseries_group_summary_params import TimeseriesGroupSummaryParams as TimeseriesGroupSummaryParams +from .markdown_for_agent_summary_params import MarkdownForAgentSummaryParams as MarkdownForAgentSummaryParams from .timeseries_group_summary_response import TimeseriesGroupSummaryResponse as TimeseriesGroupSummaryResponse from .timeseries_group_timeseries_params import TimeseriesGroupTimeseriesParams as TimeseriesGroupTimeseriesParams from .timeseries_group_user_agent_params import TimeseriesGroupUserAgentParams as TimeseriesGroupUserAgentParams +from .markdown_for_agent_summary_response import MarkdownForAgentSummaryResponse as MarkdownForAgentSummaryResponse +from .markdown_for_agent_timeseries_params import MarkdownForAgentTimeseriesParams as MarkdownForAgentTimeseriesParams from .timeseries_group_timeseries_response import TimeseriesGroupTimeseriesResponse as TimeseriesGroupTimeseriesResponse from .timeseries_group_user_agent_response import TimeseriesGroupUserAgentResponse as TimeseriesGroupUserAgentResponse from .inference_timeseries_groups_v2_params import ( InferenceTimeseriesGroupsV2Params as InferenceTimeseriesGroupsV2Params, ) +from .markdown_for_agent_timeseries_response import ( + MarkdownForAgentTimeseriesResponse as MarkdownForAgentTimeseriesResponse, +) from .inference_timeseries_groups_v2_response import ( InferenceTimeseriesGroupsV2Response as InferenceTimeseriesGroupsV2Response, ) diff --git a/src/cloudflare/types/radar/ai/markdown_for_agent_summary_params.py b/src/cloudflare/types/radar/ai/markdown_for_agent_summary_params.py new file mode 100644 index 00000000000..f2f0f4f665a --- /dev/null +++ b/src/cloudflare/types/radar/ai/markdown_for_agent_summary_params.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from ...._types import SequenceNotStr +from ...._utils import PropertyInfo + +__all__ = ["MarkdownForAgentSummaryParams"] + + +class MarkdownForAgentSummaryParams(TypedDict, total=False): + date_end: Annotated[SequenceNotStr[Union[str, datetime]], PropertyInfo(alias="dateEnd", format="iso8601")] + """End of the date range (inclusive).""" + + date_range: Annotated[SequenceNotStr[str], PropertyInfo(alias="dateRange")] + """Filters results by date range. + + For example, use `7d` and `7dcontrol` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + """ + + date_start: Annotated[SequenceNotStr[Union[str, datetime]], PropertyInfo(alias="dateStart", format="iso8601")] + """Start of the date range.""" + + format: Literal["JSON", "CSV"] + """Format in which results will be returned.""" + + name: SequenceNotStr[str] + """Array of names used to label the series in the response.""" diff --git a/src/cloudflare/types/radar/ai/markdown_for_agent_summary_response.py b/src/cloudflare/types/radar/ai/markdown_for_agent_summary_response.py new file mode 100644 index 00000000000..a57750d0fca --- /dev/null +++ b/src/cloudflare/types/radar/ai/markdown_for_agent_summary_response.py @@ -0,0 +1,131 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = [ + "MarkdownForAgentSummaryResponse", + "Meta", + "MetaConfidenceInfo", + "MetaConfidenceInfoAnnotation", + "MetaDateRange", + "MetaUnit", + "Summary0", +] + + +class MetaConfidenceInfoAnnotation(BaseModel): + """Annotation associated with the result (e.g. outage or other type of event).""" + + data_source: Literal[ + "ALL", + "AI_BOTS", + "AI_GATEWAY", + "BGP", + "BOTS", + "CONNECTION_ANOMALY", + "CT", + "DNS", + "DNS_MAGNITUDE", + "DNS_AS112", + "DOS", + "EMAIL_ROUTING", + "EMAIL_SECURITY", + "FW", + "FW_PG", + "HTTP", + "HTTP_CONTROL", + "HTTP_CRAWLER_REFERER", + "HTTP_ORIGINS", + "IQI", + "LEAKED_CREDENTIALS", + "NET", + "ROBOTS_TXT", + "SPEED", + "WORKERS_AI", + ] = FieldInfo(alias="dataSource") + """Data source for annotations.""" + + description: str + + end_date: datetime = FieldInfo(alias="endDate") + + event_type: Literal["EVENT", "GENERAL", "OUTAGE", "PARTIAL_PROJECTION", "PIPELINE", "TRAFFIC_ANOMALY"] = FieldInfo( + alias="eventType" + ) + """Event type for annotations.""" + + is_instantaneous: bool = FieldInfo(alias="isInstantaneous") + """Whether event is a single point in time or a time range.""" + + linked_url: str = FieldInfo(alias="linkedUrl") + + start_date: datetime = FieldInfo(alias="startDate") + + +class MetaConfidenceInfo(BaseModel): + annotations: List[MetaConfidenceInfoAnnotation] + + level: int + """Provides an indication of how much confidence Cloudflare has in the data.""" + + +class MetaDateRange(BaseModel): + end_time: datetime = FieldInfo(alias="endTime") + """Adjusted end of date range.""" + + start_time: datetime = FieldInfo(alias="startTime") + """Adjusted start of date range.""" + + +class MetaUnit(BaseModel): + name: str + + value: str + + +class Meta(BaseModel): + """Metadata for the results.""" + + confidence_info: MetaConfidenceInfo = FieldInfo(alias="confidenceInfo") + + date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") + + last_updated: datetime = FieldInfo(alias="lastUpdated") + """Timestamp of the last dataset update.""" + + normalization: Literal[ + "PERCENTAGE", + "MIN0_MAX", + "MIN_MAX", + "RAW_VALUES", + "PERCENTAGE_CHANGE", + "ROLLING_AVERAGE", + "OVERLAPPED_PERCENTAGE", + "RATIO", + ] + """Normalization method applied to the results. + + Refer to + [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + """ + + units: List[MetaUnit] + """Measurement units for the results.""" + + +class Summary0(BaseModel): + value: str + """A numeric string that can include decimals and infinity values.""" + + +class MarkdownForAgentSummaryResponse(BaseModel): + meta: Meta + """Metadata for the results.""" + + summary_0: Summary0 diff --git a/src/cloudflare/types/radar/ai/markdown_for_agent_timeseries_params.py b/src/cloudflare/types/radar/ai/markdown_for_agent_timeseries_params.py new file mode 100644 index 00000000000..bed0c783308 --- /dev/null +++ b/src/cloudflare/types/radar/ai/markdown_for_agent_timeseries_params.py @@ -0,0 +1,41 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from ...._types import SequenceNotStr +from ...._utils import PropertyInfo + +__all__ = ["MarkdownForAgentTimeseriesParams"] + + +class MarkdownForAgentTimeseriesParams(TypedDict, total=False): + agg_interval: Annotated[Literal["15m", "1h", "1d", "1w"], PropertyInfo(alias="aggInterval")] + """Aggregation interval of the results (e.g., in 15 minutes or 1 hour intervals). + + Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + """ + + date_end: Annotated[SequenceNotStr[Union[str, datetime]], PropertyInfo(alias="dateEnd", format="iso8601")] + """End of the date range (inclusive).""" + + date_range: Annotated[SequenceNotStr[str], PropertyInfo(alias="dateRange")] + """Filters results by date range. + + For example, use `7d` and `7dcontrol` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + """ + + date_start: Annotated[SequenceNotStr[Union[str, datetime]], PropertyInfo(alias="dateStart", format="iso8601")] + """Start of the date range.""" + + format: Literal["JSON", "CSV"] + """Format in which results will be returned.""" + + name: SequenceNotStr[str] + """Array of names used to label the series in the response.""" diff --git a/src/cloudflare/types/radar/ai/markdown_for_agent_timeseries_response.py b/src/cloudflare/types/radar/ai/markdown_for_agent_timeseries_response.py new file mode 100644 index 00000000000..165e883b2fa --- /dev/null +++ b/src/cloudflare/types/radar/ai/markdown_for_agent_timeseries_response.py @@ -0,0 +1,151 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import TYPE_CHECKING, Dict, List +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = [ + "MarkdownForAgentTimeseriesResponse", + "Meta", + "MetaConfidenceInfo", + "MetaConfidenceInfoAnnotation", + "MetaDateRange", + "MetaUnit", + "MarkdownForAgentTimeseriesResponseItem", +] + + +class MetaConfidenceInfoAnnotation(BaseModel): + """Annotation associated with the result (e.g. outage or other type of event).""" + + data_source: Literal[ + "ALL", + "AI_BOTS", + "AI_GATEWAY", + "BGP", + "BOTS", + "CONNECTION_ANOMALY", + "CT", + "DNS", + "DNS_MAGNITUDE", + "DNS_AS112", + "DOS", + "EMAIL_ROUTING", + "EMAIL_SECURITY", + "FW", + "FW_PG", + "HTTP", + "HTTP_CONTROL", + "HTTP_CRAWLER_REFERER", + "HTTP_ORIGINS", + "IQI", + "LEAKED_CREDENTIALS", + "NET", + "ROBOTS_TXT", + "SPEED", + "WORKERS_AI", + ] = FieldInfo(alias="dataSource") + """Data source for annotations.""" + + description: str + + end_date: datetime = FieldInfo(alias="endDate") + + event_type: Literal["EVENT", "GENERAL", "OUTAGE", "PARTIAL_PROJECTION", "PIPELINE", "TRAFFIC_ANOMALY"] = FieldInfo( + alias="eventType" + ) + """Event type for annotations.""" + + is_instantaneous: bool = FieldInfo(alias="isInstantaneous") + """Whether event is a single point in time or a time range.""" + + linked_url: str = FieldInfo(alias="linkedUrl") + + start_date: datetime = FieldInfo(alias="startDate") + + +class MetaConfidenceInfo(BaseModel): + annotations: List[MetaConfidenceInfoAnnotation] + + level: int + """Provides an indication of how much confidence Cloudflare has in the data.""" + + +class MetaDateRange(BaseModel): + end_time: datetime = FieldInfo(alias="endTime") + """Adjusted end of date range.""" + + start_time: datetime = FieldInfo(alias="startTime") + """Adjusted start of date range.""" + + +class MetaUnit(BaseModel): + name: str + + value: str + + +class Meta(BaseModel): + """Metadata for the results.""" + + agg_interval: Literal["FIFTEEN_MINUTES", "ONE_HOUR", "ONE_DAY", "ONE_WEEK", "ONE_MONTH"] = FieldInfo( + alias="aggInterval" + ) + """Aggregation interval of the results (e.g., in 15 minutes or 1 hour intervals). + + Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + """ + + confidence_info: MetaConfidenceInfo = FieldInfo(alias="confidenceInfo") + + date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") + + last_updated: datetime = FieldInfo(alias="lastUpdated") + """Timestamp of the last dataset update.""" + + normalization: Literal[ + "PERCENTAGE", + "MIN0_MAX", + "MIN_MAX", + "RAW_VALUES", + "PERCENTAGE_CHANGE", + "ROLLING_AVERAGE", + "OVERLAPPED_PERCENTAGE", + "RATIO", + ] + """Normalization method applied to the results. + + Refer to + [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + """ + + units: List[MetaUnit] + """Measurement units for the results.""" + + +class MarkdownForAgentTimeseriesResponseItem(BaseModel): + timestamps: List[datetime] + + values: List[str] + + +class MarkdownForAgentTimeseriesResponse(BaseModel): + meta: Meta + """Metadata for the results.""" + + if TYPE_CHECKING: + # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a + # value to this field, so for compatibility we avoid doing it at runtime. + __pydantic_extra__: Dict[str, MarkdownForAgentTimeseriesResponseItem] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride] + + # Stub to indicate that arbitrary properties are accepted. + # To access properties that are not valid identifiers you can use `getattr`, e.g. + # `getattr(obj, '$type')` + def __getattr__(self, attr: str) -> MarkdownForAgentTimeseriesResponseItem: ... + else: + __pydantic_extra__: Dict[str, MarkdownForAgentTimeseriesResponseItem] diff --git a/src/cloudflare/types/radar/ai/to_markdown_create_params.py b/src/cloudflare/types/radar/ai/to_markdown_create_params.py index 92304981b59..ee89c14a391 100644 --- a/src/cloudflare/types/radar/ai/to_markdown_create_params.py +++ b/src/cloudflare/types/radar/ai/to_markdown_create_params.py @@ -10,6 +10,6 @@ class ToMarkdownCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str files: Required[SequenceNotStr[FileTypes]] diff --git a/src/cloudflare/types/rate_limits/rate_limit_create_params.py b/src/cloudflare/types/rate_limits/rate_limit_create_params.py index 447c2b8b56e..66edefc1144 100644 --- a/src/cloudflare/types/rate_limits/rate_limit_create_params.py +++ b/src/cloudflare/types/rate_limits/rate_limit_create_params.py @@ -11,7 +11,7 @@ class RateLimitCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" action: Required[Action] diff --git a/src/cloudflare/types/rate_limits/rate_limit_edit_params.py b/src/cloudflare/types/rate_limits/rate_limit_edit_params.py index e91233331b1..f5674cb973e 100644 --- a/src/cloudflare/types/rate_limits/rate_limit_edit_params.py +++ b/src/cloudflare/types/rate_limits/rate_limit_edit_params.py @@ -11,7 +11,7 @@ class RateLimitEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" action: Required[Action] diff --git a/src/cloudflare/types/rate_limits/rate_limit_list_params.py b/src/cloudflare/types/rate_limits/rate_limit_list_params.py index b4de31ed657..ce6be251fa4 100644 --- a/src/cloudflare/types/rate_limits/rate_limit_list_params.py +++ b/src/cloudflare/types/rate_limits/rate_limit_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["RateLimitListParams"] class RateLimitListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Defines an identifier.""" page: float diff --git a/src/cloudflare/types/realtime_kit/active_session_create_poll_params.py b/src/cloudflare/types/realtime_kit/active_session_create_poll_params.py index 45cdf76f14e..9c2aae1a7d1 100644 --- a/src/cloudflare/types/realtime_kit/active_session_create_poll_params.py +++ b/src/cloudflare/types/realtime_kit/active_session_create_poll_params.py @@ -10,7 +10,7 @@ class ActiveSessionCreatePollParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/active_session_kick_participants_params.py b/src/cloudflare/types/realtime_kit/active_session_kick_participants_params.py index afd4df8c824..41613784271 100644 --- a/src/cloudflare/types/realtime_kit/active_session_kick_participants_params.py +++ b/src/cloudflare/types/realtime_kit/active_session_kick_participants_params.py @@ -10,7 +10,7 @@ class ActiveSessionKickParticipantsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/analytics_get_org_analytics_params.py b/src/cloudflare/types/realtime_kit/analytics_get_org_analytics_params.py index 208d478907d..a8f90eb9581 100644 --- a/src/cloudflare/types/realtime_kit/analytics_get_org_analytics_params.py +++ b/src/cloudflare/types/realtime_kit/analytics_get_org_analytics_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["AnalyticsGetOrgAnalyticsParams"] class AnalyticsGetOrgAnalyticsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" end_date: str diff --git a/src/cloudflare/types/realtime_kit/app_post_params.py b/src/cloudflare/types/realtime_kit/app_post_params.py index 1bb8921ab6e..6eab457d44a 100644 --- a/src/cloudflare/types/realtime_kit/app_post_params.py +++ b/src/cloudflare/types/realtime_kit/app_post_params.py @@ -8,6 +8,6 @@ class AppPostParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] diff --git a/src/cloudflare/types/realtime_kit/livestream_create_independent_livestream_params.py b/src/cloudflare/types/realtime_kit/livestream_create_independent_livestream_params.py index 8991dc929c3..9790add07df 100644 --- a/src/cloudflare/types/realtime_kit/livestream_create_independent_livestream_params.py +++ b/src/cloudflare/types/realtime_kit/livestream_create_independent_livestream_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["LivestreamCreateIndependentLivestreamParams"] class LivestreamCreateIndependentLivestreamParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" name: Optional[str] diff --git a/src/cloudflare/types/realtime_kit/livestream_get_all_livestreams_params.py b/src/cloudflare/types/realtime_kit/livestream_get_all_livestreams_params.py index a72b62a0fb2..60fff83f6be 100644 --- a/src/cloudflare/types/realtime_kit/livestream_get_all_livestreams_params.py +++ b/src/cloudflare/types/realtime_kit/livestream_get_all_livestreams_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class LivestreamGetAllLivestreamsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" end_time: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/realtime_kit/livestream_get_livestream_analytics_complete_params.py b/src/cloudflare/types/realtime_kit/livestream_get_livestream_analytics_complete_params.py index 132726bf720..cf606f3b415 100644 --- a/src/cloudflare/types/realtime_kit/livestream_get_livestream_analytics_complete_params.py +++ b/src/cloudflare/types/realtime_kit/livestream_get_livestream_analytics_complete_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class LivestreamGetLivestreamAnalyticsCompleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" end_time: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/realtime_kit/livestream_get_livestream_session_for_livestream_id_params.py b/src/cloudflare/types/realtime_kit/livestream_get_livestream_session_for_livestream_id_params.py index edf7e5f092a..71c191fe0fc 100644 --- a/src/cloudflare/types/realtime_kit/livestream_get_livestream_session_for_livestream_id_params.py +++ b/src/cloudflare/types/realtime_kit/livestream_get_livestream_session_for_livestream_id_params.py @@ -8,7 +8,7 @@ class LivestreamGetLivestreamSessionForLivestreamIDParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/livestream_get_org_analytics_params.py b/src/cloudflare/types/realtime_kit/livestream_get_org_analytics_params.py index 63730dcc0e2..48a63e37d03 100644 --- a/src/cloudflare/types/realtime_kit/livestream_get_org_analytics_params.py +++ b/src/cloudflare/types/realtime_kit/livestream_get_org_analytics_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["LivestreamGetOrgAnalyticsParams"] class LivestreamGetOrgAnalyticsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" end_date: str diff --git a/src/cloudflare/types/realtime_kit/livestream_start_livestreaming_a_meeting_params.py b/src/cloudflare/types/realtime_kit/livestream_start_livestreaming_a_meeting_params.py index 8a34a6d8d2d..5239bcd75bb 100644 --- a/src/cloudflare/types/realtime_kit/livestream_start_livestreaming_a_meeting_params.py +++ b/src/cloudflare/types/realtime_kit/livestream_start_livestreaming_a_meeting_params.py @@ -9,7 +9,7 @@ class LivestreamStartLivestreamingAMeetingParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/meeting_add_participant_params.py b/src/cloudflare/types/realtime_kit/meeting_add_participant_params.py index 111b281d294..361a8f0177d 100644 --- a/src/cloudflare/types/realtime_kit/meeting_add_participant_params.py +++ b/src/cloudflare/types/realtime_kit/meeting_add_participant_params.py @@ -9,7 +9,7 @@ class MeetingAddParticipantParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/meeting_create_params.py b/src/cloudflare/types/realtime_kit/meeting_create_params.py index 7cf8980aa09..5890bfc3c6e 100644 --- a/src/cloudflare/types/realtime_kit/meeting_create_params.py +++ b/src/cloudflare/types/realtime_kit/meeting_create_params.py @@ -24,7 +24,7 @@ class MeetingCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" ai_config: AIConfig diff --git a/src/cloudflare/types/realtime_kit/meeting_edit_participant_params.py b/src/cloudflare/types/realtime_kit/meeting_edit_participant_params.py index 2b36ce4b14a..49312cbb11d 100644 --- a/src/cloudflare/types/realtime_kit/meeting_edit_participant_params.py +++ b/src/cloudflare/types/realtime_kit/meeting_edit_participant_params.py @@ -9,7 +9,7 @@ class MeetingEditParticipantParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/meeting_get_meeting_by_id_params.py b/src/cloudflare/types/realtime_kit/meeting_get_meeting_by_id_params.py index 76dc134732c..cc6d647589b 100644 --- a/src/cloudflare/types/realtime_kit/meeting_get_meeting_by_id_params.py +++ b/src/cloudflare/types/realtime_kit/meeting_get_meeting_by_id_params.py @@ -8,7 +8,7 @@ class MeetingGetMeetingByIDParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/meeting_get_meeting_participants_params.py b/src/cloudflare/types/realtime_kit/meeting_get_meeting_participants_params.py index a7476985b95..71224b7690e 100644 --- a/src/cloudflare/types/realtime_kit/meeting_get_meeting_participants_params.py +++ b/src/cloudflare/types/realtime_kit/meeting_get_meeting_participants_params.py @@ -8,7 +8,7 @@ class MeetingGetMeetingParticipantsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/meeting_get_params.py b/src/cloudflare/types/realtime_kit/meeting_get_params.py index 4cf938f1ed9..8c8de4b3b39 100644 --- a/src/cloudflare/types/realtime_kit/meeting_get_params.py +++ b/src/cloudflare/types/realtime_kit/meeting_get_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class MeetingGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" end_time: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/realtime_kit/meeting_replace_meeting_by_id_params.py b/src/cloudflare/types/realtime_kit/meeting_replace_meeting_by_id_params.py index ddc84a3ef07..39c437058f9 100644 --- a/src/cloudflare/types/realtime_kit/meeting_replace_meeting_by_id_params.py +++ b/src/cloudflare/types/realtime_kit/meeting_replace_meeting_by_id_params.py @@ -24,7 +24,7 @@ class MeetingReplaceMeetingByIDParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/meeting_update_meeting_by_id_params.py b/src/cloudflare/types/realtime_kit/meeting_update_meeting_by_id_params.py index f58ca68b842..0667733954d 100644 --- a/src/cloudflare/types/realtime_kit/meeting_update_meeting_by_id_params.py +++ b/src/cloudflare/types/realtime_kit/meeting_update_meeting_by_id_params.py @@ -10,7 +10,7 @@ class MeetingUpdateMeetingByIDParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/preset_create_params.py b/src/cloudflare/types/realtime_kit/preset_create_params.py index 23fb7761a88..5ec2ff20485 100644 --- a/src/cloudflare/types/realtime_kit/preset_create_params.py +++ b/src/cloudflare/types/realtime_kit/preset_create_params.py @@ -37,7 +37,7 @@ class PresetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" config: Required[Config] diff --git a/src/cloudflare/types/realtime_kit/preset_get_params.py b/src/cloudflare/types/realtime_kit/preset_get_params.py index c83295c7a61..ef22d315e3d 100644 --- a/src/cloudflare/types/realtime_kit/preset_get_params.py +++ b/src/cloudflare/types/realtime_kit/preset_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PresetGetParams"] class PresetGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" page_no: float diff --git a/src/cloudflare/types/realtime_kit/preset_update_params.py b/src/cloudflare/types/realtime_kit/preset_update_params.py index 87da10b488f..90be39f237a 100644 --- a/src/cloudflare/types/realtime_kit/preset_update_params.py +++ b/src/cloudflare/types/realtime_kit/preset_update_params.py @@ -36,7 +36,7 @@ class PresetUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/recording_get_recordings_params.py b/src/cloudflare/types/realtime_kit/recording_get_recordings_params.py index e6f658309f7..7b86f149214 100644 --- a/src/cloudflare/types/realtime_kit/recording_get_recordings_params.py +++ b/src/cloudflare/types/realtime_kit/recording_get_recordings_params.py @@ -4,7 +4,7 @@ from typing import List, Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class RecordingGetRecordingsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" end_time: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/realtime_kit/recording_pause_resume_stop_recording_params.py b/src/cloudflare/types/realtime_kit/recording_pause_resume_stop_recording_params.py index 5d1e37a20ff..2f4fd06f3e5 100644 --- a/src/cloudflare/types/realtime_kit/recording_pause_resume_stop_recording_params.py +++ b/src/cloudflare/types/realtime_kit/recording_pause_resume_stop_recording_params.py @@ -8,7 +8,7 @@ class RecordingPauseResumeStopRecordingParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/recording_start_recordings_params.py b/src/cloudflare/types/realtime_kit/recording_start_recordings_params.py index 550a5b31e79..c1fdd2887e2 100644 --- a/src/cloudflare/types/realtime_kit/recording_start_recordings_params.py +++ b/src/cloudflare/types/realtime_kit/recording_start_recordings_params.py @@ -19,7 +19,7 @@ class RecordingStartRecordingsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" allow_multiple_recordings: bool diff --git a/src/cloudflare/types/realtime_kit/recording_start_track_recording_params.py b/src/cloudflare/types/realtime_kit/recording_start_track_recording_params.py index 0b0de90f89a..1e34d1ed8d9 100644 --- a/src/cloudflare/types/realtime_kit/recording_start_track_recording_params.py +++ b/src/cloudflare/types/realtime_kit/recording_start_track_recording_params.py @@ -9,7 +9,7 @@ class RecordingStartTrackRecordingParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" layers: Required[Dict[str, Layers]] diff --git a/src/cloudflare/types/realtime_kit/session_get_participant_data_from_peer_id_params.py b/src/cloudflare/types/realtime_kit/session_get_participant_data_from_peer_id_params.py index b0976a7a812..3f52147f147 100644 --- a/src/cloudflare/types/realtime_kit/session_get_participant_data_from_peer_id_params.py +++ b/src/cloudflare/types/realtime_kit/session_get_participant_data_from_peer_id_params.py @@ -8,7 +8,7 @@ class SessionGetParticipantDataFromPeerIDParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/session_get_session_details_params.py b/src/cloudflare/types/realtime_kit/session_get_session_details_params.py index daea87d18b7..c0615876045 100644 --- a/src/cloudflare/types/realtime_kit/session_get_session_details_params.py +++ b/src/cloudflare/types/realtime_kit/session_get_session_details_params.py @@ -8,7 +8,7 @@ class SessionGetSessionDetailsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/session_get_session_participant_details_params.py b/src/cloudflare/types/realtime_kit/session_get_session_participant_details_params.py index 6cc600c7bca..a28608d403e 100644 --- a/src/cloudflare/types/realtime_kit/session_get_session_participant_details_params.py +++ b/src/cloudflare/types/realtime_kit/session_get_session_participant_details_params.py @@ -8,7 +8,7 @@ class SessionGetSessionParticipantDetailsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/session_get_session_participants_params.py b/src/cloudflare/types/realtime_kit/session_get_session_participants_params.py index 7cee9e192e5..a2a50190639 100644 --- a/src/cloudflare/types/realtime_kit/session_get_session_participants_params.py +++ b/src/cloudflare/types/realtime_kit/session_get_session_participants_params.py @@ -8,7 +8,7 @@ class SessionGetSessionParticipantsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/session_get_sessions_params.py b/src/cloudflare/types/realtime_kit/session_get_sessions_params.py index 8978b5d43da..b64cf40ccd5 100644 --- a/src/cloudflare/types/realtime_kit/session_get_sessions_params.py +++ b/src/cloudflare/types/realtime_kit/session_get_sessions_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class SessionGetSessionsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" associated_id: str diff --git a/src/cloudflare/types/realtime_kit/webhook_create_webhook_params.py b/src/cloudflare/types/realtime_kit/webhook_create_webhook_params.py index c16f99a451c..7dc23b4dcb2 100644 --- a/src/cloudflare/types/realtime_kit/webhook_create_webhook_params.py +++ b/src/cloudflare/types/realtime_kit/webhook_create_webhook_params.py @@ -9,7 +9,7 @@ class WebhookCreateWebhookParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" events: Required[ diff --git a/src/cloudflare/types/realtime_kit/webhook_edit_webhook_params.py b/src/cloudflare/types/realtime_kit/webhook_edit_webhook_params.py index 5b4e7ded101..9e8c9bcb97c 100644 --- a/src/cloudflare/types/realtime_kit/webhook_edit_webhook_params.py +++ b/src/cloudflare/types/realtime_kit/webhook_edit_webhook_params.py @@ -9,7 +9,7 @@ class WebhookEditWebhookParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/realtime_kit/webhook_replace_webhook_params.py b/src/cloudflare/types/realtime_kit/webhook_replace_webhook_params.py index 74732bdbf45..bc27108bc53 100644 --- a/src/cloudflare/types/realtime_kit/webhook_replace_webhook_params.py +++ b/src/cloudflare/types/realtime_kit/webhook_replace_webhook_params.py @@ -9,7 +9,7 @@ class WebhookReplaceWebhookParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" app_id: Required[str] diff --git a/src/cloudflare/types/registrar/__init__.py b/src/cloudflare/types/registrar/__init__.py index b6e29688280..720eb9554d8 100644 --- a/src/cloudflare/types/registrar/__init__.py +++ b/src/cloudflare/types/registrar/__init__.py @@ -10,5 +10,6 @@ from .registrar_search_params import RegistrarSearchParams as RegistrarSearchParams from .registrar_check_response import RegistrarCheckResponse as RegistrarCheckResponse from .registration_edit_params import RegistrationEditParams as RegistrationEditParams +from .registration_list_params import RegistrationListParams as RegistrationListParams from .registrar_search_response import RegistrarSearchResponse as RegistrarSearchResponse from .registration_create_params import RegistrationCreateParams as RegistrationCreateParams diff --git a/src/cloudflare/types/registrar/domain_update_params.py b/src/cloudflare/types/registrar/domain_update_params.py index c69ee2fe840..5c6da427594 100644 --- a/src/cloudflare/types/registrar/domain_update_params.py +++ b/src/cloudflare/types/registrar/domain_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DomainUpdateParams"] class DomainUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" auto_renew: bool diff --git a/src/cloudflare/types/registrar/registrar_check_params.py b/src/cloudflare/types/registrar/registrar_check_params.py index fd48b15dc15..663932047ff 100644 --- a/src/cloudflare/types/registrar/registrar_check_params.py +++ b/src/cloudflare/types/registrar/registrar_check_params.py @@ -10,7 +10,7 @@ class RegistrarCheckParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" domains: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/registrar/registrar_search_params.py b/src/cloudflare/types/registrar/registrar_search_params.py index 4dc2945e42c..bbd35e7e9b5 100644 --- a/src/cloudflare/types/registrar/registrar_search_params.py +++ b/src/cloudflare/types/registrar/registrar_search_params.py @@ -10,7 +10,7 @@ class RegistrarSearchParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" q: Required[str] diff --git a/src/cloudflare/types/registrar/registration_create_params.py b/src/cloudflare/types/registrar/registration_create_params.py index 6ff16a019ed..b4b5022a4c2 100644 --- a/src/cloudflare/types/registrar/registration_create_params.py +++ b/src/cloudflare/types/registrar/registration_create_params.py @@ -16,7 +16,7 @@ class RegistrationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" domain_name: Required[str] diff --git a/src/cloudflare/types/registrar/registration_edit_params.py b/src/cloudflare/types/registrar/registration_edit_params.py index 348b9fb99bd..48f70de8f16 100644 --- a/src/cloudflare/types/registrar/registration_edit_params.py +++ b/src/cloudflare/types/registrar/registration_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -10,7 +10,7 @@ class RegistrationEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" auto_renew: bool diff --git a/src/cloudflare/types/registrar/registration_list_params.py b/src/cloudflare/types/registrar/registration_list_params.py new file mode 100644 index 00000000000..962e7562dfd --- /dev/null +++ b/src/cloudflare/types/registrar/registration_list_params.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, TypedDict + +__all__ = ["RegistrationListParams"] + + +class RegistrationListParams(TypedDict, total=False): + account_id: str + """Identifier""" + + cursor: str + """ + Opaque token from a previous response's `result_info.cursor`. Pass this value to + fetch the next page of results. Omit (or pass an empty string) for the first + page. + """ + + direction: Literal["asc", "desc"] + """Sort direction for results. Defaults to ascending order.""" + + per_page: int + """Number of items to return per page.""" + + sort_by: Literal["registry_created_at", "registry_expires_at", "name"] + """Column to sort results by. + + Defaults to registration date (`registry_created_at`) when omitted. + """ diff --git a/src/cloudflare/types/request_tracers/trace_create_params.py b/src/cloudflare/types/request_tracers/trace_create_params.py index 184d290a90a..999190ed744 100644 --- a/src/cloudflare/types/request_tracers/trace_create_params.py +++ b/src/cloudflare/types/request_tracers/trace_create_params.py @@ -9,7 +9,7 @@ class TraceCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" method: Required[str] diff --git a/src/cloudflare/types/resource_sharing/recipient_create_params.py b/src/cloudflare/types/resource_sharing/recipient_create_params.py index 58b143bcada..6384dc2152e 100644 --- a/src/cloudflare/types/resource_sharing/recipient_create_params.py +++ b/src/cloudflare/types/resource_sharing/recipient_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -10,7 +10,7 @@ class RecipientCreateParams(TypedDict, total=False): - path_account_id: Required[Annotated[str, PropertyInfo(alias="account_id")]] + path_account_id: Annotated[str, PropertyInfo(alias="account_id")] """Account identifier.""" body_account_id: Annotated[str, PropertyInfo(alias="account_id")] diff --git a/src/cloudflare/types/resource_sharing/recipient_get_params.py b/src/cloudflare/types/resource_sharing/recipient_get_params.py index beaa5c36c21..b451cbcb69e 100644 --- a/src/cloudflare/types/resource_sharing/recipient_get_params.py +++ b/src/cloudflare/types/resource_sharing/recipient_get_params.py @@ -8,7 +8,7 @@ class RecipientGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier.""" share_id: Required[str] diff --git a/src/cloudflare/types/resource_sharing/recipient_list_params.py b/src/cloudflare/types/resource_sharing/recipient_list_params.py index 81723455101..5907b690150 100644 --- a/src/cloudflare/types/resource_sharing/recipient_list_params.py +++ b/src/cloudflare/types/resource_sharing/recipient_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["RecipientListParams"] class RecipientListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier.""" include_resources: bool diff --git a/src/cloudflare/types/resource_sharing/resource_create_params.py b/src/cloudflare/types/resource_sharing/resource_create_params.py index a5b1f95764f..6e4122fe3b9 100644 --- a/src/cloudflare/types/resource_sharing/resource_create_params.py +++ b/src/cloudflare/types/resource_sharing/resource_create_params.py @@ -8,7 +8,7 @@ class ResourceCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier.""" meta: Required[object] diff --git a/src/cloudflare/types/resource_sharing/resource_list_params.py b/src/cloudflare/types/resource_sharing/resource_list_params.py index cad9c27cae1..2103dce349c 100644 --- a/src/cloudflare/types/resource_sharing/resource_list_params.py +++ b/src/cloudflare/types/resource_sharing/resource_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ResourceListParams"] class ResourceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier.""" page: int diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_create_params.py b/src/cloudflare/types/resource_sharing/resource_sharing_create_params.py index d5adacfdba7..3f7c75a4670 100644 --- a/src/cloudflare/types/resource_sharing/resource_sharing_create_params.py +++ b/src/cloudflare/types/resource_sharing/resource_sharing_create_params.py @@ -9,7 +9,7 @@ class ResourceSharingCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier.""" name: Required[str] diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_get_params.py b/src/cloudflare/types/resource_sharing/resource_sharing_get_params.py index a84c94c5892..c905d9e8636 100644 --- a/src/cloudflare/types/resource_sharing/resource_sharing_get_params.py +++ b/src/cloudflare/types/resource_sharing/resource_sharing_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ResourceSharingGetParams"] class ResourceSharingGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier.""" include_recipient_counts: bool diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_list_params.py b/src/cloudflare/types/resource_sharing/resource_sharing_list_params.py index 5b96649e2c3..dd1195de629 100644 --- a/src/cloudflare/types/resource_sharing/resource_sharing_list_params.py +++ b/src/cloudflare/types/resource_sharing/resource_sharing_list_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ResourceSharingListParams"] class ResourceSharingListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_update_params.py b/src/cloudflare/types/resource_sharing/resource_sharing_update_params.py index 6d796532f5a..35cfcffb627 100644 --- a/src/cloudflare/types/resource_sharing/resource_sharing_update_params.py +++ b/src/cloudflare/types/resource_sharing/resource_sharing_update_params.py @@ -8,7 +8,7 @@ class ResourceSharingUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier.""" name: Required[str] diff --git a/src/cloudflare/types/resource_sharing/resource_update_params.py b/src/cloudflare/types/resource_sharing/resource_update_params.py index d69bbdc0eb0..23c469c064e 100644 --- a/src/cloudflare/types/resource_sharing/resource_update_params.py +++ b/src/cloudflare/types/resource_sharing/resource_update_params.py @@ -8,7 +8,7 @@ class ResourceUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier.""" share_id: Required[str] diff --git a/src/cloudflare/types/resource_tagging/account_tag_get_params.py b/src/cloudflare/types/resource_tagging/account_tag_get_params.py index 7a0340f55ab..919526e9260 100644 --- a/src/cloudflare/types/resource_tagging/account_tag_get_params.py +++ b/src/cloudflare/types/resource_tagging/account_tag_get_params.py @@ -8,7 +8,7 @@ class AccountTagGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" resource_id: Required[str] diff --git a/src/cloudflare/types/resource_tagging/account_tag_update_params.py b/src/cloudflare/types/resource_tagging/account_tag_update_params.py index 1fb41f29a2a..7b2e6ebe08d 100644 --- a/src/cloudflare/types/resource_tagging/account_tag_update_params.py +++ b/src/cloudflare/types/resource_tagging/account_tag_update_params.py @@ -15,7 +15,7 @@ class ResourceTaggingSetTagsRequestAccountLevelWorkerVersion(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" resource_id: Required[str] @@ -60,7 +60,7 @@ class ResourceTaggingSetTagsRequestAccountLevelWorkerVersion(TypedDict, total=Fa class ResourceTaggingSetTagsRequestAccountLevelBase(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" resource_id: Required[str] diff --git a/src/cloudflare/types/resource_tagging/key_list_params.py b/src/cloudflare/types/resource_tagging/key_list_params.py index 3511a00e252..6dd43633fdd 100644 --- a/src/cloudflare/types/resource_tagging/key_list_params.py +++ b/src/cloudflare/types/resource_tagging/key_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["KeyListParams"] class KeyListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" cursor: str diff --git a/src/cloudflare/types/resource_tagging/resource_tagging_list_params.py b/src/cloudflare/types/resource_tagging/resource_tagging_list_params.py index ed7e4758489..c1e5f8a9459 100644 --- a/src/cloudflare/types/resource_tagging/resource_tagging_list_params.py +++ b/src/cloudflare/types/resource_tagging/resource_tagging_list_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -11,7 +11,7 @@ class ResourceTaggingListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" cursor: str diff --git a/src/cloudflare/types/resource_tagging/value_list_params.py b/src/cloudflare/types/resource_tagging/value_list_params.py index f154de3a39c..66b79beb171 100644 --- a/src/cloudflare/types/resource_tagging/value_list_params.py +++ b/src/cloudflare/types/resource_tagging/value_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ValueListParams"] class ValueListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" cursor: str diff --git a/src/cloudflare/types/resource_tagging/zone_tag_get_params.py b/src/cloudflare/types/resource_tagging/zone_tag_get_params.py index 41e8fbbbe22..b2a511fdffd 100644 --- a/src/cloudflare/types/resource_tagging/zone_tag_get_params.py +++ b/src/cloudflare/types/resource_tagging/zone_tag_get_params.py @@ -8,7 +8,7 @@ class ZoneTagGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Zone ID is required only for zone-level resources""" resource_id: Required[str] diff --git a/src/cloudflare/types/resource_tagging/zone_tag_update_params.py b/src/cloudflare/types/resource_tagging/zone_tag_update_params.py index 9b9fa8a54fa..8542e88dffb 100644 --- a/src/cloudflare/types/resource_tagging/zone_tag_update_params.py +++ b/src/cloudflare/types/resource_tagging/zone_tag_update_params.py @@ -15,7 +15,7 @@ class ResourceTaggingSetTagsRequestZoneLevelBase(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Zone ID is required only for zone-level resources""" resource_id: Required[str] @@ -40,7 +40,7 @@ class ResourceTaggingSetTagsRequestZoneLevelBase(TypedDict, total=False): class ResourceTaggingSetTagsRequestZoneLevelAccessApplicationPolicy(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Zone ID is required only for zone-level resources""" access_application_id: Required[str] diff --git a/src/cloudflare/types/rules/list_create_params.py b/src/cloudflare/types/rules/list_create_params.py index a0ecda97394..62f9c943133 100644 --- a/src/cloudflare/types/rules/list_create_params.py +++ b/src/cloudflare/types/rules/list_create_params.py @@ -8,7 +8,7 @@ class ListCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The Account ID for this resource.""" kind: Required[Literal["ip", "redirect", "hostname", "asn"]] diff --git a/src/cloudflare/types/rules/list_update_params.py b/src/cloudflare/types/rules/list_update_params.py index 1b37842360b..1620290507b 100644 --- a/src/cloudflare/types/rules/list_update_params.py +++ b/src/cloudflare/types/rules/list_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ListUpdateParams"] class ListUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The Account ID for this resource.""" description: str diff --git a/src/cloudflare/types/rules/lists/item_create_params.py b/src/cloudflare/types/rules/lists/item_create_params.py index d8d4e8646eb..ad17ea76f4a 100644 --- a/src/cloudflare/types/rules/lists/item_create_params.py +++ b/src/cloudflare/types/rules/lists/item_create_params.py @@ -19,7 +19,7 @@ class ItemCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The Account ID for this resource.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/rules/lists/item_delete_params.py b/src/cloudflare/types/rules/lists/item_delete_params.py index 9ab6856dad9..8d917743119 100644 --- a/src/cloudflare/types/rules/lists/item_delete_params.py +++ b/src/cloudflare/types/rules/lists/item_delete_params.py @@ -9,7 +9,7 @@ class ItemDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The Account ID for this resource.""" items: Iterable[Item] diff --git a/src/cloudflare/types/rules/lists/item_list_params.py b/src/cloudflare/types/rules/lists/item_list_params.py index 55374a19c0b..bfd9cfd2a12 100644 --- a/src/cloudflare/types/rules/lists/item_list_params.py +++ b/src/cloudflare/types/rules/lists/item_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ItemListParams"] class ItemListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The Account ID for this resource.""" cursor: str diff --git a/src/cloudflare/types/rules/lists/item_update_params.py b/src/cloudflare/types/rules/lists/item_update_params.py index f61262a02c8..cc3c5b8d02b 100644 --- a/src/cloudflare/types/rules/lists/item_update_params.py +++ b/src/cloudflare/types/rules/lists/item_update_params.py @@ -19,7 +19,7 @@ class ItemUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The Account ID for this resource.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/rulesets/__init__.py b/src/cloudflare/types/rulesets/__init__.py index 21370d47a1e..933d9d20abc 100644 --- a/src/cloudflare/types/rulesets/__init__.py +++ b/src/cloudflare/types/rulesets/__init__.py @@ -4,3 +4,54 @@ from .kind import Kind as Kind from .phase import Phase as Phase +from .logging import Logging as Logging +from .log_rule import LogRule as LogRule +from .skip_rule import SkipRule as SkipRule +from .block_rule import BlockRule as BlockRule +from .route_rule import RouteRule as RouteRule +from .score_rule import ScoreRule as ScoreRule +from .execute_rule import ExecuteRule as ExecuteRule +from .rewrite_rule import RewriteRule as RewriteRule +from .logging_param import LoggingParam as LoggingParam +from .redirect_rule import RedirectRule as RedirectRule +from .log_rule_param import LogRuleParam as LogRuleParam +from .set_config_rule import SetConfigRule as SetConfigRule +from .skip_rule_param import SkipRuleParam as SkipRuleParam +from .block_rule_param import BlockRuleParam as BlockRuleParam +from .route_rule_param import RouteRuleParam as RouteRuleParam +from .rule_edit_params import RuleEditParams as RuleEditParams +from .score_rule_param import ScoreRuleParam as ScoreRuleParam +from .serve_error_rule import ServeErrorRule as ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule as DDoSDynamicRule +from .execute_rule_param import ExecuteRuleParam as ExecuteRuleParam +from .phase_get_response import PhaseGetResponse as PhaseGetResponse +from .rewrite_rule_param import RewriteRuleParam as RewriteRuleParam +from .rule_create_params import RuleCreateParams as RuleCreateParams +from .rule_edit_response import RuleEditResponse as RuleEditResponse +from .phase_update_params import PhaseUpdateParams as PhaseUpdateParams +from .redirect_rule_param import RedirectRuleParam as RedirectRuleParam +from .ruleset_list_params import RulesetListParams as RulesetListParams +from .rule_create_response import RuleCreateResponse as RuleCreateResponse +from .rule_delete_response import RuleDeleteResponse as RuleDeleteResponse +from .ruleset_get_response import RulesetGetResponse as RulesetGetResponse +from .version_get_response import VersionGetResponse as VersionGetResponse +from .log_custom_field_rule import LogCustomFieldRule as LogCustomFieldRule +from .phase_update_response import PhaseUpdateResponse as PhaseUpdateResponse +from .ruleset_create_params import RulesetCreateParams as RulesetCreateParams +from .ruleset_list_response import RulesetListResponse as RulesetListResponse +from .ruleset_update_params import RulesetUpdateParams as RulesetUpdateParams +from .set_config_rule_param import SetConfigRuleParam as SetConfigRuleParam +from .version_list_response import VersionListResponse as VersionListResponse +from .compress_response_rule import CompressResponseRule as CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule as ManagedChallengeRule +from .serve_error_rule_param import ServeErrorRuleParam as ServeErrorRuleParam +from .ddos_dynamic_rule_param import DDoSDynamicRuleParam as DDoSDynamicRuleParam +from .ruleset_create_response import RulesetCreateResponse as RulesetCreateResponse +from .ruleset_update_response import RulesetUpdateResponse as RulesetUpdateResponse +from .set_cache_settings_rule import SetCacheSettingsRule as SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule as ForceConnectionCloseRule +from .log_custom_field_rule_param import LogCustomFieldRuleParam as LogCustomFieldRuleParam +from .compress_response_rule_param import CompressResponseRuleParam as CompressResponseRuleParam +from .managed_challenge_rule_param import ManagedChallengeRuleParam as ManagedChallengeRuleParam +from .set_cache_settings_rule_param import SetCacheSettingsRuleParam as SetCacheSettingsRuleParam +from .force_connection_close_rule_param import ForceConnectionCloseRuleParam as ForceConnectionCloseRuleParam diff --git a/src/cloudflare/types/rulesets/block_rule.py b/src/cloudflare/types/rulesets/block_rule.py new file mode 100644 index 00000000000..61fa89b2bf7 --- /dev/null +++ b/src/cloudflare/types/rulesets/block_rule.py @@ -0,0 +1,127 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = ["BlockRule", "ActionParameters", "ActionParametersResponse", "ExposedCredentialCheck", "Ratelimit"] + + +class ActionParametersResponse(BaseModel): + """The response to show when the block is applied.""" + + content: str + """The content to return.""" + + content_type: str + """The type of the content to return.""" + + status_code: int + """The status code to return.""" + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + response: Optional[ActionParametersResponse] = None + """The response to show when the block is applied.""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class BlockRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["block"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/block_rule_param.py b/src/cloudflare/types/rulesets/block_rule_param.py new file mode 100644 index 00000000000..7eff7a06dc0 --- /dev/null +++ b/src/cloudflare/types/rulesets/block_rule_param.py @@ -0,0 +1,118 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = ["BlockRuleParam", "ActionParameters", "ActionParametersResponse", "ExposedCredentialCheck", "Ratelimit"] + + +class ActionParametersResponse(TypedDict, total=False): + """The response to show when the block is applied.""" + + content: Required[str] + """The content to return.""" + + content_type: Required[str] + """The type of the content to return.""" + + status_code: Required[int] + """The status code to return.""" + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + response: ActionParametersResponse + """The response to show when the block is applied.""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class BlockRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["block"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/compress_response_rule.py b/src/cloudflare/types/rulesets/compress_response_rule.py new file mode 100644 index 00000000000..8f6125645c7 --- /dev/null +++ b/src/cloudflare/types/rulesets/compress_response_rule.py @@ -0,0 +1,127 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = [ + "CompressResponseRule", + "ActionParameters", + "ActionParametersAlgorithm", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersAlgorithm(BaseModel): + """Compression algorithm to enable.""" + + name: Optional[Literal["none", "auto", "default", "gzip", "brotli", "zstd"]] = None + """Name of the compression algorithm to enable.""" + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + algorithms: List[ActionParametersAlgorithm] + """Custom order for compression algorithms.""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class CompressResponseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/compress_response_rule_param.py b/src/cloudflare/types/rulesets/compress_response_rule_param.py new file mode 100644 index 00000000000..2caf924b41d --- /dev/null +++ b/src/cloudflare/types/rulesets/compress_response_rule_param.py @@ -0,0 +1,119 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = [ + "CompressResponseRuleParam", + "ActionParameters", + "ActionParametersAlgorithm", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersAlgorithm(TypedDict, total=False): + """Compression algorithm to enable.""" + + name: Literal["none", "auto", "default", "gzip", "brotli", "zstd"] + """Name of the compression algorithm to enable.""" + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + algorithms: Required[Iterable[ActionParametersAlgorithm]] + """Custom order for compression algorithms.""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class CompressResponseRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["compress_response"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/ddos_dynamic_rule.py b/src/cloudflare/types/rulesets/ddos_dynamic_rule.py new file mode 100644 index 00000000000..f20ca932ab1 --- /dev/null +++ b/src/cloudflare/types/rulesets/ddos_dynamic_rule.py @@ -0,0 +1,107 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = ["DDoSDynamicRule", "ExposedCredentialCheck", "Ratelimit"] + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class DDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/ddos_dynamic_rule_param.py b/src/cloudflare/types/rulesets/ddos_dynamic_rule_param.py new file mode 100644 index 00000000000..d150078bb63 --- /dev/null +++ b/src/cloudflare/types/rulesets/ddos_dynamic_rule_param.py @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = ["DDoSDynamicRuleParam", "ExposedCredentialCheck", "Ratelimit"] + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class DDoSDynamicRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/execute_rule.py b/src/cloudflare/types/rulesets/execute_rule.py new file mode 100644 index 00000000000..83dc8ed46e8 --- /dev/null +++ b/src/cloudflare/types/rulesets/execute_rule.py @@ -0,0 +1,209 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = [ + "ExecuteRule", + "ActionParameters", + "ActionParametersMatchedData", + "ActionParametersOverrides", + "ActionParametersOverridesCategory", + "ActionParametersOverridesRule", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersMatchedData(BaseModel): + """The configuration to use for matched data logging.""" + + public_key: str + """The public key to encrypt matched data logs with.""" + + +class ActionParametersOverridesCategory(BaseModel): + """A category-level override.""" + + category: str + """The name of the category to override.""" + + action: Optional[str] = None + """The action to override rules in the category with.""" + + enabled: Optional[bool] = None + """Whether to enable execution of rules in the category.""" + + sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None + """The sensitivity level to use for rules in the category. + + This option is only applicable for DDoS phases. + """ + + +class ActionParametersOverridesRule(BaseModel): + """A rule-level override.""" + + id: str + """The ID of the rule to override.""" + + action: Optional[str] = None + """The action to override the rule with.""" + + enabled: Optional[bool] = None + """Whether to enable execution of the rule.""" + + score_threshold: Optional[int] = None + """The score threshold to use for the rule.""" + + sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None + """The sensitivity level to use for the rule. + + This option is only applicable for DDoS phases. + """ + + +class ActionParametersOverrides(BaseModel): + """A set of overrides to apply to the target ruleset.""" + + action: Optional[str] = None + """An action to override all rules with. + + This option has lower precedence than rule and category overrides. + """ + + categories: Optional[List[ActionParametersOverridesCategory]] = None + """A list of category-level overrides. + + This option has the second-highest precedence after rule-level overrides. + """ + + enabled: Optional[bool] = None + """Whether to enable execution of all rules. + + This option has lower precedence than rule and category overrides. + """ + + rules: Optional[List[ActionParametersOverridesRule]] = None + """A list of rule-level overrides. This option has the highest precedence.""" + + sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None + """A sensitivity level to set for all rules. + + This option has lower precedence than rule and category overrides and is only + applicable for DDoS phases. + """ + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + id: str + """The ID of the ruleset to execute.""" + + matched_data: Optional[ActionParametersMatchedData] = None + """The configuration to use for matched data logging.""" + + overrides: Optional[ActionParametersOverrides] = None + """A set of overrides to apply to the target ruleset.""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ExecuteRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["execute"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/execute_rule_param.py b/src/cloudflare/types/rulesets/execute_rule_param.py new file mode 100644 index 00000000000..e9ba2dd6941 --- /dev/null +++ b/src/cloudflare/types/rulesets/execute_rule_param.py @@ -0,0 +1,201 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = [ + "ExecuteRuleParam", + "ActionParameters", + "ActionParametersMatchedData", + "ActionParametersOverrides", + "ActionParametersOverridesCategory", + "ActionParametersOverridesRule", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersMatchedData(TypedDict, total=False): + """The configuration to use for matched data logging.""" + + public_key: Required[str] + """The public key to encrypt matched data logs with.""" + + +class ActionParametersOverridesCategory(TypedDict, total=False): + """A category-level override.""" + + category: Required[str] + """The name of the category to override.""" + + action: str + """The action to override rules in the category with.""" + + enabled: bool + """Whether to enable execution of rules in the category.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """The sensitivity level to use for rules in the category. + + This option is only applicable for DDoS phases. + """ + + +class ActionParametersOverridesRule(TypedDict, total=False): + """A rule-level override.""" + + id: Required[str] + """The ID of the rule to override.""" + + action: str + """The action to override the rule with.""" + + enabled: bool + """Whether to enable execution of the rule.""" + + score_threshold: int + """The score threshold to use for the rule.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """The sensitivity level to use for the rule. + + This option is only applicable for DDoS phases. + """ + + +class ActionParametersOverrides(TypedDict, total=False): + """A set of overrides to apply to the target ruleset.""" + + action: str + """An action to override all rules with. + + This option has lower precedence than rule and category overrides. + """ + + categories: Iterable[ActionParametersOverridesCategory] + """A list of category-level overrides. + + This option has the second-highest precedence after rule-level overrides. + """ + + enabled: bool + """Whether to enable execution of all rules. + + This option has lower precedence than rule and category overrides. + """ + + rules: Iterable[ActionParametersOverridesRule] + """A list of rule-level overrides. This option has the highest precedence.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """A sensitivity level to set for all rules. + + This option has lower precedence than rule and category overrides and is only + applicable for DDoS phases. + """ + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + id: Required[str] + """The ID of the ruleset to execute.""" + + matched_data: ActionParametersMatchedData + """The configuration to use for matched data logging.""" + + overrides: ActionParametersOverrides + """A set of overrides to apply to the target ruleset.""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ExecuteRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["execute"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/force_connection_close_rule.py b/src/cloudflare/types/rulesets/force_connection_close_rule.py new file mode 100644 index 00000000000..230d272aa4a --- /dev/null +++ b/src/cloudflare/types/rulesets/force_connection_close_rule.py @@ -0,0 +1,107 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = ["ForceConnectionCloseRule", "ExposedCredentialCheck", "Ratelimit"] + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/force_connection_close_rule_param.py b/src/cloudflare/types/rulesets/force_connection_close_rule_param.py new file mode 100644 index 00000000000..9460ef34feb --- /dev/null +++ b/src/cloudflare/types/rulesets/force_connection_close_rule_param.py @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = ["ForceConnectionCloseRuleParam", "ExposedCredentialCheck", "Ratelimit"] + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ForceConnectionCloseRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/log_custom_field_rule.py b/src/cloudflare/types/rulesets/log_custom_field_rule.py new file mode 100644 index 00000000000..e66dcc3c0f9 --- /dev/null +++ b/src/cloudflare/types/rulesets/log_custom_field_rule.py @@ -0,0 +1,177 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = [ + "LogCustomFieldRule", + "ActionParameters", + "ActionParametersCookieField", + "ActionParametersRawResponseField", + "ActionParametersRequestField", + "ActionParametersResponseField", + "ActionParametersTransformedRequestField", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersCookieField(BaseModel): + """The cookie field to log.""" + + name: str + """The name of the cookie.""" + + +class ActionParametersRawResponseField(BaseModel): + """The raw response field to log.""" + + name: str + """The name of the response header.""" + + preserve_duplicates: Optional[bool] = None + """Whether to log duplicate values of the same header.""" + + +class ActionParametersRequestField(BaseModel): + """The raw request field to log.""" + + name: str + """The name of the header.""" + + +class ActionParametersResponseField(BaseModel): + """The transformed response field to log.""" + + name: str + """The name of the response header.""" + + preserve_duplicates: Optional[bool] = None + """Whether to log duplicate values of the same header.""" + + +class ActionParametersTransformedRequestField(BaseModel): + """The transformed request field to log.""" + + name: str + """The name of the header.""" + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + cookie_fields: Optional[List[ActionParametersCookieField]] = None + """The cookie fields to log.""" + + raw_response_fields: Optional[List[ActionParametersRawResponseField]] = None + """The raw response fields to log.""" + + request_fields: Optional[List[ActionParametersRequestField]] = None + """The raw request fields to log.""" + + response_fields: Optional[List[ActionParametersResponseField]] = None + """The transformed response fields to log.""" + + transformed_request_fields: Optional[List[ActionParametersTransformedRequestField]] = None + """The transformed request fields to log.""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class LogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/log_custom_field_rule_param.py b/src/cloudflare/types/rulesets/log_custom_field_rule_param.py new file mode 100644 index 00000000000..b6cdbaaf767 --- /dev/null +++ b/src/cloudflare/types/rulesets/log_custom_field_rule_param.py @@ -0,0 +1,169 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = [ + "LogCustomFieldRuleParam", + "ActionParameters", + "ActionParametersCookieField", + "ActionParametersRawResponseField", + "ActionParametersRequestField", + "ActionParametersResponseField", + "ActionParametersTransformedRequestField", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersCookieField(TypedDict, total=False): + """The cookie field to log.""" + + name: Required[str] + """The name of the cookie.""" + + +class ActionParametersRawResponseField(TypedDict, total=False): + """The raw response field to log.""" + + name: Required[str] + """The name of the response header.""" + + preserve_duplicates: bool + """Whether to log duplicate values of the same header.""" + + +class ActionParametersRequestField(TypedDict, total=False): + """The raw request field to log.""" + + name: Required[str] + """The name of the header.""" + + +class ActionParametersResponseField(TypedDict, total=False): + """The transformed response field to log.""" + + name: Required[str] + """The name of the response header.""" + + preserve_duplicates: bool + """Whether to log duplicate values of the same header.""" + + +class ActionParametersTransformedRequestField(TypedDict, total=False): + """The transformed request field to log.""" + + name: Required[str] + """The name of the header.""" + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + cookie_fields: Iterable[ActionParametersCookieField] + """The cookie fields to log.""" + + raw_response_fields: Iterable[ActionParametersRawResponseField] + """The raw response fields to log.""" + + request_fields: Iterable[ActionParametersRequestField] + """The raw request fields to log.""" + + response_fields: Iterable[ActionParametersResponseField] + """The transformed response fields to log.""" + + transformed_request_fields: Iterable[ActionParametersTransformedRequestField] + """The transformed request fields to log.""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class LogCustomFieldRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["log_custom_field"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/log_rule.py b/src/cloudflare/types/rulesets/log_rule.py new file mode 100644 index 00000000000..8248a6299cb --- /dev/null +++ b/src/cloudflare/types/rulesets/log_rule.py @@ -0,0 +1,107 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = ["LogRule", "ExposedCredentialCheck", "Ratelimit"] + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class LogRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/log_rule_param.py b/src/cloudflare/types/rulesets/log_rule_param.py new file mode 100644 index 00000000000..ed168f80dda --- /dev/null +++ b/src/cloudflare/types/rulesets/log_rule_param.py @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = ["LogRuleParam", "ExposedCredentialCheck", "Ratelimit"] + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class LogRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["log"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/logging.py b/src/cloudflare/types/rulesets/logging.py new file mode 100644 index 00000000000..4394ddda28b --- /dev/null +++ b/src/cloudflare/types/rulesets/logging.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from ..._models import BaseModel + +__all__ = ["Logging"] + + +class Logging(BaseModel): + """An object configuring the rule's logging behavior.""" + + enabled: bool + """Whether to generate a log when the rule matches.""" diff --git a/src/cloudflare/types/rulesets/logging_param.py b/src/cloudflare/types/rulesets/logging_param.py new file mode 100644 index 00000000000..44483e01871 --- /dev/null +++ b/src/cloudflare/types/rulesets/logging_param.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["LoggingParam"] + + +class LoggingParam(TypedDict, total=False): + """An object configuring the rule's logging behavior.""" + + enabled: Required[bool] + """Whether to generate a log when the rule matches.""" diff --git a/src/cloudflare/types/rulesets/managed_challenge_rule.py b/src/cloudflare/types/rulesets/managed_challenge_rule.py new file mode 100644 index 00000000000..9cdd21ea69c --- /dev/null +++ b/src/cloudflare/types/rulesets/managed_challenge_rule.py @@ -0,0 +1,107 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = ["ManagedChallengeRule", "ExposedCredentialCheck", "Ratelimit"] + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ManagedChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["managed_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/managed_challenge_rule_param.py b/src/cloudflare/types/rulesets/managed_challenge_rule_param.py new file mode 100644 index 00000000000..60986b78886 --- /dev/null +++ b/src/cloudflare/types/rulesets/managed_challenge_rule_param.py @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = ["ManagedChallengeRuleParam", "ExposedCredentialCheck", "Ratelimit"] + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ManagedChallengeRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["managed_challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py new file mode 100644 index 00000000000..b9552130335 --- /dev/null +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from .kind import Kind +from .phase import Phase +from .logging import Logging +from ..._utils import PropertyInfo +from .log_rule import LogRule +from ..._models import BaseModel +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .route_rule import RouteRule +from .score_rule import ScoreRule +from .execute_rule import ExecuteRule +from .rewrite_rule import RewriteRule +from .redirect_rule import RedirectRule +from .set_config_rule import SetConfigRule +from .serve_error_rule import ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule +from .log_custom_field_rule import LogCustomFieldRule +from .compress_response_rule import CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule +from .set_cache_settings_rule import SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "PhaseGetResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class PhaseGetResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py new file mode 100644 index 00000000000..1a17a4c6063 --- /dev/null +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -0,0 +1,989 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo +from .logging_param import LoggingParam +from .log_rule_param import LogRuleParam +from .skip_rule_param import SkipRuleParam +from .block_rule_param import BlockRuleParam +from .route_rule_param import RouteRuleParam +from .score_rule_param import ScoreRuleParam +from .execute_rule_param import ExecuteRuleParam +from .rewrite_rule_param import RewriteRuleParam +from .redirect_rule_param import RedirectRuleParam +from .set_config_rule_param import SetConfigRuleParam +from .serve_error_rule_param import ServeErrorRuleParam +from .ddos_dynamic_rule_param import DDoSDynamicRuleParam +from .log_custom_field_rule_param import LogCustomFieldRuleParam +from .compress_response_rule_param import CompressResponseRuleParam +from .managed_challenge_rule_param import ManagedChallengeRuleParam +from .set_cache_settings_rule_param import SetCacheSettingsRuleParam +from .force_connection_close_rule_param import ForceConnectionCloseRuleParam + +__all__ = [ + "PhaseUpdateParams", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class PhaseUpdateParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + description: str + """An informative description of the ruleset.""" + + name: str + """The human-readable name of the ruleset.""" + + rules: Iterable[Rule] + """The list of rules in the ruleset.""" + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsJSChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsJSChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: RuleRulesetsSetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[RuleRulesetsSetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate") + ] + """A cache-control directive configuration.""" + + must_understand: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand") + ] + """A cache-control directive configuration.""" + + no_cache: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform") + ] + """A cache-control directive configuration.""" + + private: RuleRulesetsSetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: RuleRulesetsSetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[RuleRulesetsSetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate, + PropertyInfo(alias="stale-while-revalidate"), + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Union[ + BlockRuleParam, + RuleRulesetsChallengeRule, + CompressResponseRuleParam, + DDoSDynamicRuleParam, + ExecuteRuleParam, + ForceConnectionCloseRuleParam, + RuleRulesetsJSChallengeRule, + LogRuleParam, + LogCustomFieldRuleParam, + ManagedChallengeRuleParam, + RedirectRuleParam, + RewriteRuleParam, + RouteRuleParam, + ScoreRuleParam, + ServeErrorRuleParam, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRuleParam, + RuleRulesetsSetCacheTagsRule, + SetConfigRuleParam, + SkipRuleParam, +] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py new file mode 100644 index 00000000000..9b06f4b181e --- /dev/null +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from .kind import Kind +from .phase import Phase +from .logging import Logging +from ..._utils import PropertyInfo +from .log_rule import LogRule +from ..._models import BaseModel +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .route_rule import RouteRule +from .score_rule import ScoreRule +from .execute_rule import ExecuteRule +from .rewrite_rule import RewriteRule +from .redirect_rule import RedirectRule +from .set_config_rule import SetConfigRule +from .serve_error_rule import ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule +from .log_custom_field_rule import LogCustomFieldRule +from .compress_response_rule import CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule +from .set_cache_settings_rule import SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "PhaseUpdateResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class PhaseUpdateResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/phases/__init__.py b/src/cloudflare/types/rulesets/phases/__init__.py index f8ee8b14b1c..5a719b3e523 100644 --- a/src/cloudflare/types/rulesets/phases/__init__.py +++ b/src/cloudflare/types/rulesets/phases/__init__.py @@ -1,3 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .version_get_response import VersionGetResponse as VersionGetResponse +from .version_list_response import VersionListResponse as VersionListResponse diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py new file mode 100644 index 00000000000..d6f80e98ed8 --- /dev/null +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from ..kind import Kind +from ..phase import Phase +from ..logging import Logging +from ...._utils import PropertyInfo +from ..log_rule import LogRule +from ...._models import BaseModel +from ..skip_rule import SkipRule +from ..block_rule import BlockRule +from ..route_rule import RouteRule +from ..score_rule import ScoreRule +from ..execute_rule import ExecuteRule +from ..rewrite_rule import RewriteRule +from ..redirect_rule import RedirectRule +from ..set_config_rule import SetConfigRule +from ..serve_error_rule import ServeErrorRule +from ..ddos_dynamic_rule import DDoSDynamicRule +from ..log_custom_field_rule import LogCustomFieldRule +from ..compress_response_rule import CompressResponseRule +from ..managed_challenge_rule import ManagedChallengeRule +from ..set_cache_settings_rule import SetCacheSettingsRule +from ..force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "VersionGetResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class VersionGetResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/phases/version_list_response.py b/src/cloudflare/types/rulesets/phases/version_list_response.py new file mode 100644 index 00000000000..fbdd2b8b4cf --- /dev/null +++ b/src/cloudflare/types/rulesets/phases/version_list_response.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..kind import Kind +from ..phase import Phase +from ...._models import BaseModel + +__all__ = ["VersionListResponse"] + + +class VersionListResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/redirect_rule.py b/src/cloudflare/types/rulesets/redirect_rule.py new file mode 100644 index 00000000000..22fa69bc894 --- /dev/null +++ b/src/cloudflare/types/rulesets/redirect_rule.py @@ -0,0 +1,158 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = [ + "RedirectRule", + "ActionParameters", + "ActionParametersFromList", + "ActionParametersFromValue", + "ActionParametersFromValueTargetURL", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersFromList(BaseModel): + """A redirect based on a bulk list lookup.""" + + key: str + """An expression that evaluates to the list lookup key.""" + + name: str + """The name of the list to match against.""" + + +class ActionParametersFromValueTargetURL(BaseModel): + """A URL to redirect the request to.""" + + expression: Optional[str] = None + """An expression that evaluates to a URL to redirect the request to.""" + + value: Optional[str] = None + """A URL to redirect the request to.""" + + +class ActionParametersFromValue(BaseModel): + """A redirect based on the request properties.""" + + target_url: ActionParametersFromValueTargetURL + """A URL to redirect the request to.""" + + preserve_query_string: Optional[bool] = None + """Whether to keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to use for the redirect.""" + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + from_list: Optional[ActionParametersFromList] = None + """A redirect based on a bulk list lookup.""" + + from_value: Optional[ActionParametersFromValue] = None + """A redirect based on the request properties.""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RedirectRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/redirect_rule_param.py b/src/cloudflare/types/rulesets/redirect_rule_param.py new file mode 100644 index 00000000000..3e23bfaf78c --- /dev/null +++ b/src/cloudflare/types/rulesets/redirect_rule_param.py @@ -0,0 +1,149 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = [ + "RedirectRuleParam", + "ActionParameters", + "ActionParametersFromList", + "ActionParametersFromValue", + "ActionParametersFromValueTargetURL", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersFromList(TypedDict, total=False): + """A redirect based on a bulk list lookup.""" + + key: Required[str] + """An expression that evaluates to the list lookup key.""" + + name: Required[str] + """The name of the list to match against.""" + + +class ActionParametersFromValueTargetURL(TypedDict, total=False): + """A URL to redirect the request to.""" + + expression: str + """An expression that evaluates to a URL to redirect the request to.""" + + value: str + """A URL to redirect the request to.""" + + +class ActionParametersFromValue(TypedDict, total=False): + """A redirect based on the request properties.""" + + target_url: Required[ActionParametersFromValueTargetURL] + """A URL to redirect the request to.""" + + preserve_query_string: bool + """Whether to keep the query string of the original request.""" + + status_code: Literal[301, 302, 303, 307, 308] + """The status code to use for the redirect.""" + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + from_list: ActionParametersFromList + """A redirect based on a bulk list lookup.""" + + from_value: ActionParametersFromValue + """A redirect based on the request properties.""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RedirectRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["redirect"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/rewrite_rule.py b/src/cloudflare/types/rulesets/rewrite_rule.py new file mode 100644 index 00000000000..4071d1b1cff --- /dev/null +++ b/src/cloudflare/types/rulesets/rewrite_rule.py @@ -0,0 +1,232 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, TypeAlias + +from .logging import Logging +from ..._models import BaseModel + +__all__ = [ + "RewriteRule", + "ActionParameters", + "ActionParametersHeaders", + "ActionParametersHeadersAddStaticHeader", + "ActionParametersHeadersAddDynamicHeader", + "ActionParametersHeadersSetStaticHeader", + "ActionParametersHeadersSetDynamicHeader", + "ActionParametersHeadersRemoveHeader", + "ActionParametersURI", + "ActionParametersURIURIPath", + "ActionParametersURIURIPathPath", + "ActionParametersURIURIQuery", + "ActionParametersURIURIQueryQuery", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersHeadersAddStaticHeader(BaseModel): + """A header with a static value to add.""" + + operation: Literal["add"] + """The operation to perform on the header.""" + + value: str + """A static value for the header.""" + + +class ActionParametersHeadersAddDynamicHeader(BaseModel): + """A header with a dynamic value to add.""" + + expression: str + """An expression that evaluates to a value for the header.""" + + operation: Literal["add"] + """The operation to perform on the header.""" + + +class ActionParametersHeadersSetStaticHeader(BaseModel): + """A header with a static value to set.""" + + operation: Literal["set"] + """The operation to perform on the header.""" + + value: str + """A static value for the header.""" + + +class ActionParametersHeadersSetDynamicHeader(BaseModel): + """A header with a dynamic value to set.""" + + expression: str + """An expression that evaluates to a value for the header.""" + + operation: Literal["set"] + """The operation to perform on the header.""" + + +class ActionParametersHeadersRemoveHeader(BaseModel): + """A header to remove.""" + + operation: Literal["remove"] + """The operation to perform on the header.""" + + +ActionParametersHeaders: TypeAlias = Union[ + ActionParametersHeadersAddStaticHeader, + ActionParametersHeadersAddDynamicHeader, + ActionParametersHeadersSetStaticHeader, + ActionParametersHeadersSetDynamicHeader, + ActionParametersHeadersRemoveHeader, +] + + +class ActionParametersURIURIPathPath(BaseModel): + """A URI path rewrite.""" + + expression: Optional[str] = None + """An expression that evaluates to a value to rewrite the URI path to.""" + + value: Optional[str] = None + """A value to rewrite the URI path to.""" + + +class ActionParametersURIURIPath(BaseModel): + """A URI path rewrite.""" + + path: ActionParametersURIURIPathPath + """A URI path rewrite.""" + + origin: Optional[bool] = None + """Whether to propagate the rewritten URI to origin.""" + + +class ActionParametersURIURIQueryQuery(BaseModel): + """A URI query rewrite.""" + + expression: Optional[str] = None + """An expression that evaluates to a value to rewrite the URI query to.""" + + value: Optional[str] = None + """A value to rewrite the URI query to.""" + + +class ActionParametersURIURIQuery(BaseModel): + """A URI query rewrite.""" + + query: ActionParametersURIURIQueryQuery + """A URI query rewrite.""" + + origin: Optional[bool] = None + """Whether to propagate the rewritten URI to origin.""" + + +ActionParametersURI: TypeAlias = Union[ActionParametersURIURIPath, ActionParametersURIURIQuery] + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + headers: Optional[Dict[str, ActionParametersHeaders]] = None + """A map of headers to rewrite.""" + + uri: Optional[ActionParametersURI] = None + """A URI path rewrite.""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RewriteRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/rewrite_rule_param.py b/src/cloudflare/types/rulesets/rewrite_rule_param.py new file mode 100644 index 00000000000..75e18c4787d --- /dev/null +++ b/src/cloudflare/types/rulesets/rewrite_rule_param.py @@ -0,0 +1,218 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union +from typing_extensions import Literal, Required, TypeAlias, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = [ + "RewriteRuleParam", + "ActionParameters", + "ActionParametersHeaders", + "ActionParametersHeadersAddStaticHeader", + "ActionParametersHeadersAddDynamicHeader", + "ActionParametersHeadersSetStaticHeader", + "ActionParametersHeadersSetDynamicHeader", + "ActionParametersHeadersRemoveHeader", + "ActionParametersURI", + "ActionParametersURIURIPath", + "ActionParametersURIURIPathPath", + "ActionParametersURIURIQuery", + "ActionParametersURIURIQueryQuery", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersHeadersAddStaticHeader(TypedDict, total=False): + """A header with a static value to add.""" + + operation: Required[Literal["add"]] + """The operation to perform on the header.""" + + value: Required[str] + """A static value for the header.""" + + +class ActionParametersHeadersAddDynamicHeader(TypedDict, total=False): + """A header with a dynamic value to add.""" + + expression: Required[str] + """An expression that evaluates to a value for the header.""" + + operation: Required[Literal["add"]] + """The operation to perform on the header.""" + + +class ActionParametersHeadersSetStaticHeader(TypedDict, total=False): + """A header with a static value to set.""" + + operation: Required[Literal["set"]] + """The operation to perform on the header.""" + + value: Required[str] + """A static value for the header.""" + + +class ActionParametersHeadersSetDynamicHeader(TypedDict, total=False): + """A header with a dynamic value to set.""" + + expression: Required[str] + """An expression that evaluates to a value for the header.""" + + operation: Required[Literal["set"]] + """The operation to perform on the header.""" + + +class ActionParametersHeadersRemoveHeader(TypedDict, total=False): + """A header to remove.""" + + operation: Required[Literal["remove"]] + """The operation to perform on the header.""" + + +ActionParametersHeaders: TypeAlias = Union[ + ActionParametersHeadersAddStaticHeader, + ActionParametersHeadersAddDynamicHeader, + ActionParametersHeadersSetStaticHeader, + ActionParametersHeadersSetDynamicHeader, + ActionParametersHeadersRemoveHeader, +] + + +class ActionParametersURIURIPathPath(TypedDict, total=False): + """A URI path rewrite.""" + + expression: str + """An expression that evaluates to a value to rewrite the URI path to.""" + + value: str + """A value to rewrite the URI path to.""" + + +class ActionParametersURIURIPath(TypedDict, total=False): + """A URI path rewrite.""" + + path: Required[ActionParametersURIURIPathPath] + """A URI path rewrite.""" + + +class ActionParametersURIURIQueryQuery(TypedDict, total=False): + """A URI query rewrite.""" + + expression: str + """An expression that evaluates to a value to rewrite the URI query to.""" + + value: str + """A value to rewrite the URI query to.""" + + +class ActionParametersURIURIQuery(TypedDict, total=False): + """A URI query rewrite.""" + + query: Required[ActionParametersURIURIQueryQuery] + """A URI query rewrite.""" + + +ActionParametersURI: TypeAlias = Union[ActionParametersURIURIPath, ActionParametersURIURIQuery] + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + headers: Dict[str, ActionParametersHeaders] + """A map of headers to rewrite.""" + + uri: ActionParametersURI + """A URI path rewrite.""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RewriteRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["rewrite"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/route_rule.py b/src/cloudflare/types/rulesets/route_rule.py new file mode 100644 index 00000000000..41f3a739d56 --- /dev/null +++ b/src/cloudflare/types/rulesets/route_rule.py @@ -0,0 +1,144 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = [ + "RouteRule", + "ActionParameters", + "ActionParametersOrigin", + "ActionParametersSNI", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersOrigin(BaseModel): + """An origin to route to.""" + + host: Optional[str] = None + """A resolved host to route to.""" + + port: Optional[int] = None + """A destination port to route to.""" + + +class ActionParametersSNI(BaseModel): + """A Server Name Indication (SNI) override.""" + + value: str + """A value to override the SNI to.""" + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + host_header: Optional[str] = None + """A value to rewrite the HTTP host header to.""" + + origin: Optional[ActionParametersOrigin] = None + """An origin to route to.""" + + sni: Optional[ActionParametersSNI] = None + """A Server Name Indication (SNI) override.""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RouteRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/route_rule_param.py b/src/cloudflare/types/rulesets/route_rule_param.py new file mode 100644 index 00000000000..33cc97c8e86 --- /dev/null +++ b/src/cloudflare/types/rulesets/route_rule_param.py @@ -0,0 +1,135 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = [ + "RouteRuleParam", + "ActionParameters", + "ActionParametersOrigin", + "ActionParametersSNI", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersOrigin(TypedDict, total=False): + """An origin to route to.""" + + host: str + """A resolved host to route to.""" + + port: int + """A destination port to route to.""" + + +class ActionParametersSNI(TypedDict, total=False): + """A Server Name Indication (SNI) override.""" + + value: Required[str] + """A value to override the SNI to.""" + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + host_header: str + """A value to rewrite the HTTP host header to.""" + + origin: ActionParametersOrigin + """An origin to route to.""" + + sni: ActionParametersSNI + """A Server Name Indication (SNI) override.""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RouteRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["route"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py new file mode 100644 index 00000000000..6a8c82757e1 --- /dev/null +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -0,0 +1,4197 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Union, Iterable +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from .phase import Phase +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo +from .logging_param import LoggingParam + +__all__ = [ + "RuleCreateParams", + "BlockRule", + "BlockRuleActionParameters", + "BlockRuleActionParametersResponse", + "BlockRuleExposedCredentialCheck", + "BlockRulePosition", + "BlockRulePositionBeforePosition", + "BlockRulePositionAfterPosition", + "BlockRulePositionIndexPosition", + "BlockRuleRatelimit", + "ChallengeRule", + "ChallengeRuleExposedCredentialCheck", + "ChallengeRulePosition", + "ChallengeRulePositionBeforePosition", + "ChallengeRulePositionAfterPosition", + "ChallengeRulePositionIndexPosition", + "ChallengeRuleRatelimit", + "ResponseCompressionRule", + "ResponseCompressionRuleActionParameters", + "ResponseCompressionRuleActionParametersAlgorithm", + "ResponseCompressionRuleExposedCredentialCheck", + "ResponseCompressionRulePosition", + "ResponseCompressionRulePositionBeforePosition", + "ResponseCompressionRulePositionAfterPosition", + "ResponseCompressionRulePositionIndexPosition", + "ResponseCompressionRuleRatelimit", + "DDoSDynamicRule", + "DDoSDynamicRuleExposedCredentialCheck", + "DDoSDynamicRulePosition", + "DDoSDynamicRulePositionBeforePosition", + "DDoSDynamicRulePositionAfterPosition", + "DDoSDynamicRulePositionIndexPosition", + "DDoSDynamicRuleRatelimit", + "ExecuteRule", + "ExecuteRuleActionParameters", + "ExecuteRuleActionParametersMatchedData", + "ExecuteRuleActionParametersOverrides", + "ExecuteRuleActionParametersOverridesCategory", + "ExecuteRuleActionParametersOverridesRule", + "ExecuteRuleExposedCredentialCheck", + "ExecuteRulePosition", + "ExecuteRulePositionBeforePosition", + "ExecuteRulePositionAfterPosition", + "ExecuteRulePositionIndexPosition", + "ExecuteRuleRatelimit", + "ForceConnectionCloseRule", + "ForceConnectionCloseRuleExposedCredentialCheck", + "ForceConnectionCloseRulePosition", + "ForceConnectionCloseRulePositionBeforePosition", + "ForceConnectionCloseRulePositionAfterPosition", + "ForceConnectionCloseRulePositionIndexPosition", + "ForceConnectionCloseRuleRatelimit", + "JavaScriptChallengeRule", + "JavaScriptChallengeRuleExposedCredentialCheck", + "JavaScriptChallengeRulePosition", + "JavaScriptChallengeRulePositionBeforePosition", + "JavaScriptChallengeRulePositionAfterPosition", + "JavaScriptChallengeRulePositionIndexPosition", + "JavaScriptChallengeRuleRatelimit", + "LogRule", + "LogRuleExposedCredentialCheck", + "LogRulePosition", + "LogRulePositionBeforePosition", + "LogRulePositionAfterPosition", + "LogRulePositionIndexPosition", + "LogRuleRatelimit", + "LogCustomFieldRule", + "LogCustomFieldRuleActionParameters", + "LogCustomFieldRuleActionParametersCookieField", + "LogCustomFieldRuleActionParametersRawResponseField", + "LogCustomFieldRuleActionParametersRequestField", + "LogCustomFieldRuleActionParametersResponseField", + "LogCustomFieldRuleActionParametersTransformedRequestField", + "LogCustomFieldRuleExposedCredentialCheck", + "LogCustomFieldRulePosition", + "LogCustomFieldRulePositionBeforePosition", + "LogCustomFieldRulePositionAfterPosition", + "LogCustomFieldRulePositionIndexPosition", + "LogCustomFieldRuleRatelimit", + "ManagedChallengeRule", + "ManagedChallengeRuleExposedCredentialCheck", + "ManagedChallengeRulePosition", + "ManagedChallengeRulePositionBeforePosition", + "ManagedChallengeRulePositionAfterPosition", + "ManagedChallengeRulePositionIndexPosition", + "ManagedChallengeRuleRatelimit", + "RedirectRule", + "RedirectRuleActionParameters", + "RedirectRuleActionParametersFromList", + "RedirectRuleActionParametersFromValue", + "RedirectRuleActionParametersFromValueTargetURL", + "RedirectRuleExposedCredentialCheck", + "RedirectRulePosition", + "RedirectRulePositionBeforePosition", + "RedirectRulePositionAfterPosition", + "RedirectRulePositionIndexPosition", + "RedirectRuleRatelimit", + "RewriteRule", + "RewriteRuleActionParameters", + "RewriteRuleActionParametersHeaders", + "RewriteRuleActionParametersHeadersAddStaticHeader", + "RewriteRuleActionParametersHeadersAddDynamicHeader", + "RewriteRuleActionParametersHeadersSetStaticHeader", + "RewriteRuleActionParametersHeadersSetDynamicHeader", + "RewriteRuleActionParametersHeadersRemoveHeader", + "RewriteRuleActionParametersURI", + "RewriteRuleActionParametersURIURIPath", + "RewriteRuleActionParametersURIURIPathPath", + "RewriteRuleActionParametersURIURIQuery", + "RewriteRuleActionParametersURIURIQueryQuery", + "RewriteRuleExposedCredentialCheck", + "RewriteRulePosition", + "RewriteRulePositionBeforePosition", + "RewriteRulePositionAfterPosition", + "RewriteRulePositionIndexPosition", + "RewriteRuleRatelimit", + "RouteRule", + "RouteRuleActionParameters", + "RouteRuleActionParametersOrigin", + "RouteRuleActionParametersSNI", + "RouteRuleExposedCredentialCheck", + "RouteRulePosition", + "RouteRulePositionBeforePosition", + "RouteRulePositionAfterPosition", + "RouteRulePositionIndexPosition", + "RouteRuleRatelimit", + "ScoreRule", + "ScoreRuleActionParameters", + "ScoreRuleExposedCredentialCheck", + "ScoreRulePosition", + "ScoreRulePositionBeforePosition", + "ScoreRulePositionAfterPosition", + "ScoreRulePositionIndexPosition", + "ScoreRuleRatelimit", + "ServeErrorRule", + "ServeErrorRuleActionParameters", + "ServeErrorRuleActionParametersActionParametersContent", + "ServeErrorRuleActionParametersActionParametersAsset", + "ServeErrorRuleExposedCredentialCheck", + "ServeErrorRulePosition", + "ServeErrorRulePositionBeforePosition", + "ServeErrorRulePositionAfterPosition", + "ServeErrorRulePositionIndexPosition", + "ServeErrorRuleRatelimit", + "SetCacheControlRule", + "SetCacheControlRuleActionParameters", + "SetCacheControlRuleActionParametersImmutable", + "SetCacheControlRuleActionParametersImmutableSetDirective", + "SetCacheControlRuleActionParametersImmutableRemoveDirective", + "SetCacheControlRuleActionParametersMaxAge", + "SetCacheControlRuleActionParametersMaxAgeSetDirective", + "SetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "SetCacheControlRuleActionParametersMustRevalidate", + "SetCacheControlRuleActionParametersMustRevalidateSetDirective", + "SetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "SetCacheControlRuleActionParametersMustUnderstand", + "SetCacheControlRuleActionParametersMustUnderstandSetDirective", + "SetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "SetCacheControlRuleActionParametersNoCache", + "SetCacheControlRuleActionParametersNoCacheSetDirective", + "SetCacheControlRuleActionParametersNoCacheRemoveDirective", + "SetCacheControlRuleActionParametersNoStore", + "SetCacheControlRuleActionParametersNoStoreSetDirective", + "SetCacheControlRuleActionParametersNoStoreRemoveDirective", + "SetCacheControlRuleActionParametersNoTransform", + "SetCacheControlRuleActionParametersNoTransformSetDirective", + "SetCacheControlRuleActionParametersNoTransformRemoveDirective", + "SetCacheControlRuleActionParametersPrivate", + "SetCacheControlRuleActionParametersPrivateSetDirective", + "SetCacheControlRuleActionParametersPrivateRemoveDirective", + "SetCacheControlRuleActionParametersProxyRevalidate", + "SetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "SetCacheControlRuleActionParametersPublic", + "SetCacheControlRuleActionParametersPublicSetDirective", + "SetCacheControlRuleActionParametersPublicRemoveDirective", + "SetCacheControlRuleActionParametersSMaxage", + "SetCacheControlRuleActionParametersSMaxageSetDirective", + "SetCacheControlRuleActionParametersSMaxageRemoveDirective", + "SetCacheControlRuleActionParametersStaleIfError", + "SetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "SetCacheControlRuleActionParametersStaleWhileRevalidate", + "SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "SetCacheControlRuleExposedCredentialCheck", + "SetCacheControlRulePosition", + "SetCacheControlRulePositionBeforePosition", + "SetCacheControlRulePositionAfterPosition", + "SetCacheControlRulePositionIndexPosition", + "SetCacheControlRuleRatelimit", + "SetCacheSettingsRule", + "SetCacheSettingsRuleActionParameters", + "SetCacheSettingsRuleActionParametersBrowserTTL", + "SetCacheSettingsRuleActionParametersCacheKey", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "SetCacheSettingsRuleActionParametersCacheReserve", + "SetCacheSettingsRuleActionParametersEdgeTTL", + "SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "SetCacheSettingsRuleActionParametersServeStale", + "SetCacheSettingsRuleActionParametersSharedDictionary", + "SetCacheSettingsRuleExposedCredentialCheck", + "SetCacheSettingsRulePosition", + "SetCacheSettingsRulePositionBeforePosition", + "SetCacheSettingsRulePositionAfterPosition", + "SetCacheSettingsRulePositionIndexPosition", + "SetCacheSettingsRuleRatelimit", + "SetCacheTagsRule", + "SetCacheTagsRuleActionParameters", + "SetCacheTagsRuleActionParametersAddCacheTagsValues", + "SetCacheTagsRuleActionParametersAddCacheTagsExpression", + "SetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "SetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "SetCacheTagsRuleActionParametersSetCacheTagsValues", + "SetCacheTagsRuleActionParametersSetCacheTagsExpression", + "SetCacheTagsRuleExposedCredentialCheck", + "SetCacheTagsRulePosition", + "SetCacheTagsRulePositionBeforePosition", + "SetCacheTagsRulePositionAfterPosition", + "SetCacheTagsRulePositionIndexPosition", + "SetCacheTagsRuleRatelimit", + "SetConfigurationRule", + "SetConfigurationRuleActionParameters", + "SetConfigurationRuleActionParametersAutominify", + "SetConfigurationRuleExposedCredentialCheck", + "SetConfigurationRulePosition", + "SetConfigurationRulePositionBeforePosition", + "SetConfigurationRulePositionAfterPosition", + "SetConfigurationRulePositionIndexPosition", + "SetConfigurationRuleRatelimit", + "SkipRule", + "SkipRuleActionParameters", + "SkipRuleExposedCredentialCheck", + "SkipRulePosition", + "SkipRulePositionBeforePosition", + "SkipRulePositionAfterPosition", + "SkipRulePositionIndexPosition", + "SkipRuleRatelimit", +] + + +class BlockRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["block"] + """The action to perform when the rule matches.""" + + action_parameters: BlockRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: BlockRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: BlockRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: BlockRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class BlockRuleActionParametersResponse(TypedDict, total=False): + """The response to show when the block is applied.""" + + content: Required[str] + """The content to return.""" + + content_type: Required[str] + """The type of the content to return.""" + + status_code: Required[int] + """The status code to return.""" + + +class BlockRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + response: BlockRuleActionParametersResponse + """The response to show when the block is applied.""" + + +class BlockRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class BlockRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class BlockRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class BlockRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +BlockRulePosition: TypeAlias = Union[ + BlockRulePositionBeforePosition, BlockRulePositionAfterPosition, BlockRulePositionIndexPosition +] + + +class BlockRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ChallengeRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ChallengeRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ChallengeRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ChallengeRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ChallengeRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ChallengeRulePosition: TypeAlias = Union[ + ChallengeRulePositionBeforePosition, ChallengeRulePositionAfterPosition, ChallengeRulePositionIndexPosition +] + + +class ChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ResponseCompressionRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["compress_response"] + """The action to perform when the rule matches.""" + + action_parameters: ResponseCompressionRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ResponseCompressionRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ResponseCompressionRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ResponseCompressionRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ResponseCompressionRuleActionParametersAlgorithm(TypedDict, total=False): + """Compression algorithm to enable.""" + + name: Literal["none", "auto", "default", "gzip", "brotli", "zstd"] + """Name of the compression algorithm to enable.""" + + +class ResponseCompressionRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + algorithms: Required[Iterable[ResponseCompressionRuleActionParametersAlgorithm]] + """Custom order for compression algorithms.""" + + +class ResponseCompressionRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ResponseCompressionRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ResponseCompressionRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ResponseCompressionRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ResponseCompressionRulePosition: TypeAlias = Union[ + ResponseCompressionRulePositionBeforePosition, + ResponseCompressionRulePositionAfterPosition, + ResponseCompressionRulePositionIndexPosition, +] + + +class ResponseCompressionRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class DDoSDynamicRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: DDoSDynamicRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: DDoSDynamicRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: DDoSDynamicRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class DDoSDynamicRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class DDoSDynamicRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class DDoSDynamicRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class DDoSDynamicRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +DDoSDynamicRulePosition: TypeAlias = Union[ + DDoSDynamicRulePositionBeforePosition, DDoSDynamicRulePositionAfterPosition, DDoSDynamicRulePositionIndexPosition +] + + +class DDoSDynamicRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ExecuteRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["execute"] + """The action to perform when the rule matches.""" + + action_parameters: ExecuteRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExecuteRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ExecuteRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ExecuteRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ExecuteRuleActionParametersMatchedData(TypedDict, total=False): + """The configuration to use for matched data logging.""" + + public_key: Required[str] + """The public key to encrypt matched data logs with.""" + + +class ExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): + """A category-level override.""" + + category: Required[str] + """The name of the category to override.""" + + action: str + """The action to override rules in the category with.""" + + enabled: bool + """Whether to enable execution of rules in the category.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """The sensitivity level to use for rules in the category. + + This option is only applicable for DDoS phases. + """ + + +class ExecuteRuleActionParametersOverridesRule(TypedDict, total=False): + """A rule-level override.""" + + id: Required[str] + """The ID of the rule to override.""" + + action: str + """The action to override the rule with.""" + + enabled: bool + """Whether to enable execution of the rule.""" + + score_threshold: int + """The score threshold to use for the rule.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """The sensitivity level to use for the rule. + + This option is only applicable for DDoS phases. + """ + + +class ExecuteRuleActionParametersOverrides(TypedDict, total=False): + """A set of overrides to apply to the target ruleset.""" + + action: str + """An action to override all rules with. + + This option has lower precedence than rule and category overrides. + """ + + categories: Iterable[ExecuteRuleActionParametersOverridesCategory] + """A list of category-level overrides. + + This option has the second-highest precedence after rule-level overrides. + """ + + enabled: bool + """Whether to enable execution of all rules. + + This option has lower precedence than rule and category overrides. + """ + + rules: Iterable[ExecuteRuleActionParametersOverridesRule] + """A list of rule-level overrides. This option has the highest precedence.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """A sensitivity level to set for all rules. + + This option has lower precedence than rule and category overrides and is only + applicable for DDoS phases. + """ + + +class ExecuteRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + id: Required[str] + """The ID of the ruleset to execute.""" + + matched_data: ExecuteRuleActionParametersMatchedData + """The configuration to use for matched data logging.""" + + overrides: ExecuteRuleActionParametersOverrides + """A set of overrides to apply to the target ruleset.""" + + +class ExecuteRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ExecuteRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ExecuteRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ExecuteRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ExecuteRulePosition: TypeAlias = Union[ + ExecuteRulePositionBeforePosition, ExecuteRulePositionAfterPosition, ExecuteRulePositionIndexPosition +] + + +class ExecuteRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ForceConnectionCloseRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ForceConnectionCloseRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ForceConnectionCloseRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ForceConnectionCloseRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ForceConnectionCloseRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ForceConnectionCloseRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ForceConnectionCloseRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ForceConnectionCloseRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ForceConnectionCloseRulePosition: TypeAlias = Union[ + ForceConnectionCloseRulePositionBeforePosition, + ForceConnectionCloseRulePositionAfterPosition, + ForceConnectionCloseRulePositionIndexPosition, +] + + +class ForceConnectionCloseRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class JavaScriptChallengeRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: JavaScriptChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: JavaScriptChallengeRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: JavaScriptChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class JavaScriptChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class JavaScriptChallengeRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class JavaScriptChallengeRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class JavaScriptChallengeRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +JavaScriptChallengeRulePosition: TypeAlias = Union[ + JavaScriptChallengeRulePositionBeforePosition, + JavaScriptChallengeRulePositionAfterPosition, + JavaScriptChallengeRulePositionIndexPosition, +] + + +class JavaScriptChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class LogRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["log"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: LogRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: LogRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: LogRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class LogRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class LogRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class LogRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class LogRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +LogRulePosition: TypeAlias = Union[ + LogRulePositionBeforePosition, LogRulePositionAfterPosition, LogRulePositionIndexPosition +] + + +class LogRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class LogCustomFieldRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["log_custom_field"] + """The action to perform when the rule matches.""" + + action_parameters: LogCustomFieldRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: LogCustomFieldRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: LogCustomFieldRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: LogCustomFieldRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class LogCustomFieldRuleActionParametersCookieField(TypedDict, total=False): + """The cookie field to log.""" + + name: Required[str] + """The name of the cookie.""" + + +class LogCustomFieldRuleActionParametersRawResponseField(TypedDict, total=False): + """The raw response field to log.""" + + name: Required[str] + """The name of the response header.""" + + preserve_duplicates: bool + """Whether to log duplicate values of the same header.""" + + +class LogCustomFieldRuleActionParametersRequestField(TypedDict, total=False): + """The raw request field to log.""" + + name: Required[str] + """The name of the header.""" + + +class LogCustomFieldRuleActionParametersResponseField(TypedDict, total=False): + """The transformed response field to log.""" + + name: Required[str] + """The name of the response header.""" + + preserve_duplicates: bool + """Whether to log duplicate values of the same header.""" + + +class LogCustomFieldRuleActionParametersTransformedRequestField(TypedDict, total=False): + """The transformed request field to log.""" + + name: Required[str] + """The name of the header.""" + + +class LogCustomFieldRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + cookie_fields: Iterable[LogCustomFieldRuleActionParametersCookieField] + """The cookie fields to log.""" + + raw_response_fields: Iterable[LogCustomFieldRuleActionParametersRawResponseField] + """The raw response fields to log.""" + + request_fields: Iterable[LogCustomFieldRuleActionParametersRequestField] + """The raw request fields to log.""" + + response_fields: Iterable[LogCustomFieldRuleActionParametersResponseField] + """The transformed response fields to log.""" + + transformed_request_fields: Iterable[LogCustomFieldRuleActionParametersTransformedRequestField] + """The transformed request fields to log.""" + + +class LogCustomFieldRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class LogCustomFieldRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class LogCustomFieldRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class LogCustomFieldRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +LogCustomFieldRulePosition: TypeAlias = Union[ + LogCustomFieldRulePositionBeforePosition, + LogCustomFieldRulePositionAfterPosition, + LogCustomFieldRulePositionIndexPosition, +] + + +class LogCustomFieldRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ManagedChallengeRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["managed_challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ManagedChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ManagedChallengeRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ManagedChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ManagedChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ManagedChallengeRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ManagedChallengeRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ManagedChallengeRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ManagedChallengeRulePosition: TypeAlias = Union[ + ManagedChallengeRulePositionBeforePosition, + ManagedChallengeRulePositionAfterPosition, + ManagedChallengeRulePositionIndexPosition, +] + + +class ManagedChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RedirectRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["redirect"] + """The action to perform when the rule matches.""" + + action_parameters: RedirectRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RedirectRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: RedirectRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: RedirectRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RedirectRuleActionParametersFromList(TypedDict, total=False): + """A redirect based on a bulk list lookup.""" + + key: Required[str] + """An expression that evaluates to the list lookup key.""" + + name: Required[str] + """The name of the list to match against.""" + + +class RedirectRuleActionParametersFromValueTargetURL(TypedDict, total=False): + """A URL to redirect the request to.""" + + expression: str + """An expression that evaluates to a URL to redirect the request to.""" + + value: str + """A URL to redirect the request to.""" + + +class RedirectRuleActionParametersFromValue(TypedDict, total=False): + """A redirect based on the request properties.""" + + target_url: Required[RedirectRuleActionParametersFromValueTargetURL] + """A URL to redirect the request to.""" + + preserve_query_string: bool + """Whether to keep the query string of the original request.""" + + status_code: Literal[301, 302, 303, 307, 308] + """The status code to use for the redirect.""" + + +class RedirectRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + from_list: RedirectRuleActionParametersFromList + """A redirect based on a bulk list lookup.""" + + from_value: RedirectRuleActionParametersFromValue + """A redirect based on the request properties.""" + + +class RedirectRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RedirectRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class RedirectRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class RedirectRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +RedirectRulePosition: TypeAlias = Union[ + RedirectRulePositionBeforePosition, RedirectRulePositionAfterPosition, RedirectRulePositionIndexPosition +] + + +class RedirectRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RewriteRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["rewrite"] + """The action to perform when the rule matches.""" + + action_parameters: RewriteRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RewriteRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: RewriteRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: RewriteRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RewriteRuleActionParametersHeadersAddStaticHeader(TypedDict, total=False): + """A header with a static value to add.""" + + operation: Required[Literal["add"]] + """The operation to perform on the header.""" + + value: Required[str] + """A static value for the header.""" + + +class RewriteRuleActionParametersHeadersAddDynamicHeader(TypedDict, total=False): + """A header with a dynamic value to add.""" + + expression: Required[str] + """An expression that evaluates to a value for the header.""" + + operation: Required[Literal["add"]] + """The operation to perform on the header.""" + + +class RewriteRuleActionParametersHeadersSetStaticHeader(TypedDict, total=False): + """A header with a static value to set.""" + + operation: Required[Literal["set"]] + """The operation to perform on the header.""" + + value: Required[str] + """A static value for the header.""" + + +class RewriteRuleActionParametersHeadersSetDynamicHeader(TypedDict, total=False): + """A header with a dynamic value to set.""" + + expression: Required[str] + """An expression that evaluates to a value for the header.""" + + operation: Required[Literal["set"]] + """The operation to perform on the header.""" + + +class RewriteRuleActionParametersHeadersRemoveHeader(TypedDict, total=False): + """A header to remove.""" + + operation: Required[Literal["remove"]] + """The operation to perform on the header.""" + + +RewriteRuleActionParametersHeaders: TypeAlias = Union[ + RewriteRuleActionParametersHeadersAddStaticHeader, + RewriteRuleActionParametersHeadersAddDynamicHeader, + RewriteRuleActionParametersHeadersSetStaticHeader, + RewriteRuleActionParametersHeadersSetDynamicHeader, + RewriteRuleActionParametersHeadersRemoveHeader, +] + + +class RewriteRuleActionParametersURIURIPathPath(TypedDict, total=False): + """A URI path rewrite.""" + + expression: str + """An expression that evaluates to a value to rewrite the URI path to.""" + + value: str + """A value to rewrite the URI path to.""" + + +class RewriteRuleActionParametersURIURIPath(TypedDict, total=False): + """A URI path rewrite.""" + + path: Required[RewriteRuleActionParametersURIURIPathPath] + """A URI path rewrite.""" + + +class RewriteRuleActionParametersURIURIQueryQuery(TypedDict, total=False): + """A URI query rewrite.""" + + expression: str + """An expression that evaluates to a value to rewrite the URI query to.""" + + value: str + """A value to rewrite the URI query to.""" + + +class RewriteRuleActionParametersURIURIQuery(TypedDict, total=False): + """A URI query rewrite.""" + + query: Required[RewriteRuleActionParametersURIURIQueryQuery] + """A URI query rewrite.""" + + +RewriteRuleActionParametersURI: TypeAlias = Union[ + RewriteRuleActionParametersURIURIPath, RewriteRuleActionParametersURIURIQuery +] + + +class RewriteRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + headers: Dict[str, RewriteRuleActionParametersHeaders] + """A map of headers to rewrite.""" + + uri: RewriteRuleActionParametersURI + """A URI path rewrite.""" + + +class RewriteRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RewriteRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class RewriteRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class RewriteRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +RewriteRulePosition: TypeAlias = Union[ + RewriteRulePositionBeforePosition, RewriteRulePositionAfterPosition, RewriteRulePositionIndexPosition +] + + +class RewriteRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RouteRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["route"] + """The action to perform when the rule matches.""" + + action_parameters: RouteRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RouteRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: RouteRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: RouteRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RouteRuleActionParametersOrigin(TypedDict, total=False): + """An origin to route to.""" + + host: str + """A resolved host to route to.""" + + port: int + """A destination port to route to.""" + + +class RouteRuleActionParametersSNI(TypedDict, total=False): + """A Server Name Indication (SNI) override.""" + + value: Required[str] + """A value to override the SNI to.""" + + +class RouteRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + host_header: str + """A value to rewrite the HTTP host header to.""" + + origin: RouteRuleActionParametersOrigin + """An origin to route to.""" + + sni: RouteRuleActionParametersSNI + """A Server Name Indication (SNI) override.""" + + +class RouteRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RouteRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class RouteRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class RouteRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +RouteRulePosition: TypeAlias = Union[ + RouteRulePositionBeforePosition, RouteRulePositionAfterPosition, RouteRulePositionIndexPosition +] + + +class RouteRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ScoreRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["score"] + """The action to perform when the rule matches.""" + + action_parameters: ScoreRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ScoreRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ScoreRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ScoreRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ScoreRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + increment: Required[int] + """A delta to change the score by, which can be either positive or negative.""" + + +class ScoreRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ScoreRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ScoreRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ScoreRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ScoreRulePosition: TypeAlias = Union[ + ScoreRulePositionBeforePosition, ScoreRulePositionAfterPosition, ScoreRulePositionIndexPosition +] + + +class ScoreRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ServeErrorRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["serve_error"] + """The action to perform when the rule matches.""" + + action_parameters: ServeErrorRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ServeErrorRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ServeErrorRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ServeErrorRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ServeErrorRuleActionParametersActionParametersContent(TypedDict, total=False): + content: Required[str] + """The response content.""" + + content_type: Literal["application/json", "text/html", "text/plain", "text/xml"] + """The content type header to set with the error response.""" + + status_code: int + """The status code to use for the error.""" + + +class ServeErrorRuleActionParametersActionParametersAsset(TypedDict, total=False): + asset_name: Required[str] + """The name of a custom asset to serve as the error response.""" + + content_type: Literal["application/json", "text/html", "text/plain", "text/xml"] + """The content type header to set with the error response.""" + + status_code: int + """The status code to use for the error.""" + + +ServeErrorRuleActionParameters: TypeAlias = Union[ + ServeErrorRuleActionParametersActionParametersContent, ServeErrorRuleActionParametersActionParametersAsset +] + + +class ServeErrorRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ServeErrorRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ServeErrorRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ServeErrorRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ServeErrorRulePosition: TypeAlias = Union[ + ServeErrorRulePositionBeforePosition, ServeErrorRulePositionAfterPosition, ServeErrorRulePositionIndexPosition +] + + +class ServeErrorRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetCacheControlRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheControlRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + SetCacheControlRuleActionParametersImmutableSetDirective, + SetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class SetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + SetCacheControlRuleActionParametersMaxAgeSetDirective, SetCacheControlRuleActionParametersMaxAgeRemoveDirective +] + + +class SetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersMustRevalidateSetDirective, + SetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + SetCacheControlRuleActionParametersMustUnderstandSetDirective, + SetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class SetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class SetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoCacheSetDirective, SetCacheControlRuleActionParametersNoCacheRemoveDirective +] + + +class SetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoStoreSetDirective, SetCacheControlRuleActionParametersNoStoreRemoveDirective +] + + +class SetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoTransformSetDirective, + SetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class SetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class SetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + SetCacheControlRuleActionParametersPrivateSetDirective, SetCacheControlRuleActionParametersPrivateRemoveDirective +] + + +class SetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersProxyRevalidateSetDirective, + SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + SetCacheControlRuleActionParametersPublicSetDirective, SetCacheControlRuleActionParametersPublicRemoveDirective +] + + +class SetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + SetCacheControlRuleActionParametersSMaxageSetDirective, SetCacheControlRuleActionParametersSMaxageRemoveDirective +] + + +class SetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + SetCacheControlRuleActionParametersStaleIfErrorSetDirective, + SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: SetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[SetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[SetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate")] + """A cache-control directive configuration.""" + + must_understand: Annotated[SetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand")] + """A cache-control directive configuration.""" + + no_cache: Annotated[SetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[SetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[SetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform")] + """A cache-control directive configuration.""" + + private: SetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + SetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: SetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[SetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[SetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + SetCacheControlRuleActionParametersStaleWhileRevalidate, PropertyInfo(alias="stale-while-revalidate") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class SetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheControlRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheControlRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheControlRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheControlRulePosition: TypeAlias = Union[ + SetCacheControlRulePositionBeforePosition, + SetCacheControlRulePositionAfterPosition, + SetCacheControlRulePositionIndexPosition, +] + + +class SetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetCacheSettingsRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_settings"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheSettingsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheSettingsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheSettingsRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheSettingsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheSettingsRuleActionParametersBrowserTTL(TypedDict, total=False): + """How long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high browser TTLs may lead to stale content. + """ + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin", "bypass"]] + """The browser TTL mode.""" + + default: int + """The browser TTL (in seconds) if you choose the "override_origin" mode.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(TypedDict, total=False): + """Which cookies to include in the cache key.""" + + check_presence: SequenceNotStr[str] + """A list of cookies to check for the presence of. + + The presence of these cookies is included in the cache key. + """ + + include: SequenceNotStr[str] + """A list of cookies to include in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(TypedDict, total=False): + """Which headers to include in the cache key.""" + + check_presence: SequenceNotStr[str] + """A list of headers to check for the presence of. + + The presence of these headers is included in the cache key. + """ + + contains: Dict[str, SequenceNotStr[str]] + """A mapping of header names to a list of values. + + If a header is present in the request and contains any of the values provided, + its value is included in the cache key. + """ + + exclude_origin: bool + """Whether to exclude the origin header in the cache key.""" + + include: SequenceNotStr[str] + """A list of headers to include in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(TypedDict, total=False): + """How to use the host in the cache key.""" + + resolved: bool + """Whether to use the resolved host in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(TypedDict, total=False): + """Which query string parameters to exclude from the cache key.""" + + all: Literal[True] + """Whether to exclude all query string parameters from the cache key.""" + + list: SequenceNotStr[str] + """A list of query string parameters to exclude from the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(TypedDict, total=False): + """Which query string parameters to include in the cache key.""" + + all: Literal[True] + """Whether to include all query string parameters in the cache key.""" + + list: SequenceNotStr[str] + """A list of query string parameters to include in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(TypedDict, total=False): + """Which query string parameters to include in or exclude from the cache key.""" + + exclude: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude + """Which query string parameters to exclude from the cache key.""" + + include: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude + """Which query string parameters to include in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(TypedDict, total=False): + """How to use characteristics of the request user agent in the cache key.""" + + device_type: bool + """Whether to use the user agent's device type in the cache key.""" + + geo: bool + """Whether to use the user agents's country in the cache key.""" + + lang: bool + """Whether to use the user agent's language in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKey(TypedDict, total=False): + """Which components of the request are included or excluded from the cache key.""" + + cookie: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie + """Which cookies to include in the cache key.""" + + header: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader + """Which headers to include in the cache key.""" + + host: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost + """How to use the host in the cache key.""" + + query_string: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString + """Which query string parameters to include in or exclude from the cache key.""" + + user: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser + """How to use characteristics of the request user agent in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKey(TypedDict, total=False): + """ + Which components of the request are included in or excluded from the cache key Cloudflare uses to store the response in cache. + """ + + cache_by_device_type: bool + """Whether to separate cached content based on the visitor's device type.""" + + cache_deception_armor: bool + """ + Whether to protect from web cache deception attacks, while allowing static + assets to be cached. + """ + + custom_key: SetCacheSettingsRuleActionParametersCacheKeyCustomKey + """Which components of the request are included or excluded from the cache key.""" + + ignore_query_strings_order: bool + """ + Whether to treat requests with the same query parameters the same, regardless of + the order those query parameters are in. + """ + + +class SetCacheSettingsRuleActionParametersCacheReserve(TypedDict, total=False): + """ + Settings to determine whether the request's response from origin is eligible for Cache Reserve (requires a Cache Reserve add-on plan). + """ + + eligible: Required[bool] + """Whether Cache Reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to Cache Reserve. + """ + + minimum_file_size: int + """The minimum file size eligible for storage in Cache Reserve.""" + + +_SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords = TypedDict( + "_SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords", + { + "from": int, + }, + total=False, +) + + +class SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange( + _SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords, total=False +): + """A range of status codes to apply the TTL to.""" + + to: int + """The upper bound of the range.""" + + +class SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(TypedDict, total=False): + value: Required[int] + """The time to cache the response for (in seconds). + + A value of 0 is equivalent to setting the cache control header with the value + "no-cache". A value of -1 is equivalent to setting the cache control header with + the value of "no-store". + """ + + status_code: int + """A single status code to apply the TTL to.""" + + status_code_range: SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + """A range of status codes to apply the TTL to.""" + + +class SetCacheSettingsRuleActionParametersEdgeTTL(TypedDict, total=False): + """How long the Cloudflare edge network should cache the response.""" + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """The edge TTL mode.""" + + default: int + """The edge TTL (in seconds) if you choose the "override_origin" mode.""" + + status_code_ttl: Iterable[SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """A list of TTLs to apply to specific status codes or status code ranges.""" + + +class SetCacheSettingsRuleActionParametersServeStale(TypedDict, total=False): + """When to serve stale content from cache.""" + + disable_stale_while_updating: bool + """ + Whether Cloudflare should disable serving stale content while getting the latest + content from the origin. + """ + + +class SetCacheSettingsRuleActionParametersSharedDictionary(TypedDict, total=False): + """Configuration for shared dictionary compression. + + When set, Cloudflare injects Use-As-Dictionary headers on matching cacheable responses. + """ + + match_pattern: Required[str] + """URL pattern for the Use-As-Dictionary match field. + + This pattern specifies which URLs can use this response as a dictionary. + """ + + +class SetCacheSettingsRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + additional_cacheable_ports: Iterable[int] + """A list of additional ports that caching should be enabled on.""" + + browser_ttl: SetCacheSettingsRuleActionParametersBrowserTTL + """How long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: bool + """Whether the request's response from the origin is eligible for caching. + + Caching itself will still depend on the cache control header and your other + caching configurations. + """ + + cache_key: SetCacheSettingsRuleActionParametersCacheKey + """ + Which components of the request are included in or excluded from the cache key + Cloudflare uses to store the response in cache. + """ + + cache_reserve: SetCacheSettingsRuleActionParametersCacheReserve + """ + Settings to determine whether the request's response from origin is eligible for + Cache Reserve (requires a Cache Reserve add-on plan). + """ + + edge_ttl: SetCacheSettingsRuleActionParametersEdgeTTL + """How long the Cloudflare edge network should cache the response.""" + + origin_cache_control: bool + """Whether Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: bool + """Whether to generate Cloudflare error pages for issues from the origin server.""" + + read_timeout: int + """ + A timeout value between two successive read operations to use for your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: bool + """Whether Cloudflare should respect strong ETag (entity tag) headers. + + If false, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: SetCacheSettingsRuleActionParametersServeStale + """When to serve stale content from cache.""" + + shared_dictionary: SetCacheSettingsRuleActionParametersSharedDictionary + """Configuration for shared dictionary compression. + + When set, Cloudflare injects Use-As-Dictionary headers on matching cacheable + responses. + """ + + strip_etags: bool + """Whether to strip ETag headers from the origin response before caching.""" + + strip_last_modified: bool + """Whether to strip Last-Modified headers from the origin response before caching.""" + + strip_set_cookie: bool + """Whether to strip Set-Cookie headers from the origin response before caching.""" + + +class SetCacheSettingsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheSettingsRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheSettingsRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheSettingsRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheSettingsRulePosition: TypeAlias = Union[ + SetCacheSettingsRulePositionBeforePosition, + SetCacheSettingsRulePositionAfterPosition, + SetCacheSettingsRulePositionIndexPosition, +] + + +class SetCacheSettingsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetCacheTagsRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheTagsRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class SetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class SetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +SetCacheTagsRuleActionParameters: TypeAlias = Union[ + SetCacheTagsRuleActionParametersAddCacheTagsValues, + SetCacheTagsRuleActionParametersAddCacheTagsExpression, + SetCacheTagsRuleActionParametersRemoveCacheTagsValues, + SetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + SetCacheTagsRuleActionParametersSetCacheTagsValues, + SetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class SetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheTagsRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheTagsRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheTagsRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheTagsRulePosition: TypeAlias = Union[ + SetCacheTagsRulePositionBeforePosition, SetCacheTagsRulePositionAfterPosition, SetCacheTagsRulePositionIndexPosition +] + + +class SetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetConfigurationRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_config"] + """The action to perform when the rule matches.""" + + action_parameters: SetConfigurationRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetConfigurationRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetConfigurationRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetConfigurationRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetConfigurationRuleActionParametersAutominify(TypedDict, total=False): + """Which file extensions to minify automatically.""" + + css: bool + """Whether to minify CSS files.""" + + html: bool + """Whether to minify HTML files.""" + + js: bool + """Whether to minify JavaScript files.""" + + +class SetConfigurationRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + automatic_https_rewrites: bool + """Whether to enable Automatic HTTPS Rewrites.""" + + autominify: SetConfigurationRuleActionParametersAutominify + """Which file extensions to minify automatically.""" + + bic: bool + """Whether to enable Browser Integrity Check (BIC).""" + + content_converter: bool + """Whether to enable content conversion (e.g., HTML to Markdown).""" + + disable_apps: Literal[True] + """Whether to disable Cloudflare Apps.""" + + disable_pay_per_crawl: Literal[True] + """Whether to disable Pay Per Crawl.""" + + disable_rum: Literal[True] + """Whether to disable Real User Monitoring (RUM).""" + + disable_zaraz: Literal[True] + """Whether to disable Zaraz.""" + + email_obfuscation: bool + """Whether to enable Email Obfuscation.""" + + fonts: bool + """Whether to enable Cloudflare Fonts.""" + + hotlink_protection: bool + """Whether to enable Hotlink Protection.""" + + mirage: bool + """Whether to enable Mirage.""" + + opportunistic_encryption: bool + """Whether to enable Opportunistic Encryption.""" + + polish: Literal["off", "lossless", "lossy", "webp"] + """The Polish level to configure.""" + + redirects_for_ai_training: bool + """ + Whether to redirect verified AI training crawlers to canonical URLs found in the + HTML response. + """ + + request_body_buffering: Literal["none", "standard", "full"] + """The request body buffering mode.""" + + response_body_buffering: Literal["none", "standard"] + """The response body buffering mode.""" + + rocket_loader: bool + """Whether to enable Rocket Loader.""" + + security_level: Literal["off", "essentially_off", "low", "medium", "high", "under_attack"] + """The Security Level to configure.""" + + server_side_excludes: bool + """Whether to enable Server-Side Excludes.""" + + ssl: Literal["off", "flexible", "full", "strict", "origin_pull"] + """The SSL level to configure.""" + + sxg: bool + """Whether to enable Signed Exchanges (SXG).""" + + +class SetConfigurationRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetConfigurationRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetConfigurationRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetConfigurationRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetConfigurationRulePosition: TypeAlias = Union[ + SetConfigurationRulePositionBeforePosition, + SetConfigurationRulePositionAfterPosition, + SetConfigurationRulePositionIndexPosition, +] + + +class SetConfigurationRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SkipRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["skip"] + """The action to perform when the rule matches.""" + + action_parameters: SkipRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SkipRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SkipRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SkipRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SkipRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + phase: Literal["current"] + """A phase to skip the execution of. + + This option is only compatible with the products option. + """ + + phases: List[Phase] + """A list of phases to skip the execution of. + + This option is incompatible with the rulesets option. + """ + + products: List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] + """A list of legacy security products to skip the execution of.""" + + rules: Dict[str, SequenceNotStr[str]] + """ + A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + execution of. This option is incompatible with the ruleset option. + """ + + ruleset: Literal["current"] + """A ruleset to skip the execution of. + + This option is incompatible with the rulesets option. + """ + + rulesets: SequenceNotStr[str] + """A list of ruleset IDs to skip the execution of. + + This option is incompatible with the ruleset and phases options. + """ + + +class SkipRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SkipRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SkipRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SkipRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SkipRulePosition: TypeAlias = Union[ + SkipRulePositionBeforePosition, SkipRulePositionAfterPosition, SkipRulePositionIndexPosition +] + + +class SkipRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +RuleCreateParams: TypeAlias = Union[ + BlockRule, + ChallengeRule, + ResponseCompressionRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + JavaScriptChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetCacheControlRule, + SetCacheSettingsRule, + SetCacheTagsRule, + SetConfigurationRule, + SkipRule, +] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py new file mode 100644 index 00000000000..46f7ecd38f8 --- /dev/null +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from .kind import Kind +from .phase import Phase +from .logging import Logging +from ..._utils import PropertyInfo +from .log_rule import LogRule +from ..._models import BaseModel +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .route_rule import RouteRule +from .score_rule import ScoreRule +from .execute_rule import ExecuteRule +from .rewrite_rule import RewriteRule +from .redirect_rule import RedirectRule +from .set_config_rule import SetConfigRule +from .serve_error_rule import ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule +from .log_custom_field_rule import LogCustomFieldRule +from .compress_response_rule import CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule +from .set_cache_settings_rule import SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "RuleCreateResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class RuleCreateResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py new file mode 100644 index 00000000000..0477fa7dd06 --- /dev/null +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from .kind import Kind +from .phase import Phase +from .logging import Logging +from ..._utils import PropertyInfo +from .log_rule import LogRule +from ..._models import BaseModel +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .route_rule import RouteRule +from .score_rule import ScoreRule +from .execute_rule import ExecuteRule +from .rewrite_rule import RewriteRule +from .redirect_rule import RedirectRule +from .set_config_rule import SetConfigRule +from .serve_error_rule import ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule +from .log_custom_field_rule import LogCustomFieldRule +from .compress_response_rule import CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule +from .set_cache_settings_rule import SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "RuleDeleteResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class RuleDeleteResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py new file mode 100644 index 00000000000..c914421bbdf --- /dev/null +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -0,0 +1,4257 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Union, Iterable +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from .phase import Phase +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo +from .logging_param import LoggingParam + +__all__ = [ + "RuleEditParams", + "BlockRule", + "BlockRuleActionParameters", + "BlockRuleActionParametersResponse", + "BlockRuleExposedCredentialCheck", + "BlockRulePosition", + "BlockRulePositionBeforePosition", + "BlockRulePositionAfterPosition", + "BlockRulePositionIndexPosition", + "BlockRuleRatelimit", + "ChallengeRule", + "ChallengeRuleExposedCredentialCheck", + "ChallengeRulePosition", + "ChallengeRulePositionBeforePosition", + "ChallengeRulePositionAfterPosition", + "ChallengeRulePositionIndexPosition", + "ChallengeRuleRatelimit", + "ResponseCompressionRule", + "ResponseCompressionRuleActionParameters", + "ResponseCompressionRuleActionParametersAlgorithm", + "ResponseCompressionRuleExposedCredentialCheck", + "ResponseCompressionRulePosition", + "ResponseCompressionRulePositionBeforePosition", + "ResponseCompressionRulePositionAfterPosition", + "ResponseCompressionRulePositionIndexPosition", + "ResponseCompressionRuleRatelimit", + "DDoSDynamicRule", + "DDoSDynamicRuleExposedCredentialCheck", + "DDoSDynamicRulePosition", + "DDoSDynamicRulePositionBeforePosition", + "DDoSDynamicRulePositionAfterPosition", + "DDoSDynamicRulePositionIndexPosition", + "DDoSDynamicRuleRatelimit", + "ExecuteRule", + "ExecuteRuleActionParameters", + "ExecuteRuleActionParametersMatchedData", + "ExecuteRuleActionParametersOverrides", + "ExecuteRuleActionParametersOverridesCategory", + "ExecuteRuleActionParametersOverridesRule", + "ExecuteRuleExposedCredentialCheck", + "ExecuteRulePosition", + "ExecuteRulePositionBeforePosition", + "ExecuteRulePositionAfterPosition", + "ExecuteRulePositionIndexPosition", + "ExecuteRuleRatelimit", + "ForceConnectionCloseRule", + "ForceConnectionCloseRuleExposedCredentialCheck", + "ForceConnectionCloseRulePosition", + "ForceConnectionCloseRulePositionBeforePosition", + "ForceConnectionCloseRulePositionAfterPosition", + "ForceConnectionCloseRulePositionIndexPosition", + "ForceConnectionCloseRuleRatelimit", + "JavaScriptChallengeRule", + "JavaScriptChallengeRuleExposedCredentialCheck", + "JavaScriptChallengeRulePosition", + "JavaScriptChallengeRulePositionBeforePosition", + "JavaScriptChallengeRulePositionAfterPosition", + "JavaScriptChallengeRulePositionIndexPosition", + "JavaScriptChallengeRuleRatelimit", + "LogRule", + "LogRuleExposedCredentialCheck", + "LogRulePosition", + "LogRulePositionBeforePosition", + "LogRulePositionAfterPosition", + "LogRulePositionIndexPosition", + "LogRuleRatelimit", + "LogCustomFieldRule", + "LogCustomFieldRuleActionParameters", + "LogCustomFieldRuleActionParametersCookieField", + "LogCustomFieldRuleActionParametersRawResponseField", + "LogCustomFieldRuleActionParametersRequestField", + "LogCustomFieldRuleActionParametersResponseField", + "LogCustomFieldRuleActionParametersTransformedRequestField", + "LogCustomFieldRuleExposedCredentialCheck", + "LogCustomFieldRulePosition", + "LogCustomFieldRulePositionBeforePosition", + "LogCustomFieldRulePositionAfterPosition", + "LogCustomFieldRulePositionIndexPosition", + "LogCustomFieldRuleRatelimit", + "ManagedChallengeRule", + "ManagedChallengeRuleExposedCredentialCheck", + "ManagedChallengeRulePosition", + "ManagedChallengeRulePositionBeforePosition", + "ManagedChallengeRulePositionAfterPosition", + "ManagedChallengeRulePositionIndexPosition", + "ManagedChallengeRuleRatelimit", + "RedirectRule", + "RedirectRuleActionParameters", + "RedirectRuleActionParametersFromList", + "RedirectRuleActionParametersFromValue", + "RedirectRuleActionParametersFromValueTargetURL", + "RedirectRuleExposedCredentialCheck", + "RedirectRulePosition", + "RedirectRulePositionBeforePosition", + "RedirectRulePositionAfterPosition", + "RedirectRulePositionIndexPosition", + "RedirectRuleRatelimit", + "RewriteRule", + "RewriteRuleActionParameters", + "RewriteRuleActionParametersHeaders", + "RewriteRuleActionParametersHeadersAddStaticHeader", + "RewriteRuleActionParametersHeadersAddDynamicHeader", + "RewriteRuleActionParametersHeadersSetStaticHeader", + "RewriteRuleActionParametersHeadersSetDynamicHeader", + "RewriteRuleActionParametersHeadersRemoveHeader", + "RewriteRuleActionParametersURI", + "RewriteRuleActionParametersURIURIPath", + "RewriteRuleActionParametersURIURIPathPath", + "RewriteRuleActionParametersURIURIQuery", + "RewriteRuleActionParametersURIURIQueryQuery", + "RewriteRuleExposedCredentialCheck", + "RewriteRulePosition", + "RewriteRulePositionBeforePosition", + "RewriteRulePositionAfterPosition", + "RewriteRulePositionIndexPosition", + "RewriteRuleRatelimit", + "RouteRule", + "RouteRuleActionParameters", + "RouteRuleActionParametersOrigin", + "RouteRuleActionParametersSNI", + "RouteRuleExposedCredentialCheck", + "RouteRulePosition", + "RouteRulePositionBeforePosition", + "RouteRulePositionAfterPosition", + "RouteRulePositionIndexPosition", + "RouteRuleRatelimit", + "ScoreRule", + "ScoreRuleActionParameters", + "ScoreRuleExposedCredentialCheck", + "ScoreRulePosition", + "ScoreRulePositionBeforePosition", + "ScoreRulePositionAfterPosition", + "ScoreRulePositionIndexPosition", + "ScoreRuleRatelimit", + "ServeErrorRule", + "ServeErrorRuleActionParameters", + "ServeErrorRuleActionParametersActionParametersContent", + "ServeErrorRuleActionParametersActionParametersAsset", + "ServeErrorRuleExposedCredentialCheck", + "ServeErrorRulePosition", + "ServeErrorRulePositionBeforePosition", + "ServeErrorRulePositionAfterPosition", + "ServeErrorRulePositionIndexPosition", + "ServeErrorRuleRatelimit", + "SetCacheControlRule", + "SetCacheControlRuleActionParameters", + "SetCacheControlRuleActionParametersImmutable", + "SetCacheControlRuleActionParametersImmutableSetDirective", + "SetCacheControlRuleActionParametersImmutableRemoveDirective", + "SetCacheControlRuleActionParametersMaxAge", + "SetCacheControlRuleActionParametersMaxAgeSetDirective", + "SetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "SetCacheControlRuleActionParametersMustRevalidate", + "SetCacheControlRuleActionParametersMustRevalidateSetDirective", + "SetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "SetCacheControlRuleActionParametersMustUnderstand", + "SetCacheControlRuleActionParametersMustUnderstandSetDirective", + "SetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "SetCacheControlRuleActionParametersNoCache", + "SetCacheControlRuleActionParametersNoCacheSetDirective", + "SetCacheControlRuleActionParametersNoCacheRemoveDirective", + "SetCacheControlRuleActionParametersNoStore", + "SetCacheControlRuleActionParametersNoStoreSetDirective", + "SetCacheControlRuleActionParametersNoStoreRemoveDirective", + "SetCacheControlRuleActionParametersNoTransform", + "SetCacheControlRuleActionParametersNoTransformSetDirective", + "SetCacheControlRuleActionParametersNoTransformRemoveDirective", + "SetCacheControlRuleActionParametersPrivate", + "SetCacheControlRuleActionParametersPrivateSetDirective", + "SetCacheControlRuleActionParametersPrivateRemoveDirective", + "SetCacheControlRuleActionParametersProxyRevalidate", + "SetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "SetCacheControlRuleActionParametersPublic", + "SetCacheControlRuleActionParametersPublicSetDirective", + "SetCacheControlRuleActionParametersPublicRemoveDirective", + "SetCacheControlRuleActionParametersSMaxage", + "SetCacheControlRuleActionParametersSMaxageSetDirective", + "SetCacheControlRuleActionParametersSMaxageRemoveDirective", + "SetCacheControlRuleActionParametersStaleIfError", + "SetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "SetCacheControlRuleActionParametersStaleWhileRevalidate", + "SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "SetCacheControlRuleExposedCredentialCheck", + "SetCacheControlRulePosition", + "SetCacheControlRulePositionBeforePosition", + "SetCacheControlRulePositionAfterPosition", + "SetCacheControlRulePositionIndexPosition", + "SetCacheControlRuleRatelimit", + "SetCacheSettingsRule", + "SetCacheSettingsRuleActionParameters", + "SetCacheSettingsRuleActionParametersBrowserTTL", + "SetCacheSettingsRuleActionParametersCacheKey", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "SetCacheSettingsRuleActionParametersCacheReserve", + "SetCacheSettingsRuleActionParametersEdgeTTL", + "SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "SetCacheSettingsRuleActionParametersServeStale", + "SetCacheSettingsRuleActionParametersSharedDictionary", + "SetCacheSettingsRuleExposedCredentialCheck", + "SetCacheSettingsRulePosition", + "SetCacheSettingsRulePositionBeforePosition", + "SetCacheSettingsRulePositionAfterPosition", + "SetCacheSettingsRulePositionIndexPosition", + "SetCacheSettingsRuleRatelimit", + "SetCacheTagsRule", + "SetCacheTagsRuleActionParameters", + "SetCacheTagsRuleActionParametersAddCacheTagsValues", + "SetCacheTagsRuleActionParametersAddCacheTagsExpression", + "SetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "SetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "SetCacheTagsRuleActionParametersSetCacheTagsValues", + "SetCacheTagsRuleActionParametersSetCacheTagsExpression", + "SetCacheTagsRuleExposedCredentialCheck", + "SetCacheTagsRulePosition", + "SetCacheTagsRulePositionBeforePosition", + "SetCacheTagsRulePositionAfterPosition", + "SetCacheTagsRulePositionIndexPosition", + "SetCacheTagsRuleRatelimit", + "SetConfigurationRule", + "SetConfigurationRuleActionParameters", + "SetConfigurationRuleActionParametersAutominify", + "SetConfigurationRuleExposedCredentialCheck", + "SetConfigurationRulePosition", + "SetConfigurationRulePositionBeforePosition", + "SetConfigurationRulePositionAfterPosition", + "SetConfigurationRulePositionIndexPosition", + "SetConfigurationRuleRatelimit", + "SkipRule", + "SkipRuleActionParameters", + "SkipRuleExposedCredentialCheck", + "SkipRulePosition", + "SkipRulePositionBeforePosition", + "SkipRulePositionAfterPosition", + "SkipRulePositionIndexPosition", + "SkipRuleRatelimit", +] + + +class BlockRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["block"] + """The action to perform when the rule matches.""" + + action_parameters: BlockRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: BlockRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: BlockRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: BlockRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class BlockRuleActionParametersResponse(TypedDict, total=False): + """The response to show when the block is applied.""" + + content: Required[str] + """The content to return.""" + + content_type: Required[str] + """The type of the content to return.""" + + status_code: Required[int] + """The status code to return.""" + + +class BlockRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + response: BlockRuleActionParametersResponse + """The response to show when the block is applied.""" + + +class BlockRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class BlockRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class BlockRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class BlockRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +BlockRulePosition: TypeAlias = Union[ + BlockRulePositionBeforePosition, BlockRulePositionAfterPosition, BlockRulePositionIndexPosition +] + + +class BlockRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ChallengeRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ChallengeRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ChallengeRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ChallengeRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ChallengeRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ChallengeRulePosition: TypeAlias = Union[ + ChallengeRulePositionBeforePosition, ChallengeRulePositionAfterPosition, ChallengeRulePositionIndexPosition +] + + +class ChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ResponseCompressionRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["compress_response"] + """The action to perform when the rule matches.""" + + action_parameters: ResponseCompressionRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ResponseCompressionRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ResponseCompressionRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ResponseCompressionRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ResponseCompressionRuleActionParametersAlgorithm(TypedDict, total=False): + """Compression algorithm to enable.""" + + name: Literal["none", "auto", "default", "gzip", "brotli", "zstd"] + """Name of the compression algorithm to enable.""" + + +class ResponseCompressionRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + algorithms: Required[Iterable[ResponseCompressionRuleActionParametersAlgorithm]] + """Custom order for compression algorithms.""" + + +class ResponseCompressionRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ResponseCompressionRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ResponseCompressionRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ResponseCompressionRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ResponseCompressionRulePosition: TypeAlias = Union[ + ResponseCompressionRulePositionBeforePosition, + ResponseCompressionRulePositionAfterPosition, + ResponseCompressionRulePositionIndexPosition, +] + + +class ResponseCompressionRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class DDoSDynamicRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: DDoSDynamicRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: DDoSDynamicRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: DDoSDynamicRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class DDoSDynamicRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class DDoSDynamicRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class DDoSDynamicRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class DDoSDynamicRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +DDoSDynamicRulePosition: TypeAlias = Union[ + DDoSDynamicRulePositionBeforePosition, DDoSDynamicRulePositionAfterPosition, DDoSDynamicRulePositionIndexPosition +] + + +class DDoSDynamicRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ExecuteRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["execute"] + """The action to perform when the rule matches.""" + + action_parameters: ExecuteRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExecuteRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ExecuteRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ExecuteRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ExecuteRuleActionParametersMatchedData(TypedDict, total=False): + """The configuration to use for matched data logging.""" + + public_key: Required[str] + """The public key to encrypt matched data logs with.""" + + +class ExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): + """A category-level override.""" + + category: Required[str] + """The name of the category to override.""" + + action: str + """The action to override rules in the category with.""" + + enabled: bool + """Whether to enable execution of rules in the category.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """The sensitivity level to use for rules in the category. + + This option is only applicable for DDoS phases. + """ + + +class ExecuteRuleActionParametersOverridesRule(TypedDict, total=False): + """A rule-level override.""" + + id: Required[str] + """The ID of the rule to override.""" + + action: str + """The action to override the rule with.""" + + enabled: bool + """Whether to enable execution of the rule.""" + + score_threshold: int + """The score threshold to use for the rule.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """The sensitivity level to use for the rule. + + This option is only applicable for DDoS phases. + """ + + +class ExecuteRuleActionParametersOverrides(TypedDict, total=False): + """A set of overrides to apply to the target ruleset.""" + + action: str + """An action to override all rules with. + + This option has lower precedence than rule and category overrides. + """ + + categories: Iterable[ExecuteRuleActionParametersOverridesCategory] + """A list of category-level overrides. + + This option has the second-highest precedence after rule-level overrides. + """ + + enabled: bool + """Whether to enable execution of all rules. + + This option has lower precedence than rule and category overrides. + """ + + rules: Iterable[ExecuteRuleActionParametersOverridesRule] + """A list of rule-level overrides. This option has the highest precedence.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """A sensitivity level to set for all rules. + + This option has lower precedence than rule and category overrides and is only + applicable for DDoS phases. + """ + + +class ExecuteRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + id: Required[str] + """The ID of the ruleset to execute.""" + + matched_data: ExecuteRuleActionParametersMatchedData + """The configuration to use for matched data logging.""" + + overrides: ExecuteRuleActionParametersOverrides + """A set of overrides to apply to the target ruleset.""" + + +class ExecuteRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ExecuteRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ExecuteRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ExecuteRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ExecuteRulePosition: TypeAlias = Union[ + ExecuteRulePositionBeforePosition, ExecuteRulePositionAfterPosition, ExecuteRulePositionIndexPosition +] + + +class ExecuteRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ForceConnectionCloseRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ForceConnectionCloseRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ForceConnectionCloseRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ForceConnectionCloseRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ForceConnectionCloseRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ForceConnectionCloseRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ForceConnectionCloseRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ForceConnectionCloseRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ForceConnectionCloseRulePosition: TypeAlias = Union[ + ForceConnectionCloseRulePositionBeforePosition, + ForceConnectionCloseRulePositionAfterPosition, + ForceConnectionCloseRulePositionIndexPosition, +] + + +class ForceConnectionCloseRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class JavaScriptChallengeRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: JavaScriptChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: JavaScriptChallengeRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: JavaScriptChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class JavaScriptChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class JavaScriptChallengeRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class JavaScriptChallengeRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class JavaScriptChallengeRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +JavaScriptChallengeRulePosition: TypeAlias = Union[ + JavaScriptChallengeRulePositionBeforePosition, + JavaScriptChallengeRulePositionAfterPosition, + JavaScriptChallengeRulePositionIndexPosition, +] + + +class JavaScriptChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class LogRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["log"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: LogRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: LogRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: LogRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class LogRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class LogRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class LogRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class LogRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +LogRulePosition: TypeAlias = Union[ + LogRulePositionBeforePosition, LogRulePositionAfterPosition, LogRulePositionIndexPosition +] + + +class LogRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class LogCustomFieldRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["log_custom_field"] + """The action to perform when the rule matches.""" + + action_parameters: LogCustomFieldRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: LogCustomFieldRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: LogCustomFieldRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: LogCustomFieldRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class LogCustomFieldRuleActionParametersCookieField(TypedDict, total=False): + """The cookie field to log.""" + + name: Required[str] + """The name of the cookie.""" + + +class LogCustomFieldRuleActionParametersRawResponseField(TypedDict, total=False): + """The raw response field to log.""" + + name: Required[str] + """The name of the response header.""" + + preserve_duplicates: bool + """Whether to log duplicate values of the same header.""" + + +class LogCustomFieldRuleActionParametersRequestField(TypedDict, total=False): + """The raw request field to log.""" + + name: Required[str] + """The name of the header.""" + + +class LogCustomFieldRuleActionParametersResponseField(TypedDict, total=False): + """The transformed response field to log.""" + + name: Required[str] + """The name of the response header.""" + + preserve_duplicates: bool + """Whether to log duplicate values of the same header.""" + + +class LogCustomFieldRuleActionParametersTransformedRequestField(TypedDict, total=False): + """The transformed request field to log.""" + + name: Required[str] + """The name of the header.""" + + +class LogCustomFieldRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + cookie_fields: Iterable[LogCustomFieldRuleActionParametersCookieField] + """The cookie fields to log.""" + + raw_response_fields: Iterable[LogCustomFieldRuleActionParametersRawResponseField] + """The raw response fields to log.""" + + request_fields: Iterable[LogCustomFieldRuleActionParametersRequestField] + """The raw request fields to log.""" + + response_fields: Iterable[LogCustomFieldRuleActionParametersResponseField] + """The transformed response fields to log.""" + + transformed_request_fields: Iterable[LogCustomFieldRuleActionParametersTransformedRequestField] + """The transformed request fields to log.""" + + +class LogCustomFieldRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class LogCustomFieldRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class LogCustomFieldRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class LogCustomFieldRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +LogCustomFieldRulePosition: TypeAlias = Union[ + LogCustomFieldRulePositionBeforePosition, + LogCustomFieldRulePositionAfterPosition, + LogCustomFieldRulePositionIndexPosition, +] + + +class LogCustomFieldRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ManagedChallengeRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["managed_challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ManagedChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ManagedChallengeRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ManagedChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ManagedChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ManagedChallengeRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ManagedChallengeRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ManagedChallengeRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ManagedChallengeRulePosition: TypeAlias = Union[ + ManagedChallengeRulePositionBeforePosition, + ManagedChallengeRulePositionAfterPosition, + ManagedChallengeRulePositionIndexPosition, +] + + +class ManagedChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RedirectRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["redirect"] + """The action to perform when the rule matches.""" + + action_parameters: RedirectRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RedirectRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: RedirectRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: RedirectRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RedirectRuleActionParametersFromList(TypedDict, total=False): + """A redirect based on a bulk list lookup.""" + + key: Required[str] + """An expression that evaluates to the list lookup key.""" + + name: Required[str] + """The name of the list to match against.""" + + +class RedirectRuleActionParametersFromValueTargetURL(TypedDict, total=False): + """A URL to redirect the request to.""" + + expression: str + """An expression that evaluates to a URL to redirect the request to.""" + + value: str + """A URL to redirect the request to.""" + + +class RedirectRuleActionParametersFromValue(TypedDict, total=False): + """A redirect based on the request properties.""" + + target_url: Required[RedirectRuleActionParametersFromValueTargetURL] + """A URL to redirect the request to.""" + + preserve_query_string: bool + """Whether to keep the query string of the original request.""" + + status_code: Literal[301, 302, 303, 307, 308] + """The status code to use for the redirect.""" + + +class RedirectRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + from_list: RedirectRuleActionParametersFromList + """A redirect based on a bulk list lookup.""" + + from_value: RedirectRuleActionParametersFromValue + """A redirect based on the request properties.""" + + +class RedirectRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RedirectRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class RedirectRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class RedirectRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +RedirectRulePosition: TypeAlias = Union[ + RedirectRulePositionBeforePosition, RedirectRulePositionAfterPosition, RedirectRulePositionIndexPosition +] + + +class RedirectRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RewriteRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["rewrite"] + """The action to perform when the rule matches.""" + + action_parameters: RewriteRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RewriteRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: RewriteRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: RewriteRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RewriteRuleActionParametersHeadersAddStaticHeader(TypedDict, total=False): + """A header with a static value to add.""" + + operation: Required[Literal["add"]] + """The operation to perform on the header.""" + + value: Required[str] + """A static value for the header.""" + + +class RewriteRuleActionParametersHeadersAddDynamicHeader(TypedDict, total=False): + """A header with a dynamic value to add.""" + + expression: Required[str] + """An expression that evaluates to a value for the header.""" + + operation: Required[Literal["add"]] + """The operation to perform on the header.""" + + +class RewriteRuleActionParametersHeadersSetStaticHeader(TypedDict, total=False): + """A header with a static value to set.""" + + operation: Required[Literal["set"]] + """The operation to perform on the header.""" + + value: Required[str] + """A static value for the header.""" + + +class RewriteRuleActionParametersHeadersSetDynamicHeader(TypedDict, total=False): + """A header with a dynamic value to set.""" + + expression: Required[str] + """An expression that evaluates to a value for the header.""" + + operation: Required[Literal["set"]] + """The operation to perform on the header.""" + + +class RewriteRuleActionParametersHeadersRemoveHeader(TypedDict, total=False): + """A header to remove.""" + + operation: Required[Literal["remove"]] + """The operation to perform on the header.""" + + +RewriteRuleActionParametersHeaders: TypeAlias = Union[ + RewriteRuleActionParametersHeadersAddStaticHeader, + RewriteRuleActionParametersHeadersAddDynamicHeader, + RewriteRuleActionParametersHeadersSetStaticHeader, + RewriteRuleActionParametersHeadersSetDynamicHeader, + RewriteRuleActionParametersHeadersRemoveHeader, +] + + +class RewriteRuleActionParametersURIURIPathPath(TypedDict, total=False): + """A URI path rewrite.""" + + expression: str + """An expression that evaluates to a value to rewrite the URI path to.""" + + value: str + """A value to rewrite the URI path to.""" + + +class RewriteRuleActionParametersURIURIPath(TypedDict, total=False): + """A URI path rewrite.""" + + path: Required[RewriteRuleActionParametersURIURIPathPath] + """A URI path rewrite.""" + + +class RewriteRuleActionParametersURIURIQueryQuery(TypedDict, total=False): + """A URI query rewrite.""" + + expression: str + """An expression that evaluates to a value to rewrite the URI query to.""" + + value: str + """A value to rewrite the URI query to.""" + + +class RewriteRuleActionParametersURIURIQuery(TypedDict, total=False): + """A URI query rewrite.""" + + query: Required[RewriteRuleActionParametersURIURIQueryQuery] + """A URI query rewrite.""" + + +RewriteRuleActionParametersURI: TypeAlias = Union[ + RewriteRuleActionParametersURIURIPath, RewriteRuleActionParametersURIURIQuery +] + + +class RewriteRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + headers: Dict[str, RewriteRuleActionParametersHeaders] + """A map of headers to rewrite.""" + + uri: RewriteRuleActionParametersURI + """A URI path rewrite.""" + + +class RewriteRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RewriteRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class RewriteRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class RewriteRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +RewriteRulePosition: TypeAlias = Union[ + RewriteRulePositionBeforePosition, RewriteRulePositionAfterPosition, RewriteRulePositionIndexPosition +] + + +class RewriteRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RouteRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["route"] + """The action to perform when the rule matches.""" + + action_parameters: RouteRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RouteRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: RouteRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: RouteRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RouteRuleActionParametersOrigin(TypedDict, total=False): + """An origin to route to.""" + + host: str + """A resolved host to route to.""" + + port: int + """A destination port to route to.""" + + +class RouteRuleActionParametersSNI(TypedDict, total=False): + """A Server Name Indication (SNI) override.""" + + value: Required[str] + """A value to override the SNI to.""" + + +class RouteRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + host_header: str + """A value to rewrite the HTTP host header to.""" + + origin: RouteRuleActionParametersOrigin + """An origin to route to.""" + + sni: RouteRuleActionParametersSNI + """A Server Name Indication (SNI) override.""" + + +class RouteRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RouteRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class RouteRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class RouteRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +RouteRulePosition: TypeAlias = Union[ + RouteRulePositionBeforePosition, RouteRulePositionAfterPosition, RouteRulePositionIndexPosition +] + + +class RouteRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ScoreRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["score"] + """The action to perform when the rule matches.""" + + action_parameters: ScoreRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ScoreRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ScoreRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ScoreRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ScoreRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + increment: Required[int] + """A delta to change the score by, which can be either positive or negative.""" + + +class ScoreRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ScoreRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ScoreRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ScoreRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ScoreRulePosition: TypeAlias = Union[ + ScoreRulePositionBeforePosition, ScoreRulePositionAfterPosition, ScoreRulePositionIndexPosition +] + + +class ScoreRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ServeErrorRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["serve_error"] + """The action to perform when the rule matches.""" + + action_parameters: ServeErrorRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ServeErrorRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: ServeErrorRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: ServeErrorRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class ServeErrorRuleActionParametersActionParametersContent(TypedDict, total=False): + content: Required[str] + """The response content.""" + + content_type: Literal["application/json", "text/html", "text/plain", "text/xml"] + """The content type header to set with the error response.""" + + status_code: int + """The status code to use for the error.""" + + +class ServeErrorRuleActionParametersActionParametersAsset(TypedDict, total=False): + asset_name: Required[str] + """The name of a custom asset to serve as the error response.""" + + content_type: Literal["application/json", "text/html", "text/plain", "text/xml"] + """The content type header to set with the error response.""" + + status_code: int + """The status code to use for the error.""" + + +ServeErrorRuleActionParameters: TypeAlias = Union[ + ServeErrorRuleActionParametersActionParametersContent, ServeErrorRuleActionParametersActionParametersAsset +] + + +class ServeErrorRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class ServeErrorRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class ServeErrorRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class ServeErrorRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +ServeErrorRulePosition: TypeAlias = Union[ + ServeErrorRulePositionBeforePosition, ServeErrorRulePositionAfterPosition, ServeErrorRulePositionIndexPosition +] + + +class ServeErrorRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetCacheControlRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheControlRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + SetCacheControlRuleActionParametersImmutableSetDirective, + SetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class SetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + SetCacheControlRuleActionParametersMaxAgeSetDirective, SetCacheControlRuleActionParametersMaxAgeRemoveDirective +] + + +class SetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersMustRevalidateSetDirective, + SetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + SetCacheControlRuleActionParametersMustUnderstandSetDirective, + SetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class SetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class SetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoCacheSetDirective, SetCacheControlRuleActionParametersNoCacheRemoveDirective +] + + +class SetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoStoreSetDirective, SetCacheControlRuleActionParametersNoStoreRemoveDirective +] + + +class SetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoTransformSetDirective, + SetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class SetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class SetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + SetCacheControlRuleActionParametersPrivateSetDirective, SetCacheControlRuleActionParametersPrivateRemoveDirective +] + + +class SetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersProxyRevalidateSetDirective, + SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + SetCacheControlRuleActionParametersPublicSetDirective, SetCacheControlRuleActionParametersPublicRemoveDirective +] + + +class SetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + SetCacheControlRuleActionParametersSMaxageSetDirective, SetCacheControlRuleActionParametersSMaxageRemoveDirective +] + + +class SetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + SetCacheControlRuleActionParametersStaleIfErrorSetDirective, + SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: SetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[SetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[SetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate")] + """A cache-control directive configuration.""" + + must_understand: Annotated[SetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand")] + """A cache-control directive configuration.""" + + no_cache: Annotated[SetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[SetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[SetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform")] + """A cache-control directive configuration.""" + + private: SetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + SetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: SetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[SetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[SetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + SetCacheControlRuleActionParametersStaleWhileRevalidate, PropertyInfo(alias="stale-while-revalidate") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class SetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheControlRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheControlRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheControlRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheControlRulePosition: TypeAlias = Union[ + SetCacheControlRulePositionBeforePosition, + SetCacheControlRulePositionAfterPosition, + SetCacheControlRulePositionIndexPosition, +] + + +class SetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetCacheSettingsRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_settings"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheSettingsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheSettingsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheSettingsRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheSettingsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheSettingsRuleActionParametersBrowserTTL(TypedDict, total=False): + """How long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high browser TTLs may lead to stale content. + """ + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin", "bypass"]] + """The browser TTL mode.""" + + default: int + """The browser TTL (in seconds) if you choose the "override_origin" mode.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(TypedDict, total=False): + """Which cookies to include in the cache key.""" + + check_presence: SequenceNotStr[str] + """A list of cookies to check for the presence of. + + The presence of these cookies is included in the cache key. + """ + + include: SequenceNotStr[str] + """A list of cookies to include in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(TypedDict, total=False): + """Which headers to include in the cache key.""" + + check_presence: SequenceNotStr[str] + """A list of headers to check for the presence of. + + The presence of these headers is included in the cache key. + """ + + contains: Dict[str, SequenceNotStr[str]] + """A mapping of header names to a list of values. + + If a header is present in the request and contains any of the values provided, + its value is included in the cache key. + """ + + exclude_origin: bool + """Whether to exclude the origin header in the cache key.""" + + include: SequenceNotStr[str] + """A list of headers to include in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(TypedDict, total=False): + """How to use the host in the cache key.""" + + resolved: bool + """Whether to use the resolved host in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(TypedDict, total=False): + """Which query string parameters to exclude from the cache key.""" + + all: Literal[True] + """Whether to exclude all query string parameters from the cache key.""" + + list: SequenceNotStr[str] + """A list of query string parameters to exclude from the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(TypedDict, total=False): + """Which query string parameters to include in the cache key.""" + + all: Literal[True] + """Whether to include all query string parameters in the cache key.""" + + list: SequenceNotStr[str] + """A list of query string parameters to include in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(TypedDict, total=False): + """Which query string parameters to include in or exclude from the cache key.""" + + exclude: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude + """Which query string parameters to exclude from the cache key.""" + + include: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude + """Which query string parameters to include in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(TypedDict, total=False): + """How to use characteristics of the request user agent in the cache key.""" + + device_type: bool + """Whether to use the user agent's device type in the cache key.""" + + geo: bool + """Whether to use the user agents's country in the cache key.""" + + lang: bool + """Whether to use the user agent's language in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKeyCustomKey(TypedDict, total=False): + """Which components of the request are included or excluded from the cache key.""" + + cookie: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie + """Which cookies to include in the cache key.""" + + header: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader + """Which headers to include in the cache key.""" + + host: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost + """How to use the host in the cache key.""" + + query_string: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString + """Which query string parameters to include in or exclude from the cache key.""" + + user: SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser + """How to use characteristics of the request user agent in the cache key.""" + + +class SetCacheSettingsRuleActionParametersCacheKey(TypedDict, total=False): + """ + Which components of the request are included in or excluded from the cache key Cloudflare uses to store the response in cache. + """ + + cache_by_device_type: bool + """Whether to separate cached content based on the visitor's device type.""" + + cache_deception_armor: bool + """ + Whether to protect from web cache deception attacks, while allowing static + assets to be cached. + """ + + custom_key: SetCacheSettingsRuleActionParametersCacheKeyCustomKey + """Which components of the request are included or excluded from the cache key.""" + + ignore_query_strings_order: bool + """ + Whether to treat requests with the same query parameters the same, regardless of + the order those query parameters are in. + """ + + +class SetCacheSettingsRuleActionParametersCacheReserve(TypedDict, total=False): + """ + Settings to determine whether the request's response from origin is eligible for Cache Reserve (requires a Cache Reserve add-on plan). + """ + + eligible: Required[bool] + """Whether Cache Reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to Cache Reserve. + """ + + minimum_file_size: int + """The minimum file size eligible for storage in Cache Reserve.""" + + +_SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords = TypedDict( + "_SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords", + { + "from": int, + }, + total=False, +) + + +class SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange( + _SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords, total=False +): + """A range of status codes to apply the TTL to.""" + + to: int + """The upper bound of the range.""" + + +class SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(TypedDict, total=False): + value: Required[int] + """The time to cache the response for (in seconds). + + A value of 0 is equivalent to setting the cache control header with the value + "no-cache". A value of -1 is equivalent to setting the cache control header with + the value of "no-store". + """ + + status_code: int + """A single status code to apply the TTL to.""" + + status_code_range: SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + """A range of status codes to apply the TTL to.""" + + +class SetCacheSettingsRuleActionParametersEdgeTTL(TypedDict, total=False): + """How long the Cloudflare edge network should cache the response.""" + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """The edge TTL mode.""" + + default: int + """The edge TTL (in seconds) if you choose the "override_origin" mode.""" + + status_code_ttl: Iterable[SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """A list of TTLs to apply to specific status codes or status code ranges.""" + + +class SetCacheSettingsRuleActionParametersServeStale(TypedDict, total=False): + """When to serve stale content from cache.""" + + disable_stale_while_updating: bool + """ + Whether Cloudflare should disable serving stale content while getting the latest + content from the origin. + """ + + +class SetCacheSettingsRuleActionParametersSharedDictionary(TypedDict, total=False): + """Configuration for shared dictionary compression. + + When set, Cloudflare injects Use-As-Dictionary headers on matching cacheable responses. + """ + + match_pattern: Required[str] + """URL pattern for the Use-As-Dictionary match field. + + This pattern specifies which URLs can use this response as a dictionary. + """ + + +class SetCacheSettingsRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + additional_cacheable_ports: Iterable[int] + """A list of additional ports that caching should be enabled on.""" + + browser_ttl: SetCacheSettingsRuleActionParametersBrowserTTL + """How long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: bool + """Whether the request's response from the origin is eligible for caching. + + Caching itself will still depend on the cache control header and your other + caching configurations. + """ + + cache_key: SetCacheSettingsRuleActionParametersCacheKey + """ + Which components of the request are included in or excluded from the cache key + Cloudflare uses to store the response in cache. + """ + + cache_reserve: SetCacheSettingsRuleActionParametersCacheReserve + """ + Settings to determine whether the request's response from origin is eligible for + Cache Reserve (requires a Cache Reserve add-on plan). + """ + + edge_ttl: SetCacheSettingsRuleActionParametersEdgeTTL + """How long the Cloudflare edge network should cache the response.""" + + origin_cache_control: bool + """Whether Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: bool + """Whether to generate Cloudflare error pages for issues from the origin server.""" + + read_timeout: int + """ + A timeout value between two successive read operations to use for your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: bool + """Whether Cloudflare should respect strong ETag (entity tag) headers. + + If false, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: SetCacheSettingsRuleActionParametersServeStale + """When to serve stale content from cache.""" + + shared_dictionary: SetCacheSettingsRuleActionParametersSharedDictionary + """Configuration for shared dictionary compression. + + When set, Cloudflare injects Use-As-Dictionary headers on matching cacheable + responses. + """ + + strip_etags: bool + """Whether to strip ETag headers from the origin response before caching.""" + + strip_last_modified: bool + """Whether to strip Last-Modified headers from the origin response before caching.""" + + strip_set_cookie: bool + """Whether to strip Set-Cookie headers from the origin response before caching.""" + + +class SetCacheSettingsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheSettingsRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheSettingsRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheSettingsRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheSettingsRulePosition: TypeAlias = Union[ + SetCacheSettingsRulePositionBeforePosition, + SetCacheSettingsRulePositionAfterPosition, + SetCacheSettingsRulePositionIndexPosition, +] + + +class SetCacheSettingsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetCacheTagsRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheTagsRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class SetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class SetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +SetCacheTagsRuleActionParameters: TypeAlias = Union[ + SetCacheTagsRuleActionParametersAddCacheTagsValues, + SetCacheTagsRuleActionParametersAddCacheTagsExpression, + SetCacheTagsRuleActionParametersRemoveCacheTagsValues, + SetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + SetCacheTagsRuleActionParametersSetCacheTagsValues, + SetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class SetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheTagsRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheTagsRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheTagsRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheTagsRulePosition: TypeAlias = Union[ + SetCacheTagsRulePositionBeforePosition, SetCacheTagsRulePositionAfterPosition, SetCacheTagsRulePositionIndexPosition +] + + +class SetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetConfigurationRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_config"] + """The action to perform when the rule matches.""" + + action_parameters: SetConfigurationRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetConfigurationRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetConfigurationRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetConfigurationRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetConfigurationRuleActionParametersAutominify(TypedDict, total=False): + """Which file extensions to minify automatically.""" + + css: bool + """Whether to minify CSS files.""" + + html: bool + """Whether to minify HTML files.""" + + js: bool + """Whether to minify JavaScript files.""" + + +class SetConfigurationRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + automatic_https_rewrites: bool + """Whether to enable Automatic HTTPS Rewrites.""" + + autominify: SetConfigurationRuleActionParametersAutominify + """Which file extensions to minify automatically.""" + + bic: bool + """Whether to enable Browser Integrity Check (BIC).""" + + content_converter: bool + """Whether to enable content conversion (e.g., HTML to Markdown).""" + + disable_apps: Literal[True] + """Whether to disable Cloudflare Apps.""" + + disable_pay_per_crawl: Literal[True] + """Whether to disable Pay Per Crawl.""" + + disable_rum: Literal[True] + """Whether to disable Real User Monitoring (RUM).""" + + disable_zaraz: Literal[True] + """Whether to disable Zaraz.""" + + email_obfuscation: bool + """Whether to enable Email Obfuscation.""" + + fonts: bool + """Whether to enable Cloudflare Fonts.""" + + hotlink_protection: bool + """Whether to enable Hotlink Protection.""" + + mirage: bool + """Whether to enable Mirage.""" + + opportunistic_encryption: bool + """Whether to enable Opportunistic Encryption.""" + + polish: Literal["off", "lossless", "lossy", "webp"] + """The Polish level to configure.""" + + redirects_for_ai_training: bool + """ + Whether to redirect verified AI training crawlers to canonical URLs found in the + HTML response. + """ + + request_body_buffering: Literal["none", "standard", "full"] + """The request body buffering mode.""" + + response_body_buffering: Literal["none", "standard"] + """The response body buffering mode.""" + + rocket_loader: bool + """Whether to enable Rocket Loader.""" + + security_level: Literal["off", "essentially_off", "low", "medium", "high", "under_attack"] + """The Security Level to configure.""" + + server_side_excludes: bool + """Whether to enable Server-Side Excludes.""" + + ssl: Literal["off", "flexible", "full", "strict", "origin_pull"] + """The SSL level to configure.""" + + sxg: bool + """Whether to enable Signed Exchanges (SXG).""" + + +class SetConfigurationRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetConfigurationRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetConfigurationRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetConfigurationRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetConfigurationRulePosition: TypeAlias = Union[ + SetConfigurationRulePositionBeforePosition, + SetConfigurationRulePositionAfterPosition, + SetConfigurationRulePositionIndexPosition, +] + + +class SetConfigurationRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SkipRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["skip"] + """The action to perform when the rule matches.""" + + action_parameters: SkipRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SkipRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SkipRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SkipRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SkipRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + phase: Literal["current"] + """A phase to skip the execution of. + + This option is only compatible with the products option. + """ + + phases: List[Phase] + """A list of phases to skip the execution of. + + This option is incompatible with the rulesets option. + """ + + products: List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] + """A list of legacy security products to skip the execution of.""" + + rules: Dict[str, SequenceNotStr[str]] + """ + A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + execution of. This option is incompatible with the ruleset option. + """ + + ruleset: Literal["current"] + """A ruleset to skip the execution of. + + This option is incompatible with the rulesets option. + """ + + rulesets: SequenceNotStr[str] + """A list of ruleset IDs to skip the execution of. + + This option is incompatible with the ruleset and phases options. + """ + + +class SkipRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SkipRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SkipRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SkipRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SkipRulePosition: TypeAlias = Union[ + SkipRulePositionBeforePosition, SkipRulePositionAfterPosition, SkipRulePositionIndexPosition +] + + +class SkipRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +RuleEditParams: TypeAlias = Union[ + BlockRule, + ChallengeRule, + ResponseCompressionRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + JavaScriptChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetCacheControlRule, + SetCacheSettingsRule, + SetCacheTagsRule, + SetConfigurationRule, + SkipRule, +] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py new file mode 100644 index 00000000000..73f8f8cc4aa --- /dev/null +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from .kind import Kind +from .phase import Phase +from .logging import Logging +from ..._utils import PropertyInfo +from .log_rule import LogRule +from ..._models import BaseModel +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .route_rule import RouteRule +from .score_rule import ScoreRule +from .execute_rule import ExecuteRule +from .rewrite_rule import RewriteRule +from .redirect_rule import RedirectRule +from .set_config_rule import SetConfigRule +from .serve_error_rule import ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule +from .log_custom_field_rule import LogCustomFieldRule +from .compress_response_rule import CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule +from .set_cache_settings_rule import SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "RuleEditResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class RuleEditResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/ruleset_create_params.py b/src/cloudflare/types/rulesets/ruleset_create_params.py new file mode 100644 index 00000000000..e1130c331fa --- /dev/null +++ b/src/cloudflare/types/rulesets/ruleset_create_params.py @@ -0,0 +1,997 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from .kind import Kind +from .phase import Phase +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo +from .logging_param import LoggingParam +from .log_rule_param import LogRuleParam +from .skip_rule_param import SkipRuleParam +from .block_rule_param import BlockRuleParam +from .route_rule_param import RouteRuleParam +from .score_rule_param import ScoreRuleParam +from .execute_rule_param import ExecuteRuleParam +from .rewrite_rule_param import RewriteRuleParam +from .redirect_rule_param import RedirectRuleParam +from .set_config_rule_param import SetConfigRuleParam +from .serve_error_rule_param import ServeErrorRuleParam +from .ddos_dynamic_rule_param import DDoSDynamicRuleParam +from .log_custom_field_rule_param import LogCustomFieldRuleParam +from .compress_response_rule_param import CompressResponseRuleParam +from .managed_challenge_rule_param import ManagedChallengeRuleParam +from .set_cache_settings_rule_param import SetCacheSettingsRuleParam +from .force_connection_close_rule_param import ForceConnectionCloseRuleParam + +__all__ = [ + "RulesetCreateParams", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RulesetCreateParams(TypedDict, total=False): + kind: Required[Kind] + """The kind of the ruleset.""" + + name: Required[str] + """The human-readable name of the ruleset.""" + + phase: Required[Phase] + """The phase of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + description: str + """An informative description of the ruleset.""" + + rules: Iterable[Rule] + """The list of rules in the ruleset.""" + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsJSChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsJSChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: RuleRulesetsSetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[RuleRulesetsSetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate") + ] + """A cache-control directive configuration.""" + + must_understand: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand") + ] + """A cache-control directive configuration.""" + + no_cache: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform") + ] + """A cache-control directive configuration.""" + + private: RuleRulesetsSetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: RuleRulesetsSetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[RuleRulesetsSetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate, + PropertyInfo(alias="stale-while-revalidate"), + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Union[ + BlockRuleParam, + RuleRulesetsChallengeRule, + CompressResponseRuleParam, + DDoSDynamicRuleParam, + ExecuteRuleParam, + ForceConnectionCloseRuleParam, + RuleRulesetsJSChallengeRule, + LogRuleParam, + LogCustomFieldRuleParam, + ManagedChallengeRuleParam, + RedirectRuleParam, + RewriteRuleParam, + RouteRuleParam, + ScoreRuleParam, + ServeErrorRuleParam, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRuleParam, + RuleRulesetsSetCacheTagsRule, + SetConfigRuleParam, + SkipRuleParam, +] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py new file mode 100644 index 00000000000..996e8edac9d --- /dev/null +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from .kind import Kind +from .phase import Phase +from .logging import Logging +from ..._utils import PropertyInfo +from .log_rule import LogRule +from ..._models import BaseModel +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .route_rule import RouteRule +from .score_rule import ScoreRule +from .execute_rule import ExecuteRule +from .rewrite_rule import RewriteRule +from .redirect_rule import RedirectRule +from .set_config_rule import SetConfigRule +from .serve_error_rule import ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule +from .log_custom_field_rule import LogCustomFieldRule +from .compress_response_rule import CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule +from .set_cache_settings_rule import SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "RulesetCreateResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class RulesetCreateResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py new file mode 100644 index 00000000000..642243625e4 --- /dev/null +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from .kind import Kind +from .phase import Phase +from .logging import Logging +from ..._utils import PropertyInfo +from .log_rule import LogRule +from ..._models import BaseModel +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .route_rule import RouteRule +from .score_rule import ScoreRule +from .execute_rule import ExecuteRule +from .rewrite_rule import RewriteRule +from .redirect_rule import RedirectRule +from .set_config_rule import SetConfigRule +from .serve_error_rule import ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule +from .log_custom_field_rule import LogCustomFieldRule +from .compress_response_rule import CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule +from .set_cache_settings_rule import SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "RulesetGetResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class RulesetGetResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/ruleset_list_params.py b/src/cloudflare/types/rulesets/ruleset_list_params.py new file mode 100644 index 00000000000..277016e47c6 --- /dev/null +++ b/src/cloudflare/types/rulesets/ruleset_list_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["RulesetListParams"] + + +class RulesetListParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + cursor: str + """The cursor to use for the next page.""" + + per_page: int + """The number of rulesets to return per page.""" diff --git a/src/cloudflare/types/rulesets/ruleset_list_response.py b/src/cloudflare/types/rulesets/ruleset_list_response.py new file mode 100644 index 00000000000..c892b62467f --- /dev/null +++ b/src/cloudflare/types/rulesets/ruleset_list_response.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from .kind import Kind +from .phase import Phase +from ..._models import BaseModel + +__all__ = ["RulesetListResponse"] + + +class RulesetListResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/ruleset_update_params.py b/src/cloudflare/types/rulesets/ruleset_update_params.py new file mode 100644 index 00000000000..75ac54d4e87 --- /dev/null +++ b/src/cloudflare/types/rulesets/ruleset_update_params.py @@ -0,0 +1,997 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from .kind import Kind +from .phase import Phase +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo +from .logging_param import LoggingParam +from .log_rule_param import LogRuleParam +from .skip_rule_param import SkipRuleParam +from .block_rule_param import BlockRuleParam +from .route_rule_param import RouteRuleParam +from .score_rule_param import ScoreRuleParam +from .execute_rule_param import ExecuteRuleParam +from .rewrite_rule_param import RewriteRuleParam +from .redirect_rule_param import RedirectRuleParam +from .set_config_rule_param import SetConfigRuleParam +from .serve_error_rule_param import ServeErrorRuleParam +from .ddos_dynamic_rule_param import DDoSDynamicRuleParam +from .log_custom_field_rule_param import LogCustomFieldRuleParam +from .compress_response_rule_param import CompressResponseRuleParam +from .managed_challenge_rule_param import ManagedChallengeRuleParam +from .set_cache_settings_rule_param import SetCacheSettingsRuleParam +from .force_connection_close_rule_param import ForceConnectionCloseRuleParam + +__all__ = [ + "RulesetUpdateParams", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RulesetUpdateParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + description: str + """An informative description of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: Iterable[Rule] + """The list of rules in the ruleset.""" + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsJSChallengeRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsJSChallengeRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: RuleRulesetsSetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[RuleRulesetsSetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate") + ] + """A cache-control directive configuration.""" + + must_understand: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand") + ] + """A cache-control directive configuration.""" + + no_cache: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform") + ] + """A cache-control directive configuration.""" + + private: RuleRulesetsSetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: RuleRulesetsSetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[RuleRulesetsSetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate, + PropertyInfo(alias="stale-while-revalidate"), + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Union[ + BlockRuleParam, + RuleRulesetsChallengeRule, + CompressResponseRuleParam, + DDoSDynamicRuleParam, + ExecuteRuleParam, + ForceConnectionCloseRuleParam, + RuleRulesetsJSChallengeRule, + LogRuleParam, + LogCustomFieldRuleParam, + ManagedChallengeRuleParam, + RedirectRuleParam, + RewriteRuleParam, + RouteRuleParam, + ScoreRuleParam, + ServeErrorRuleParam, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRuleParam, + RuleRulesetsSetCacheTagsRule, + SetConfigRuleParam, + SkipRuleParam, +] diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py new file mode 100644 index 00000000000..a323e0af695 --- /dev/null +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from .kind import Kind +from .phase import Phase +from .logging import Logging +from ..._utils import PropertyInfo +from .log_rule import LogRule +from ..._models import BaseModel +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .route_rule import RouteRule +from .score_rule import ScoreRule +from .execute_rule import ExecuteRule +from .rewrite_rule import RewriteRule +from .redirect_rule import RedirectRule +from .set_config_rule import SetConfigRule +from .serve_error_rule import ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule +from .log_custom_field_rule import LogCustomFieldRule +from .compress_response_rule import CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule +from .set_cache_settings_rule import SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "RulesetUpdateResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class RulesetUpdateResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/score_rule.py b/src/cloudflare/types/rulesets/score_rule.py new file mode 100644 index 00000000000..db10d7f1e65 --- /dev/null +++ b/src/cloudflare/types/rulesets/score_rule.py @@ -0,0 +1,114 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = ["ScoreRule", "ActionParameters", "ExposedCredentialCheck", "Ratelimit"] + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + increment: int + """A delta to change the score by, which can be either positive or negative.""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ScoreRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/score_rule_param.py b/src/cloudflare/types/rulesets/score_rule_param.py new file mode 100644 index 00000000000..8f429ddc7b4 --- /dev/null +++ b/src/cloudflare/types/rulesets/score_rule_param.py @@ -0,0 +1,105 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = ["ScoreRuleParam", "ActionParameters", "ExposedCredentialCheck", "Ratelimit"] + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + increment: Required[int] + """A delta to change the score by, which can be either positive or negative.""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ScoreRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["score"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/serve_error_rule.py b/src/cloudflare/types/rulesets/serve_error_rule.py new file mode 100644 index 00000000000..6f201bc5b47 --- /dev/null +++ b/src/cloudflare/types/rulesets/serve_error_rule.py @@ -0,0 +1,139 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, TypeAlias + +from .logging import Logging +from ..._models import BaseModel + +__all__ = [ + "ServeErrorRule", + "ActionParameters", + "ActionParametersActionParametersContent", + "ActionParametersActionParametersAsset", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersActionParametersContent(BaseModel): + content: str + """The response content.""" + + content_type: Optional[Literal["application/json", "text/html", "text/plain", "text/xml"]] = None + """The content type header to set with the error response.""" + + status_code: Optional[int] = None + """The status code to use for the error.""" + + +class ActionParametersActionParametersAsset(BaseModel): + asset_name: str + """The name of a custom asset to serve as the error response.""" + + content_type: Optional[Literal["application/json", "text/html", "text/plain", "text/xml"]] = None + """The content type header to set with the error response.""" + + status_code: Optional[int] = None + """The status code to use for the error.""" + + +ActionParameters: TypeAlias = Union[ActionParametersActionParametersContent, ActionParametersActionParametersAsset] + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ServeErrorRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/serve_error_rule_param.py b/src/cloudflare/types/rulesets/serve_error_rule_param.py new file mode 100644 index 00000000000..95bfb90f76e --- /dev/null +++ b/src/cloudflare/types/rulesets/serve_error_rule_param.py @@ -0,0 +1,131 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Literal, Required, TypeAlias, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = [ + "ServeErrorRuleParam", + "ActionParameters", + "ActionParametersActionParametersContent", + "ActionParametersActionParametersAsset", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersActionParametersContent(TypedDict, total=False): + content: Required[str] + """The response content.""" + + content_type: Literal["application/json", "text/html", "text/plain", "text/xml"] + """The content type header to set with the error response.""" + + status_code: int + """The status code to use for the error.""" + + +class ActionParametersActionParametersAsset(TypedDict, total=False): + asset_name: Required[str] + """The name of a custom asset to serve as the error response.""" + + content_type: Literal["application/json", "text/html", "text/plain", "text/xml"] + """The content type header to set with the error response.""" + + status_code: int + """The status code to use for the error.""" + + +ActionParameters: TypeAlias = Union[ActionParametersActionParametersContent, ActionParametersActionParametersAsset] + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class ServeErrorRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["serve_error"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/set_cache_settings_rule.py b/src/cloudflare/types/rulesets/set_cache_settings_rule.py new file mode 100644 index 00000000000..8b1f40e5af7 --- /dev/null +++ b/src/cloudflare/types/rulesets/set_cache_settings_rule.py @@ -0,0 +1,426 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .logging import Logging +from ..._models import BaseModel + +__all__ = [ + "SetCacheSettingsRule", + "ActionParameters", + "ActionParametersBrowserTTL", + "ActionParametersCacheKey", + "ActionParametersCacheKeyCustomKey", + "ActionParametersCacheKeyCustomKeyCookie", + "ActionParametersCacheKeyCustomKeyHeader", + "ActionParametersCacheKeyCustomKeyHost", + "ActionParametersCacheKeyCustomKeyQueryString", + "ActionParametersCacheKeyCustomKeyQueryStringExclude", + "ActionParametersCacheKeyCustomKeyQueryStringInclude", + "ActionParametersCacheKeyCustomKeyUser", + "ActionParametersCacheReserve", + "ActionParametersEdgeTTL", + "ActionParametersEdgeTTLStatusCodeTTL", + "ActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "ActionParametersServeStale", + "ActionParametersSharedDictionary", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersBrowserTTL(BaseModel): + """How long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high browser TTLs may lead to stale content. + """ + + mode: Literal["respect_origin", "bypass_by_default", "override_origin", "bypass"] + """The browser TTL mode.""" + + default: Optional[int] = None + """The browser TTL (in seconds) if you choose the "override_origin" mode.""" + + +class ActionParametersCacheKeyCustomKeyCookie(BaseModel): + """Which cookies to include in the cache key.""" + + check_presence: Optional[List[str]] = None + """A list of cookies to check for the presence of. + + The presence of these cookies is included in the cache key. + """ + + include: Optional[List[str]] = None + """A list of cookies to include in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyHeader(BaseModel): + """Which headers to include in the cache key.""" + + check_presence: Optional[List[str]] = None + """A list of headers to check for the presence of. + + The presence of these headers is included in the cache key. + """ + + contains: Optional[Dict[str, List[str]]] = None + """A mapping of header names to a list of values. + + If a header is present in the request and contains any of the values provided, + its value is included in the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether to exclude the origin header in the cache key.""" + + include: Optional[List[str]] = None + """A list of headers to include in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyHost(BaseModel): + """How to use the host in the cache key.""" + + resolved: Optional[bool] = None + """Whether to use the resolved host in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + """Which query string parameters to exclude from the cache key.""" + + all: Optional[Literal[True]] = None + """Whether to exclude all query string parameters from the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters to exclude from the cache key.""" + + +class ActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + """Which query string parameters to include in the cache key.""" + + all: Optional[Literal[True]] = None + """Whether to include all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters to include in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyQueryString(BaseModel): + """Which query string parameters to include in or exclude from the cache key.""" + + exclude: Optional[ActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """Which query string parameters to exclude from the cache key.""" + + include: Optional[ActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """Which query string parameters to include in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyUser(BaseModel): + """How to use characteristics of the request user agent in the cache key.""" + + device_type: Optional[bool] = None + """Whether to use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Whether to use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Whether to use the user agent's language in the cache key.""" + + +class ActionParametersCacheKeyCustomKey(BaseModel): + """Which components of the request are included or excluded from the cache key.""" + + cookie: Optional[ActionParametersCacheKeyCustomKeyCookie] = None + """Which cookies to include in the cache key.""" + + header: Optional[ActionParametersCacheKeyCustomKeyHeader] = None + """Which headers to include in the cache key.""" + + host: Optional[ActionParametersCacheKeyCustomKeyHost] = None + """How to use the host in the cache key.""" + + query_string: Optional[ActionParametersCacheKeyCustomKeyQueryString] = None + """Which query string parameters to include in or exclude from the cache key.""" + + user: Optional[ActionParametersCacheKeyCustomKeyUser] = None + """How to use characteristics of the request user agent in the cache key.""" + + +class ActionParametersCacheKey(BaseModel): + """ + Which components of the request are included in or excluded from the cache key Cloudflare uses to store the response in cache. + """ + + cache_by_device_type: Optional[bool] = None + """Whether to separate cached content based on the visitor's device type.""" + + cache_deception_armor: Optional[bool] = None + """ + Whether to protect from web cache deception attacks, while allowing static + assets to be cached. + """ + + custom_key: Optional[ActionParametersCacheKeyCustomKey] = None + """Which components of the request are included or excluded from the cache key.""" + + ignore_query_strings_order: Optional[bool] = None + """ + Whether to treat requests with the same query parameters the same, regardless of + the order those query parameters are in. + """ + + +class ActionParametersCacheReserve(BaseModel): + """ + Settings to determine whether the request's response from origin is eligible for Cache Reserve (requires a Cache Reserve add-on plan). + """ + + eligible: bool + """Whether Cache Reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to Cache Reserve. + """ + + minimum_file_size: Optional[int] = None + """The minimum file size eligible for storage in Cache Reserve.""" + + +class ActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + """A range of status codes to apply the TTL to.""" + + from_: Optional[int] = FieldInfo(alias="from", default=None) + """The lower bound of the range.""" + + to: Optional[int] = None + """The upper bound of the range.""" + + +class ActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """The time to cache the response for (in seconds). + + A value of 0 is equivalent to setting the cache control header with the value + "no-cache". A value of -1 is equivalent to setting the cache control header with + the value of "no-store". + """ + + status_code: Optional[int] = None + """A single status code to apply the TTL to.""" + + status_code_range: Optional[ActionParametersEdgeTTLStatusCodeTTLStatusCodeRange] = None + """A range of status codes to apply the TTL to.""" + + +class ActionParametersEdgeTTL(BaseModel): + """How long the Cloudflare edge network should cache the response.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """The edge TTL mode.""" + + default: Optional[int] = None + """The edge TTL (in seconds) if you choose the "override_origin" mode.""" + + status_code_ttl: Optional[List[ActionParametersEdgeTTLStatusCodeTTL]] = None + """A list of TTLs to apply to specific status codes or status code ranges.""" + + +class ActionParametersServeStale(BaseModel): + """When to serve stale content from cache.""" + + disable_stale_while_updating: Optional[bool] = None + """ + Whether Cloudflare should disable serving stale content while getting the latest + content from the origin. + """ + + +class ActionParametersSharedDictionary(BaseModel): + """Configuration for shared dictionary compression. + + When set, Cloudflare injects Use-As-Dictionary headers on matching cacheable responses. + """ + + match_pattern: str + """URL pattern for the Use-As-Dictionary match field. + + This pattern specifies which URLs can use this response as a dictionary. + """ + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + additional_cacheable_ports: Optional[List[int]] = None + """A list of additional ports that caching should be enabled on.""" + + browser_ttl: Optional[ActionParametersBrowserTTL] = None + """How long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Whether the request's response from the origin is eligible for caching. + + Caching itself will still depend on the cache control header and your other + caching configurations. + """ + + cache_key: Optional[ActionParametersCacheKey] = None + """ + Which components of the request are included in or excluded from the cache key + Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[ActionParametersCacheReserve] = None + """ + Settings to determine whether the request's response from origin is eligible for + Cache Reserve (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[ActionParametersEdgeTTL] = None + """How long the Cloudflare edge network should cache the response.""" + + origin_cache_control: Optional[bool] = None + """Whether Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Whether to generate Cloudflare error pages for issues from the origin server.""" + + read_timeout: Optional[int] = None + """ + A timeout value between two successive read operations to use for your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """Whether Cloudflare should respect strong ETag (entity tag) headers. + + If false, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[ActionParametersServeStale] = None + """When to serve stale content from cache.""" + + shared_dictionary: Optional[ActionParametersSharedDictionary] = None + """Configuration for shared dictionary compression. + + When set, Cloudflare injects Use-As-Dictionary headers on matching cacheable + responses. + """ + + strip_etags: Optional[bool] = None + """Whether to strip ETag headers from the origin response before caching.""" + + strip_last_modified: Optional[bool] = None + """Whether to strip Last-Modified headers from the origin response before caching.""" + + strip_set_cookie: Optional[bool] = None + """Whether to strip Set-Cookie headers from the origin response before caching.""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetCacheSettingsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/set_cache_settings_rule_param.py b/src/cloudflare/types/rulesets/set_cache_settings_rule_param.py new file mode 100644 index 00000000000..b223d45297d --- /dev/null +++ b/src/cloudflare/types/rulesets/set_cache_settings_rule_param.py @@ -0,0 +1,424 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Iterable +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = [ + "SetCacheSettingsRuleParam", + "ActionParameters", + "ActionParametersBrowserTTL", + "ActionParametersCacheKey", + "ActionParametersCacheKeyCustomKey", + "ActionParametersCacheKeyCustomKeyCookie", + "ActionParametersCacheKeyCustomKeyHeader", + "ActionParametersCacheKeyCustomKeyHost", + "ActionParametersCacheKeyCustomKeyQueryString", + "ActionParametersCacheKeyCustomKeyQueryStringExclude", + "ActionParametersCacheKeyCustomKeyQueryStringInclude", + "ActionParametersCacheKeyCustomKeyUser", + "ActionParametersCacheReserve", + "ActionParametersEdgeTTL", + "ActionParametersEdgeTTLStatusCodeTTL", + "ActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "ActionParametersServeStale", + "ActionParametersSharedDictionary", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersBrowserTTL(TypedDict, total=False): + """How long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high browser TTLs may lead to stale content. + """ + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin", "bypass"]] + """The browser TTL mode.""" + + default: int + """The browser TTL (in seconds) if you choose the "override_origin" mode.""" + + +class ActionParametersCacheKeyCustomKeyCookie(TypedDict, total=False): + """Which cookies to include in the cache key.""" + + check_presence: SequenceNotStr[str] + """A list of cookies to check for the presence of. + + The presence of these cookies is included in the cache key. + """ + + include: SequenceNotStr[str] + """A list of cookies to include in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyHeader(TypedDict, total=False): + """Which headers to include in the cache key.""" + + check_presence: SequenceNotStr[str] + """A list of headers to check for the presence of. + + The presence of these headers is included in the cache key. + """ + + contains: Dict[str, SequenceNotStr[str]] + """A mapping of header names to a list of values. + + If a header is present in the request and contains any of the values provided, + its value is included in the cache key. + """ + + exclude_origin: bool + """Whether to exclude the origin header in the cache key.""" + + include: SequenceNotStr[str] + """A list of headers to include in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyHost(TypedDict, total=False): + """How to use the host in the cache key.""" + + resolved: bool + """Whether to use the resolved host in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyQueryStringExclude(TypedDict, total=False): + """Which query string parameters to exclude from the cache key.""" + + all: Literal[True] + """Whether to exclude all query string parameters from the cache key.""" + + list: SequenceNotStr[str] + """A list of query string parameters to exclude from the cache key.""" + + +class ActionParametersCacheKeyCustomKeyQueryStringInclude(TypedDict, total=False): + """Which query string parameters to include in the cache key.""" + + all: Literal[True] + """Whether to include all query string parameters in the cache key.""" + + list: SequenceNotStr[str] + """A list of query string parameters to include in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyQueryString(TypedDict, total=False): + """Which query string parameters to include in or exclude from the cache key.""" + + exclude: ActionParametersCacheKeyCustomKeyQueryStringExclude + """Which query string parameters to exclude from the cache key.""" + + include: ActionParametersCacheKeyCustomKeyQueryStringInclude + """Which query string parameters to include in the cache key.""" + + +class ActionParametersCacheKeyCustomKeyUser(TypedDict, total=False): + """How to use characteristics of the request user agent in the cache key.""" + + device_type: bool + """Whether to use the user agent's device type in the cache key.""" + + geo: bool + """Whether to use the user agents's country in the cache key.""" + + lang: bool + """Whether to use the user agent's language in the cache key.""" + + +class ActionParametersCacheKeyCustomKey(TypedDict, total=False): + """Which components of the request are included or excluded from the cache key.""" + + cookie: ActionParametersCacheKeyCustomKeyCookie + """Which cookies to include in the cache key.""" + + header: ActionParametersCacheKeyCustomKeyHeader + """Which headers to include in the cache key.""" + + host: ActionParametersCacheKeyCustomKeyHost + """How to use the host in the cache key.""" + + query_string: ActionParametersCacheKeyCustomKeyQueryString + """Which query string parameters to include in or exclude from the cache key.""" + + user: ActionParametersCacheKeyCustomKeyUser + """How to use characteristics of the request user agent in the cache key.""" + + +class ActionParametersCacheKey(TypedDict, total=False): + """ + Which components of the request are included in or excluded from the cache key Cloudflare uses to store the response in cache. + """ + + cache_by_device_type: bool + """Whether to separate cached content based on the visitor's device type.""" + + cache_deception_armor: bool + """ + Whether to protect from web cache deception attacks, while allowing static + assets to be cached. + """ + + custom_key: ActionParametersCacheKeyCustomKey + """Which components of the request are included or excluded from the cache key.""" + + ignore_query_strings_order: bool + """ + Whether to treat requests with the same query parameters the same, regardless of + the order those query parameters are in. + """ + + +class ActionParametersCacheReserve(TypedDict, total=False): + """ + Settings to determine whether the request's response from origin is eligible for Cache Reserve (requires a Cache Reserve add-on plan). + """ + + eligible: Required[bool] + """Whether Cache Reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to Cache Reserve. + """ + + minimum_file_size: int + """The minimum file size eligible for storage in Cache Reserve.""" + + +_ActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords = TypedDict( + "_ActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords", + { + "from": int, + }, + total=False, +) + + +class ActionParametersEdgeTTLStatusCodeTTLStatusCodeRange( + _ActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords, total=False +): + """A range of status codes to apply the TTL to.""" + + to: int + """The upper bound of the range.""" + + +class ActionParametersEdgeTTLStatusCodeTTL(TypedDict, total=False): + value: Required[int] + """The time to cache the response for (in seconds). + + A value of 0 is equivalent to setting the cache control header with the value + "no-cache". A value of -1 is equivalent to setting the cache control header with + the value of "no-store". + """ + + status_code: int + """A single status code to apply the TTL to.""" + + status_code_range: ActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + """A range of status codes to apply the TTL to.""" + + +class ActionParametersEdgeTTL(TypedDict, total=False): + """How long the Cloudflare edge network should cache the response.""" + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """The edge TTL mode.""" + + default: int + """The edge TTL (in seconds) if you choose the "override_origin" mode.""" + + status_code_ttl: Iterable[ActionParametersEdgeTTLStatusCodeTTL] + """A list of TTLs to apply to specific status codes or status code ranges.""" + + +class ActionParametersServeStale(TypedDict, total=False): + """When to serve stale content from cache.""" + + disable_stale_while_updating: bool + """ + Whether Cloudflare should disable serving stale content while getting the latest + content from the origin. + """ + + +class ActionParametersSharedDictionary(TypedDict, total=False): + """Configuration for shared dictionary compression. + + When set, Cloudflare injects Use-As-Dictionary headers on matching cacheable responses. + """ + + match_pattern: Required[str] + """URL pattern for the Use-As-Dictionary match field. + + This pattern specifies which URLs can use this response as a dictionary. + """ + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + additional_cacheable_ports: Iterable[int] + """A list of additional ports that caching should be enabled on.""" + + browser_ttl: ActionParametersBrowserTTL + """How long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: bool + """Whether the request's response from the origin is eligible for caching. + + Caching itself will still depend on the cache control header and your other + caching configurations. + """ + + cache_key: ActionParametersCacheKey + """ + Which components of the request are included in or excluded from the cache key + Cloudflare uses to store the response in cache. + """ + + cache_reserve: ActionParametersCacheReserve + """ + Settings to determine whether the request's response from origin is eligible for + Cache Reserve (requires a Cache Reserve add-on plan). + """ + + edge_ttl: ActionParametersEdgeTTL + """How long the Cloudflare edge network should cache the response.""" + + origin_cache_control: bool + """Whether Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: bool + """Whether to generate Cloudflare error pages for issues from the origin server.""" + + read_timeout: int + """ + A timeout value between two successive read operations to use for your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: bool + """Whether Cloudflare should respect strong ETag (entity tag) headers. + + If false, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: ActionParametersServeStale + """When to serve stale content from cache.""" + + shared_dictionary: ActionParametersSharedDictionary + """Configuration for shared dictionary compression. + + When set, Cloudflare injects Use-As-Dictionary headers on matching cacheable + responses. + """ + + strip_etags: bool + """Whether to strip ETag headers from the origin response before caching.""" + + strip_last_modified: bool + """Whether to strip Last-Modified headers from the origin response before caching.""" + + strip_set_cookie: bool + """Whether to strip Set-Cookie headers from the origin response before caching.""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetCacheSettingsRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_settings"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/set_config_rule.py b/src/cloudflare/types/rulesets/set_config_rule.py new file mode 100644 index 00000000000..f05f3e45ea4 --- /dev/null +++ b/src/cloudflare/types/rulesets/set_config_rule.py @@ -0,0 +1,193 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .logging import Logging +from ..._models import BaseModel + +__all__ = ["SetConfigRule", "ActionParameters", "ActionParametersAutominify", "ExposedCredentialCheck", "Ratelimit"] + + +class ActionParametersAutominify(BaseModel): + """Which file extensions to minify automatically.""" + + css: Optional[bool] = None + """Whether to minify CSS files.""" + + html: Optional[bool] = None + """Whether to minify HTML files.""" + + js: Optional[bool] = None + """Whether to minify JavaScript files.""" + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + automatic_https_rewrites: Optional[bool] = None + """Whether to enable Automatic HTTPS Rewrites.""" + + autominify: Optional[ActionParametersAutominify] = None + """Which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Whether to enable Browser Integrity Check (BIC).""" + + content_converter: Optional[bool] = None + """Whether to enable content conversion (e.g., HTML to Markdown).""" + + disable_apps: Optional[Literal[True]] = None + """Whether to disable Cloudflare Apps.""" + + disable_pay_per_crawl: Optional[Literal[True]] = None + """Whether to disable Pay Per Crawl.""" + + disable_rum: Optional[Literal[True]] = None + """Whether to disable Real User Monitoring (RUM).""" + + disable_zaraz: Optional[Literal[True]] = None + """Whether to disable Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Whether to enable Email Obfuscation.""" + + fonts: Optional[bool] = None + """Whether to enable Cloudflare Fonts.""" + + hotlink_protection: Optional[bool] = None + """Whether to enable Hotlink Protection.""" + + mirage: Optional[bool] = None + """Whether to enable Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Whether to enable Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy", "webp"]] = None + """The Polish level to configure.""" + + redirects_for_ai_training: Optional[bool] = None + """ + Whether to redirect verified AI training crawlers to canonical URLs found in the + HTML response. + """ + + request_body_buffering: Optional[Literal["none", "standard", "full"]] = None + """The request body buffering mode.""" + + response_body_buffering: Optional[Literal["none", "standard"]] = None + """The response body buffering mode.""" + + rocket_loader: Optional[bool] = None + """Whether to enable Rocket Loader.""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """The Security Level to configure.""" + + server_side_excludes: Optional[bool] = None + """Whether to enable Server-Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """The SSL level to configure.""" + + sxg: Optional[bool] = None + """Whether to enable Signed Exchanges (SXG).""" + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetConfigRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/set_config_rule_param.py b/src/cloudflare/types/rulesets/set_config_rule_param.py new file mode 100644 index 00000000000..ce8fb45dc88 --- /dev/null +++ b/src/cloudflare/types/rulesets/set_config_rule_param.py @@ -0,0 +1,190 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = [ + "SetConfigRuleParam", + "ActionParameters", + "ActionParametersAutominify", + "ExposedCredentialCheck", + "Ratelimit", +] + + +class ActionParametersAutominify(TypedDict, total=False): + """Which file extensions to minify automatically.""" + + css: bool + """Whether to minify CSS files.""" + + html: bool + """Whether to minify HTML files.""" + + js: bool + """Whether to minify JavaScript files.""" + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + automatic_https_rewrites: bool + """Whether to enable Automatic HTTPS Rewrites.""" + + autominify: ActionParametersAutominify + """Which file extensions to minify automatically.""" + + bic: bool + """Whether to enable Browser Integrity Check (BIC).""" + + content_converter: bool + """Whether to enable content conversion (e.g., HTML to Markdown).""" + + disable_apps: Literal[True] + """Whether to disable Cloudflare Apps.""" + + disable_pay_per_crawl: Literal[True] + """Whether to disable Pay Per Crawl.""" + + disable_rum: Literal[True] + """Whether to disable Real User Monitoring (RUM).""" + + disable_zaraz: Literal[True] + """Whether to disable Zaraz.""" + + email_obfuscation: bool + """Whether to enable Email Obfuscation.""" + + fonts: bool + """Whether to enable Cloudflare Fonts.""" + + hotlink_protection: bool + """Whether to enable Hotlink Protection.""" + + mirage: bool + """Whether to enable Mirage.""" + + opportunistic_encryption: bool + """Whether to enable Opportunistic Encryption.""" + + polish: Literal["off", "lossless", "lossy", "webp"] + """The Polish level to configure.""" + + redirects_for_ai_training: bool + """ + Whether to redirect verified AI training crawlers to canonical URLs found in the + HTML response. + """ + + request_body_buffering: Literal["none", "standard", "full"] + """The request body buffering mode.""" + + response_body_buffering: Literal["none", "standard"] + """The response body buffering mode.""" + + rocket_loader: bool + """Whether to enable Rocket Loader.""" + + security_level: Literal["off", "essentially_off", "low", "medium", "high", "under_attack"] + """The Security Level to configure.""" + + server_side_excludes: bool + """Whether to enable Server-Side Excludes.""" + + ssl: Literal["off", "flexible", "full", "strict", "origin_pull"] + """The SSL level to configure.""" + + sxg: bool + """Whether to enable Signed Exchanges (SXG).""" + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SetConfigRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_config"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/skip_rule.py b/src/cloudflare/types/rulesets/skip_rule.py new file mode 100644 index 00000000000..e329edcd197 --- /dev/null +++ b/src/cloudflare/types/rulesets/skip_rule.py @@ -0,0 +1,147 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .phase import Phase +from .logging import Logging +from ..._models import BaseModel + +__all__ = ["SkipRule", "ActionParameters", "ExposedCredentialCheck", "Ratelimit"] + + +class ActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + phase: Optional[Literal["current"]] = None + """A phase to skip the execution of. + + This option is only compatible with the products option. + """ + + phases: Optional[List[Phase]] = None + """A list of phases to skip the execution of. + + This option is incompatible with the rulesets option. + """ + + products: Optional[List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]]] = ( + None + ) + """A list of legacy security products to skip the execution of.""" + + rules: Optional[Dict[str, List[str]]] = None + """ + A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + execution of. This option is incompatible with the ruleset option. + """ + + ruleset: Optional[Literal["current"]] = None + """A ruleset to skip the execution of. + + This option is incompatible with the rulesets option. + """ + + rulesets: Optional[List[str]] = None + """A list of ruleset IDs to skip the execution of. + + This option is incompatible with the ruleset and phases options. + """ + + +class ExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SkipRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["skip"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[ExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[Ratelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/skip_rule_param.py b/src/cloudflare/types/rulesets/skip_rule_param.py new file mode 100644 index 00000000000..70c01e5febc --- /dev/null +++ b/src/cloudflare/types/rulesets/skip_rule_param.py @@ -0,0 +1,137 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List +from typing_extensions import Literal, Required, TypedDict + +from .phase import Phase +from ..._types import SequenceNotStr +from .logging_param import LoggingParam + +__all__ = ["SkipRuleParam", "ActionParameters", "ExposedCredentialCheck", "Ratelimit"] + + +class ActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + phase: Literal["current"] + """A phase to skip the execution of. + + This option is only compatible with the products option. + """ + + phases: List[Phase] + """A list of phases to skip the execution of. + + This option is incompatible with the rulesets option. + """ + + products: List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] + """A list of legacy security products to skip the execution of.""" + + rules: Dict[str, SequenceNotStr[str]] + """ + A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + execution of. This option is incompatible with the ruleset option. + """ + + ruleset: Literal["current"] + """A ruleset to skip the execution of. + + This option is incompatible with the rulesets option. + """ + + rulesets: SequenceNotStr[str] + """A list of ruleset IDs to skip the execution of. + + This option is incompatible with the ruleset and phases options. + """ + + +class ExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class Ratelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class SkipRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["skip"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: ExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: Ratelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py new file mode 100644 index 00000000000..ffa5b313a0b --- /dev/null +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -0,0 +1,1047 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal, Annotated, TypeAlias + +from pydantic import Field as FieldInfo + +from .kind import Kind +from .phase import Phase +from .logging import Logging +from ..._utils import PropertyInfo +from .log_rule import LogRule +from ..._models import BaseModel +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .route_rule import RouteRule +from .score_rule import ScoreRule +from .execute_rule import ExecuteRule +from .rewrite_rule import RewriteRule +from .redirect_rule import RedirectRule +from .set_config_rule import SetConfigRule +from .serve_error_rule import ServeErrorRule +from .ddos_dynamic_rule import DDoSDynamicRule +from .log_custom_field_rule import LogCustomFieldRule +from .compress_response_rule import CompressResponseRule +from .managed_challenge_rule import ManagedChallengeRule +from .set_cache_settings_rule import SetCacheSettingsRule +from .force_connection_close_rule import ForceConnectionCloseRule + +__all__ = [ + "VersionGetResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsChallengeRuleExposedCredentialCheck", + "RuleRulesetsChallengeRuleRatelimit", + "RuleRulesetsJSChallengeRule", + "RuleRulesetsJSChallengeRuleExposedCredentialCheck", + "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", +] + + +class RuleRulesetsChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsJSChallengeRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsJSChallengeRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsJSChallengeRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["js_challenge"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsJSChallengeRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsJSChallengeRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +Rule: TypeAlias = Annotated[ + Union[ + BlockRule, + RuleRulesetsChallengeRule, + CompressResponseRule, + DDoSDynamicRule, + ExecuteRule, + ForceConnectionCloseRule, + RuleRulesetsJSChallengeRule, + LogRule, + LogCustomFieldRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + RuleRulesetsSetCacheControlRule, + SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, + SetConfigRule, + SkipRule, + ], + PropertyInfo(discriminator="action"), +] + + +class VersionGetResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + rules: List[Rule] + """The list of rules in the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/version_list_response.py b/src/cloudflare/types/rulesets/version_list_response.py new file mode 100644 index 00000000000..48c9c312b83 --- /dev/null +++ b/src/cloudflare/types/rulesets/version_list_response.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from .kind import Kind +from .phase import Phase +from ..._models import BaseModel + +__all__ = ["VersionListResponse"] + + +class VersionListResponse(BaseModel): + """A ruleset object.""" + + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rum/rule_bulk_create_params.py b/src/cloudflare/types/rum/rule_bulk_create_params.py index 11ba2bfc19d..128c4b0b192 100644 --- a/src/cloudflare/types/rum/rule_bulk_create_params.py +++ b/src/cloudflare/types/rum/rule_bulk_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -11,7 +11,7 @@ class RuleBulkCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" delete_rules: SequenceNotStr[str] diff --git a/src/cloudflare/types/rum/rule_create_params.py b/src/cloudflare/types/rum/rule_create_params.py index 45bf57b63b4..808e47c419b 100644 --- a/src/cloudflare/types/rum/rule_create_params.py +++ b/src/cloudflare/types/rum/rule_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class RuleCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" host: str diff --git a/src/cloudflare/types/rum/rule_update_params.py b/src/cloudflare/types/rum/rule_update_params.py index cd16ad9cbc3..8210d8323ec 100644 --- a/src/cloudflare/types/rum/rule_update_params.py +++ b/src/cloudflare/types/rum/rule_update_params.py @@ -10,7 +10,7 @@ class RuleUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" ruleset_id: Required[str] diff --git a/src/cloudflare/types/rum/site_info_create_params.py b/src/cloudflare/types/rum/site_info_create_params.py index 1c5741fc7ba..3190ad86e70 100644 --- a/src/cloudflare/types/rum/site_info_create_params.py +++ b/src/cloudflare/types/rum/site_info_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SiteInfoCreateParams"] class SiteInfoCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" auto_install: bool diff --git a/src/cloudflare/types/rum/site_info_list_params.py b/src/cloudflare/types/rum/site_info_list_params.py index 5d20ee77a52..f24b9890d84 100644 --- a/src/cloudflare/types/rum/site_info_list_params.py +++ b/src/cloudflare/types/rum/site_info_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["SiteInfoListParams"] class SiteInfoListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" order_by: Literal["host", "created"] diff --git a/src/cloudflare/types/rum/site_info_update_params.py b/src/cloudflare/types/rum/site_info_update_params.py index 8c46b5e3cb7..57b6c97025f 100644 --- a/src/cloudflare/types/rum/site_info_update_params.py +++ b/src/cloudflare/types/rum/site_info_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SiteInfoUpdateParams"] class SiteInfoUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" auto_install: bool diff --git a/src/cloudflare/types/schema_validation/schema_create_params.py b/src/cloudflare/types/schema_validation/schema_create_params.py index 585316e7cf3..dc263454e79 100644 --- a/src/cloudflare/types/schema_validation/schema_create_params.py +++ b/src/cloudflare/types/schema_validation/schema_create_params.py @@ -8,7 +8,7 @@ class SchemaCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" kind: Required[Literal["openapi_v3"]] diff --git a/src/cloudflare/types/schema_validation/schema_edit_params.py b/src/cloudflare/types/schema_validation/schema_edit_params.py index 074e692fce5..2ac44efaed2 100644 --- a/src/cloudflare/types/schema_validation/schema_edit_params.py +++ b/src/cloudflare/types/schema_validation/schema_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SchemaEditParams"] class SchemaEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" validation_enabled: bool diff --git a/src/cloudflare/types/schema_validation/schema_get_params.py b/src/cloudflare/types/schema_validation/schema_get_params.py index 9da2522edf0..82baf45494a 100644 --- a/src/cloudflare/types/schema_validation/schema_get_params.py +++ b/src/cloudflare/types/schema_validation/schema_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SchemaGetParams"] class SchemaGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" omit_source: bool diff --git a/src/cloudflare/types/schema_validation/schema_list_params.py b/src/cloudflare/types/schema_validation/schema_list_params.py index c286bdd8a5b..e614641c742 100644 --- a/src/cloudflare/types/schema_validation/schema_list_params.py +++ b/src/cloudflare/types/schema_validation/schema_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SchemaListParams"] class SchemaListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" omit_source: bool diff --git a/src/cloudflare/types/schema_validation/setting_edit_params.py b/src/cloudflare/types/schema_validation/setting_edit_params.py index 81f3bd15537..e5d9194fb0c 100644 --- a/src/cloudflare/types/schema_validation/setting_edit_params.py +++ b/src/cloudflare/types/schema_validation/setting_edit_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["SettingEditParams"] class SettingEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" validation_default_mitigation_action: Literal["none", "log", "block"] diff --git a/src/cloudflare/types/schema_validation/setting_update_params.py b/src/cloudflare/types/schema_validation/setting_update_params.py index c6e641c373c..411ad5ac2dd 100644 --- a/src/cloudflare/types/schema_validation/setting_update_params.py +++ b/src/cloudflare/types/schema_validation/setting_update_params.py @@ -9,7 +9,7 @@ class SettingUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" validation_default_mitigation_action: Required[Literal["none", "log", "block"]] diff --git a/src/cloudflare/types/schema_validation/settings/operation_bulk_edit_params.py b/src/cloudflare/types/schema_validation/settings/operation_bulk_edit_params.py index d1ce1c2c929..e726438994f 100644 --- a/src/cloudflare/types/schema_validation/settings/operation_bulk_edit_params.py +++ b/src/cloudflare/types/schema_validation/settings/operation_bulk_edit_params.py @@ -9,7 +9,7 @@ class OperationBulkEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[Dict[str, Body]] diff --git a/src/cloudflare/types/schema_validation/settings/operation_list_params.py b/src/cloudflare/types/schema_validation/settings/operation_list_params.py index 79851b36335..a14797f5de2 100644 --- a/src/cloudflare/types/schema_validation/settings/operation_list_params.py +++ b/src/cloudflare/types/schema_validation/settings/operation_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["OperationListParams"] class OperationListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/schema_validation/settings/operation_update_params.py b/src/cloudflare/types/schema_validation/settings/operation_update_params.py index 34cd95b5fc1..15db268b3f0 100644 --- a/src/cloudflare/types/schema_validation/settings/operation_update_params.py +++ b/src/cloudflare/types/schema_validation/settings/operation_update_params.py @@ -9,7 +9,7 @@ class OperationUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" mitigation_action: Required[Optional[Literal["log", "block", "none"]]] diff --git a/src/cloudflare/types/secrets_store/store_create_params.py b/src/cloudflare/types/secrets_store/store_create_params.py index d359c3bbce9..788b3bbfb8a 100644 --- a/src/cloudflare/types/secrets_store/store_create_params.py +++ b/src/cloudflare/types/secrets_store/store_create_params.py @@ -8,7 +8,7 @@ class StoreCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" name: Required[str] diff --git a/src/cloudflare/types/secrets_store/store_list_params.py b/src/cloudflare/types/secrets_store/store_list_params.py index 19d56210b25..e3432db39ef 100644 --- a/src/cloudflare/types/secrets_store/store_list_params.py +++ b/src/cloudflare/types/secrets_store/store_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["StoreListParams"] class StoreListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/secrets_store/stores/secret_create_params.py b/src/cloudflare/types/secrets_store/stores/secret_create_params.py index be39d5aa745..db2fb7d6821 100644 --- a/src/cloudflare/types/secrets_store/stores/secret_create_params.py +++ b/src/cloudflare/types/secrets_store/stores/secret_create_params.py @@ -11,7 +11,7 @@ class SecretCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/secrets_store/stores/secret_duplicate_params.py b/src/cloudflare/types/secrets_store/stores/secret_duplicate_params.py index 73a262b30a7..1de2f598248 100644 --- a/src/cloudflare/types/secrets_store/stores/secret_duplicate_params.py +++ b/src/cloudflare/types/secrets_store/stores/secret_duplicate_params.py @@ -10,7 +10,7 @@ class SecretDuplicateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" store_id: Required[str] diff --git a/src/cloudflare/types/secrets_store/stores/secret_edit_params.py b/src/cloudflare/types/secrets_store/stores/secret_edit_params.py index 68fe083869e..ef19e79aa8e 100644 --- a/src/cloudflare/types/secrets_store/stores/secret_edit_params.py +++ b/src/cloudflare/types/secrets_store/stores/secret_edit_params.py @@ -10,7 +10,7 @@ class SecretEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" store_id: Required[str] diff --git a/src/cloudflare/types/secrets_store/stores/secret_list_params.py b/src/cloudflare/types/secrets_store/stores/secret_list_params.py index ad101503e83..5a76f649f9b 100644 --- a/src/cloudflare/types/secrets_store/stores/secret_list_params.py +++ b/src/cloudflare/types/secrets_store/stores/secret_list_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ...._types import SequenceNotStr @@ -11,7 +11,7 @@ class SecretListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/security_center/__init__.py b/src/cloudflare/types/security_center/__init__.py index f8ee8b14b1c..34e1627b271 100644 --- a/src/cloudflare/types/security_center/__init__.py +++ b/src/cloudflare/types/security_center/__init__.py @@ -1,3 +1,8 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .insight_list_params import InsightListParams as InsightListParams +from .insight_list_response import InsightListResponse as InsightListResponse +from .insight_dismiss_params import InsightDismissParams as InsightDismissParams +from .insight_dismiss_response import InsightDismissResponse as InsightDismissResponse diff --git a/src/cloudflare/types/security_center/insight_dismiss_params.py b/src/cloudflare/types/security_center/insight_dismiss_params.py new file mode 100644 index 00000000000..b4209f9bed2 --- /dev/null +++ b/src/cloudflare/types/security_center/insight_dismiss_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["InsightDismissParams"] + + +class InsightDismissParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + dismiss: bool diff --git a/src/cloudflare/types/security_center/insight_dismiss_response.py b/src/cloudflare/types/security_center/insight_dismiss_response.py new file mode 100644 index 00000000000..4d2beb819f9 --- /dev/null +++ b/src/cloudflare/types/security_center/insight_dismiss_response.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["InsightDismissResponse", "Error", "ErrorSource", "Message", "MessageSource"] + + +class ErrorSource(BaseModel): + pointer: Optional[str] = None + + +class Error(BaseModel): + code: int + + message: str + + documentation_url: Optional[str] = None + + source: Optional[ErrorSource] = None + + +class MessageSource(BaseModel): + pointer: Optional[str] = None + + +class Message(BaseModel): + code: int + + message: str + + documentation_url: Optional[str] = None + + source: Optional[MessageSource] = None + + +class InsightDismissResponse(BaseModel): + errors: List[Error] + + messages: List[Message] + + success: Literal[True] + """Whether the API call was successful.""" diff --git a/src/cloudflare/types/security_center/insight_list_params.py b/src/cloudflare/types/security_center/insight_list_params.py new file mode 100644 index 00000000000..82b4735f192 --- /dev/null +++ b/src/cloudflare/types/security_center/insight_list_params.py @@ -0,0 +1,49 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Annotated, TypedDict + +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo +from ..intel.attack_surface_report.issue_type import IssueType +from ..intel.attack_surface_report.severity_query_param import SeverityQueryParam + +__all__ = ["InsightListParams"] + + +class InsightListParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + dismissed: bool + + issue_class: SequenceNotStr[str] + + issue_class_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="issue_class~neq")] + + issue_type: List[IssueType] + + issue_type_neq: Annotated[List[IssueType], PropertyInfo(alias="issue_type~neq")] + + page: int + """Specifies the current page within paginated list of results.""" + + per_page: int + """Sets the number of results per page of results.""" + + product: SequenceNotStr[str] + + product_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="product~neq")] + + severity: List[SeverityQueryParam] + + severity_neq: Annotated[List[SeverityQueryParam], PropertyInfo(alias="severity~neq")] + + subject: SequenceNotStr[str] + + subject_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="subject~neq")] diff --git a/src/cloudflare/types/security_center/insight_list_response.py b/src/cloudflare/types/security_center/insight_list_response.py new file mode 100644 index 00000000000..bbe0b207151 --- /dev/null +++ b/src/cloudflare/types/security_center/insight_list_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel +from ..intel.attack_surface_report.issue_type import IssueType + +__all__ = ["InsightListResponse", "Issue", "IssuePayload"] + + +class IssuePayload(BaseModel): + detection_method: Optional[str] = None + """Describes the method used to detect insight.""" + + zone_tag: Optional[str] = None + + +class Issue(BaseModel): + id: Optional[str] = None + + dismissed: Optional[bool] = None + + has_extended_context: Optional[bool] = None + """ + Indicates whether the insight has a large payload that requires fetching via the + context endpoint. + """ + + issue_class: Optional[str] = None + + issue_type: Optional[IssueType] = None + + payload: Optional[IssuePayload] = None + + resolve_link: Optional[str] = None + + resolve_text: Optional[str] = None + + severity: Optional[Literal["Low", "Moderate", "Critical"]] = None + + since: Optional[datetime] = None + + status: Optional[Literal["active", "resolved"]] = None + """The current status of the insight.""" + + subject: Optional[str] = None + + timestamp: Optional[datetime] = None + + user_classification: Optional[Literal["false_positive", "accept_risk", "other"]] = None + """User-defined classification for the insight. + + Can be 'false_positive', 'accept_risk', 'other', or null. + """ + + +class InsightListResponse(BaseModel): + count: Optional[int] = None + """Indicates the total number of results.""" + + issues: Optional[List[Issue]] = None + + page: Optional[int] = None + """Specifies the current page within paginated list of results.""" + + per_page: Optional[int] = None + """Sets the number of results per page of results.""" diff --git a/src/cloudflare/types/security_center/insights/__init__.py b/src/cloudflare/types/security_center/insights/__init__.py index f8ee8b14b1c..adb9484cde5 100644 --- a/src/cloudflare/types/security_center/insights/__init__.py +++ b/src/cloudflare/types/security_center/insights/__init__.py @@ -1,3 +1,10 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .type_get_params import TypeGetParams as TypeGetParams +from .class_get_params import ClassGetParams as ClassGetParams +from .type_get_response import TypeGetResponse as TypeGetResponse +from .class_get_response import ClassGetResponse as ClassGetResponse +from .severity_get_params import SeverityGetParams as SeverityGetParams +from .severity_get_response import SeverityGetResponse as SeverityGetResponse diff --git a/src/cloudflare/types/security_center/insights/class_get_params.py b/src/cloudflare/types/security_center/insights/class_get_params.py new file mode 100644 index 00000000000..39065fc0b7f --- /dev/null +++ b/src/cloudflare/types/security_center/insights/class_get_params.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Annotated, TypedDict + +from ...._types import SequenceNotStr +from ...._utils import PropertyInfo +from ...intel.attack_surface_report.issue_type import IssueType +from ...intel.attack_surface_report.severity_query_param import SeverityQueryParam + +__all__ = ["ClassGetParams"] + + +class ClassGetParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + dismissed: bool + + issue_class: SequenceNotStr[str] + + issue_class_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="issue_class~neq")] + + issue_type: List[IssueType] + + issue_type_neq: Annotated[List[IssueType], PropertyInfo(alias="issue_type~neq")] + + product: SequenceNotStr[str] + + product_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="product~neq")] + + severity: List[SeverityQueryParam] + + severity_neq: Annotated[List[SeverityQueryParam], PropertyInfo(alias="severity~neq")] + + subject: SequenceNotStr[str] + + subject_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="subject~neq")] diff --git a/src/cloudflare/types/security_center/insights/class_get_response.py b/src/cloudflare/types/security_center/insights/class_get_response.py new file mode 100644 index 00000000000..b5c2898329f --- /dev/null +++ b/src/cloudflare/types/security_center/insights/class_get_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import TypeAlias + +from ...._models import BaseModel + +__all__ = ["ClassGetResponse", "ClassGetResponseItem"] + + +class ClassGetResponseItem(BaseModel): + count: Optional[int] = None + + value: Optional[str] = None + + +ClassGetResponse: TypeAlias = List[ClassGetResponseItem] diff --git a/src/cloudflare/types/security_center/insights/severity_get_params.py b/src/cloudflare/types/security_center/insights/severity_get_params.py new file mode 100644 index 00000000000..bc3796c0d6d --- /dev/null +++ b/src/cloudflare/types/security_center/insights/severity_get_params.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Annotated, TypedDict + +from ...._types import SequenceNotStr +from ...._utils import PropertyInfo +from ...intel.attack_surface_report.issue_type import IssueType +from ...intel.attack_surface_report.severity_query_param import SeverityQueryParam + +__all__ = ["SeverityGetParams"] + + +class SeverityGetParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + dismissed: bool + + issue_class: SequenceNotStr[str] + + issue_class_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="issue_class~neq")] + + issue_type: List[IssueType] + + issue_type_neq: Annotated[List[IssueType], PropertyInfo(alias="issue_type~neq")] + + product: SequenceNotStr[str] + + product_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="product~neq")] + + severity: List[SeverityQueryParam] + + severity_neq: Annotated[List[SeverityQueryParam], PropertyInfo(alias="severity~neq")] + + subject: SequenceNotStr[str] + + subject_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="subject~neq")] diff --git a/src/cloudflare/types/security_center/insights/severity_get_response.py b/src/cloudflare/types/security_center/insights/severity_get_response.py new file mode 100644 index 00000000000..a8148abb332 --- /dev/null +++ b/src/cloudflare/types/security_center/insights/severity_get_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import TypeAlias + +from ...._models import BaseModel + +__all__ = ["SeverityGetResponse", "SeverityGetResponseItem"] + + +class SeverityGetResponseItem(BaseModel): + count: Optional[int] = None + + value: Optional[str] = None + + +SeverityGetResponse: TypeAlias = List[SeverityGetResponseItem] diff --git a/src/cloudflare/types/security_center/insights/type_get_params.py b/src/cloudflare/types/security_center/insights/type_get_params.py new file mode 100644 index 00000000000..dd0853d0119 --- /dev/null +++ b/src/cloudflare/types/security_center/insights/type_get_params.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Annotated, TypedDict + +from ...._types import SequenceNotStr +from ...._utils import PropertyInfo +from ...intel.attack_surface_report.issue_type import IssueType +from ...intel.attack_surface_report.severity_query_param import SeverityQueryParam + +__all__ = ["TypeGetParams"] + + +class TypeGetParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + dismissed: bool + + issue_class: SequenceNotStr[str] + + issue_class_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="issue_class~neq")] + + issue_type: List[IssueType] + + issue_type_neq: Annotated[List[IssueType], PropertyInfo(alias="issue_type~neq")] + + product: SequenceNotStr[str] + + product_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="product~neq")] + + severity: List[SeverityQueryParam] + + severity_neq: Annotated[List[SeverityQueryParam], PropertyInfo(alias="severity~neq")] + + subject: SequenceNotStr[str] + + subject_neq: Annotated[SequenceNotStr[str], PropertyInfo(alias="subject~neq")] diff --git a/src/cloudflare/types/security_center/insights/type_get_response.py b/src/cloudflare/types/security_center/insights/type_get_response.py new file mode 100644 index 00000000000..eae4a597510 --- /dev/null +++ b/src/cloudflare/types/security_center/insights/type_get_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import TypeAlias + +from ...._models import BaseModel + +__all__ = ["TypeGetResponse", "TypeGetResponseItem"] + + +class TypeGetResponseItem(BaseModel): + count: Optional[int] = None + + value: Optional[str] = None + + +TypeGetResponse: TypeAlias = List[TypeGetResponseItem] diff --git a/src/cloudflare/types/security_txt/security_txt_update_params.py b/src/cloudflare/types/security_txt/security_txt_update_params.py index ccd935f7bed..e19e3c9b9c6 100644 --- a/src/cloudflare/types/security_txt/security_txt_update_params.py +++ b/src/cloudflare/types/security_txt/security_txt_update_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -13,7 +13,7 @@ class SecurityTXTUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" acknowledgments: SequenceNotStr[str] diff --git a/src/cloudflare/types/snippets/rule_update_params.py b/src/cloudflare/types/snippets/rule_update_params.py index 9511ef89cf8..688e9060cad 100644 --- a/src/cloudflare/types/snippets/rule_update_params.py +++ b/src/cloudflare/types/snippets/rule_update_params.py @@ -9,7 +9,7 @@ class RuleUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Use this field to specify the unique ID of the zone.""" rules: Required[Iterable[Rule]] diff --git a/src/cloudflare/types/snippets/snippet_list_params.py b/src/cloudflare/types/snippets/snippet_list_params.py index 6a88fa28753..20787161dbe 100644 --- a/src/cloudflare/types/snippets/snippet_list_params.py +++ b/src/cloudflare/types/snippets/snippet_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SnippetListParams"] class SnippetListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Use this field to specify the unique ID of the zone.""" page: int diff --git a/src/cloudflare/types/snippets/snippet_update_params.py b/src/cloudflare/types/snippets/snippet_update_params.py index 9018359d3cf..8085e6c686b 100644 --- a/src/cloudflare/types/snippets/snippet_update_params.py +++ b/src/cloudflare/types/snippets/snippet_update_params.py @@ -8,7 +8,7 @@ class SnippetUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Use this field to specify the unique ID of the zone.""" metadata: Required[Metadata] diff --git a/src/cloudflare/types/spectrum/analytics/aggregates/current_get_params.py b/src/cloudflare/types/spectrum/analytics/aggregates/current_get_params.py index 62e4567343d..021e3e02a38 100644 --- a/src/cloudflare/types/spectrum/analytics/aggregates/current_get_params.py +++ b/src/cloudflare/types/spectrum/analytics/aggregates/current_get_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ....._utils import PropertyInfo @@ -10,7 +10,7 @@ class CurrentGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" app_id: Annotated[str, PropertyInfo(alias="appID")] diff --git a/src/cloudflare/types/spectrum/analytics/events/bytime_get_params.py b/src/cloudflare/types/spectrum/analytics/events/bytime_get_params.py index d0093aefdcc..ff139691ebc 100644 --- a/src/cloudflare/types/spectrum/analytics/events/bytime_get_params.py +++ b/src/cloudflare/types/spectrum/analytics/events/bytime_get_params.py @@ -14,7 +14,7 @@ class BytimeGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" time_delta: Required[Literal["year", "quarter", "month", "week", "day", "hour", "dekaminute", "minute"]] diff --git a/src/cloudflare/types/spectrum/analytics/events/summary_get_params.py b/src/cloudflare/types/spectrum/analytics/events/summary_get_params.py index 49158c5ae50..73350abfd56 100644 --- a/src/cloudflare/types/spectrum/analytics/events/summary_get_params.py +++ b/src/cloudflare/types/spectrum/analytics/events/summary_get_params.py @@ -4,7 +4,7 @@ from typing import List, Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ....._types import SequenceNotStr from ....._utils import PropertyInfo @@ -14,7 +14,7 @@ class SummaryGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" dimensions: List[Dimension] diff --git a/src/cloudflare/types/spectrum/app_create_params.py b/src/cloudflare/types/spectrum/app_create_params.py index 8927bec1bf7..a42065dff51 100644 --- a/src/cloudflare/types/spectrum/app_create_params.py +++ b/src/cloudflare/types/spectrum/app_create_params.py @@ -15,7 +15,7 @@ class SpectrumConfigAppConfig(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Zone identifier.""" dns: Required[DNSParam] @@ -85,7 +85,7 @@ class SpectrumConfigAppConfig(TypedDict, total=False): class SpectrumConfigPaygoAppConfig(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Zone identifier.""" dns: Required[DNSParam] diff --git a/src/cloudflare/types/spectrum/app_list_params.py b/src/cloudflare/types/spectrum/app_list_params.py index 84e5876649c..bc2351bb116 100644 --- a/src/cloudflare/types/spectrum/app_list_params.py +++ b/src/cloudflare/types/spectrum/app_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["AppListParams"] class AppListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Zone identifier.""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/spectrum/app_update_params.py b/src/cloudflare/types/spectrum/app_update_params.py index 1c51cd912d6..03df27f5a7b 100644 --- a/src/cloudflare/types/spectrum/app_update_params.py +++ b/src/cloudflare/types/spectrum/app_update_params.py @@ -15,7 +15,7 @@ class SpectrumConfigAppConfig(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Zone identifier.""" dns: Required[DNSParam] @@ -85,7 +85,7 @@ class SpectrumConfigAppConfig(TypedDict, total=False): class SpectrumConfigPaygoAppConfig(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Zone identifier.""" dns: Required[DNSParam] diff --git a/src/cloudflare/types/speed/page_trend_params.py b/src/cloudflare/types/speed/page_trend_params.py index b459824cc20..eb7af0dae85 100644 --- a/src/cloudflare/types/speed/page_trend_params.py +++ b/src/cloudflare/types/speed/page_trend_params.py @@ -12,7 +12,7 @@ class PageTrendParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" device_type: Required[Annotated[Literal["DESKTOP", "MOBILE"], PropertyInfo(alias="deviceType")]] diff --git a/src/cloudflare/types/speed/pages/test_create_params.py b/src/cloudflare/types/speed/pages/test_create_params.py index 59d1d27a61c..1e58d3584c2 100644 --- a/src/cloudflare/types/speed/pages/test_create_params.py +++ b/src/cloudflare/types/speed/pages/test_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["TestCreateParams"] class TestCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" region: Literal[ diff --git a/src/cloudflare/types/speed/pages/test_delete_params.py b/src/cloudflare/types/speed/pages/test_delete_params.py index 7481c7403dd..623ed819fe8 100644 --- a/src/cloudflare/types/speed/pages/test_delete_params.py +++ b/src/cloudflare/types/speed/pages/test_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["TestDeleteParams"] class TestDeleteParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" region: Literal[ diff --git a/src/cloudflare/types/speed/pages/test_list_params.py b/src/cloudflare/types/speed/pages/test_list_params.py index d6dc3167860..3c52d99aacd 100644 --- a/src/cloudflare/types/speed/pages/test_list_params.py +++ b/src/cloudflare/types/speed/pages/test_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["TestListParams"] class TestListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/speed/schedule_create_params.py b/src/cloudflare/types/speed/schedule_create_params.py index c36a7880435..6832034e574 100644 --- a/src/cloudflare/types/speed/schedule_create_params.py +++ b/src/cloudflare/types/speed/schedule_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ScheduleCreateParams"] class ScheduleCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" frequency: Literal["DAILY", "WEEKLY"] diff --git a/src/cloudflare/types/speed/schedule_delete_params.py b/src/cloudflare/types/speed/schedule_delete_params.py index 3248601fc2a..d374e0bf6fd 100644 --- a/src/cloudflare/types/speed/schedule_delete_params.py +++ b/src/cloudflare/types/speed/schedule_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ScheduleDeleteParams"] class ScheduleDeleteParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" region: Literal[ diff --git a/src/cloudflare/types/speed/schedule_get_params.py b/src/cloudflare/types/speed/schedule_get_params.py index 7f3e96ab293..3f16df160c8 100644 --- a/src/cloudflare/types/speed/schedule_get_params.py +++ b/src/cloudflare/types/speed/schedule_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ScheduleGetParams"] class ScheduleGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" region: Literal[ diff --git a/src/cloudflare/types/ssl/analyze_create_params.py b/src/cloudflare/types/ssl/analyze_create_params.py index cc33f00c9cc..11de0c66c56 100644 --- a/src/cloudflare/types/ssl/analyze_create_params.py +++ b/src/cloudflare/types/ssl/analyze_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..custom_hostnames.bundle_method import BundleMethod @@ -10,7 +10,7 @@ class AnalyzeCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" bundle_method: BundleMethod diff --git a/src/cloudflare/types/ssl/certificate_pack_create_params.py b/src/cloudflare/types/ssl/certificate_pack_create_params.py index 1b52c52d05f..3b1791f4736 100644 --- a/src/cloudflare/types/ssl/certificate_pack_create_params.py +++ b/src/cloudflare/types/ssl/certificate_pack_create_params.py @@ -11,7 +11,7 @@ class CertificatePackCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" certificate_authority: Required[Literal["google", "lets_encrypt", "ssl_com"]] diff --git a/src/cloudflare/types/ssl/certificate_pack_edit_params.py b/src/cloudflare/types/ssl/certificate_pack_edit_params.py index ac1eb503f9b..20e36feddf8 100644 --- a/src/cloudflare/types/ssl/certificate_pack_edit_params.py +++ b/src/cloudflare/types/ssl/certificate_pack_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CertificatePackEditParams"] class CertificatePackEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" cloudflare_branding: bool diff --git a/src/cloudflare/types/ssl/certificate_pack_list_params.py b/src/cloudflare/types/ssl/certificate_pack_list_params.py index b231888d073..0831fdd669e 100644 --- a/src/cloudflare/types/ssl/certificate_pack_list_params.py +++ b/src/cloudflare/types/ssl/certificate_pack_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["CertificatePackListParams"] class CertificatePackListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" deploy: Literal["staging", "production"] diff --git a/src/cloudflare/types/ssl/universal/setting_edit_params.py b/src/cloudflare/types/ssl/universal/setting_edit_params.py index e7e19a63085..73949043af8 100644 --- a/src/cloudflare/types/ssl/universal/setting_edit_params.py +++ b/src/cloudflare/types/ssl/universal/setting_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SettingEditParams"] class SettingEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" enabled: bool diff --git a/src/cloudflare/types/ssl/verification_edit_params.py b/src/cloudflare/types/ssl/verification_edit_params.py index 2ec2389f68b..f02c342e438 100644 --- a/src/cloudflare/types/ssl/verification_edit_params.py +++ b/src/cloudflare/types/ssl/verification_edit_params.py @@ -8,7 +8,7 @@ class VerificationEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" validation_method: Required[Literal["http", "cname", "txt", "email"]] diff --git a/src/cloudflare/types/ssl/verification_get_params.py b/src/cloudflare/types/ssl/verification_get_params.py index 1f33b183f83..6560cb3856b 100644 --- a/src/cloudflare/types/ssl/verification_get_params.py +++ b/src/cloudflare/types/ssl/verification_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["VerificationGetParams"] class VerificationGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" retry: Literal[True] diff --git a/src/cloudflare/types/stream/audio_track_copy_params.py b/src/cloudflare/types/stream/audio_track_copy_params.py index 599c1adb399..1d5c48c729d 100644 --- a/src/cloudflare/types/stream/audio_track_copy_params.py +++ b/src/cloudflare/types/stream/audio_track_copy_params.py @@ -8,7 +8,7 @@ class AudioTrackCopyParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" label: Required[str] diff --git a/src/cloudflare/types/stream/audio_track_edit_params.py b/src/cloudflare/types/stream/audio_track_edit_params.py index 6463f48b26b..7d851b826ea 100644 --- a/src/cloudflare/types/stream/audio_track_edit_params.py +++ b/src/cloudflare/types/stream/audio_track_edit_params.py @@ -8,7 +8,7 @@ class AudioTrackEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" identifier: Required[str] diff --git a/src/cloudflare/types/stream/captions/language_update_params.py b/src/cloudflare/types/stream/captions/language_update_params.py index 5c9b702792b..e528e05fde1 100644 --- a/src/cloudflare/types/stream/captions/language_update_params.py +++ b/src/cloudflare/types/stream/captions/language_update_params.py @@ -8,7 +8,7 @@ class LanguageUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" identifier: Required[str] diff --git a/src/cloudflare/types/stream/clip_create_params.py b/src/cloudflare/types/stream/clip_create_params.py index e04adad50aa..09a20b0f232 100644 --- a/src/cloudflare/types/stream/clip_create_params.py +++ b/src/cloudflare/types/stream/clip_create_params.py @@ -14,7 +14,7 @@ class ClipCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" clipped_from_video_uid: Required[Annotated[str, PropertyInfo(alias="clippedFromVideoUID")]] diff --git a/src/cloudflare/types/stream/copy_create_params.py b/src/cloudflare/types/stream/copy_create_params.py index 22f6bb86824..383d686c7bb 100644 --- a/src/cloudflare/types/stream/copy_create_params.py +++ b/src/cloudflare/types/stream/copy_create_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -14,7 +14,7 @@ class CopyCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" allowed_origins: Annotated[SequenceNotStr[AllowedOrigins], PropertyInfo(alias="allowedOrigins")] diff --git a/src/cloudflare/types/stream/direct_upload_create_params.py b/src/cloudflare/types/stream/direct_upload_create_params.py index 196794ac8cd..ada6e59930c 100644 --- a/src/cloudflare/types/stream/direct_upload_create_params.py +++ b/src/cloudflare/types/stream/direct_upload_create_params.py @@ -14,7 +14,7 @@ class DirectUploadCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" max_duration_seconds: Required[Annotated[int, PropertyInfo(alias="maxDurationSeconds")]] diff --git a/src/cloudflare/types/stream/key_create_params.py b/src/cloudflare/types/stream/key_create_params.py index 0e48b1613bb..968dcd2c885 100644 --- a/src/cloudflare/types/stream/key_create_params.py +++ b/src/cloudflare/types/stream/key_create_params.py @@ -8,7 +8,7 @@ class KeyCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" body: Required[object] diff --git a/src/cloudflare/types/stream/live_input_create_params.py b/src/cloudflare/types/stream/live_input_create_params.py index 63f6f095320..8bc7ae7fed0 100644 --- a/src/cloudflare/types/stream/live_input_create_params.py +++ b/src/cloudflare/types/stream/live_input_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -11,7 +11,7 @@ class LiveInputCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" default_creator: Annotated[str, PropertyInfo(alias="defaultCreator")] diff --git a/src/cloudflare/types/stream/live_input_list_params.py b/src/cloudflare/types/stream/live_input_list_params.py index 7daa7840150..9ea088d3803 100644 --- a/src/cloudflare/types/stream/live_input_list_params.py +++ b/src/cloudflare/types/stream/live_input_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["LiveInputListParams"] class LiveInputListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" include_counts: bool diff --git a/src/cloudflare/types/stream/live_input_update_params.py b/src/cloudflare/types/stream/live_input_update_params.py index 248048df5af..80dca8e1687 100644 --- a/src/cloudflare/types/stream/live_input_update_params.py +++ b/src/cloudflare/types/stream/live_input_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -11,7 +11,7 @@ class LiveInputUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" default_creator: Annotated[str, PropertyInfo(alias="defaultCreator")] diff --git a/src/cloudflare/types/stream/live_inputs/output_create_params.py b/src/cloudflare/types/stream/live_inputs/output_create_params.py index a07db015a54..d7088828a3a 100644 --- a/src/cloudflare/types/stream/live_inputs/output_create_params.py +++ b/src/cloudflare/types/stream/live_inputs/output_create_params.py @@ -10,7 +10,7 @@ class OutputCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" stream_key: Required[Annotated[str, PropertyInfo(alias="streamKey")]] diff --git a/src/cloudflare/types/stream/live_inputs/output_update_params.py b/src/cloudflare/types/stream/live_inputs/output_update_params.py index f364723888d..a5ed6b2b21b 100644 --- a/src/cloudflare/types/stream/live_inputs/output_update_params.py +++ b/src/cloudflare/types/stream/live_inputs/output_update_params.py @@ -8,7 +8,7 @@ class OutputUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" live_input_identifier: Required[str] diff --git a/src/cloudflare/types/stream/stream_create_params.py b/src/cloudflare/types/stream/stream_create_params.py index 38ee4f3f9db..3626fbfc2c7 100644 --- a/src/cloudflare/types/stream/stream_create_params.py +++ b/src/cloudflare/types/stream/stream_create_params.py @@ -10,7 +10,7 @@ class StreamCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" tus_resumable: Required[Annotated[Literal["1.0.0"], PropertyInfo(alias="Tus-Resumable")]] diff --git a/src/cloudflare/types/stream/stream_edit_params.py b/src/cloudflare/types/stream/stream_edit_params.py index 3ec2c2eecc3..1b50b4d05a0 100644 --- a/src/cloudflare/types/stream/stream_edit_params.py +++ b/src/cloudflare/types/stream/stream_edit_params.py @@ -4,7 +4,7 @@ from typing import Union, Optional from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -14,7 +14,7 @@ class StreamEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" allowed_origins: Annotated[SequenceNotStr[AllowedOrigins], PropertyInfo(alias="allowedOrigins")] diff --git a/src/cloudflare/types/stream/stream_list_params.py b/src/cloudflare/types/stream/stream_list_params.py index 7165c3d3dc4..badeea9782e 100644 --- a/src/cloudflare/types/stream/stream_list_params.py +++ b/src/cloudflare/types/stream/stream_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class StreamListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" id: str diff --git a/src/cloudflare/types/stream/token_create_params.py b/src/cloudflare/types/stream/token_create_params.py index 7ddc54cfbd8..bf97e9d4c63 100644 --- a/src/cloudflare/types/stream/token_create_params.py +++ b/src/cloudflare/types/stream/token_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._types import SequenceNotStr from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class TokenCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" id: str diff --git a/src/cloudflare/types/stream/video_storage_usage_params.py b/src/cloudflare/types/stream/video_storage_usage_params.py index a17cf902bbd..12651e39b27 100644 --- a/src/cloudflare/types/stream/video_storage_usage_params.py +++ b/src/cloudflare/types/stream/video_storage_usage_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["VideoStorageUsageParams"] class VideoStorageUsageParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" creator: str diff --git a/src/cloudflare/types/stream/watermark_create_params.py b/src/cloudflare/types/stream/watermark_create_params.py index 4fc7d2463fa..b7121cae71d 100644 --- a/src/cloudflare/types/stream/watermark_create_params.py +++ b/src/cloudflare/types/stream/watermark_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["WatermarkCreateParams"] class WatermarkCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" name: str diff --git a/src/cloudflare/types/stream/webhook_update_params.py b/src/cloudflare/types/stream/webhook_update_params.py index 65fd67b2670..1bc00b839b1 100644 --- a/src/cloudflare/types/stream/webhook_update_params.py +++ b/src/cloudflare/types/stream/webhook_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ..._utils import PropertyInfo @@ -10,7 +10,7 @@ class WebhookUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """The account identifier tag.""" body_notification_url_1: Annotated[str, PropertyInfo(alias="notification_url")] diff --git a/src/cloudflare/types/token_validation/configuration/credential_update_params.py b/src/cloudflare/types/token_validation/configuration/credential_update_params.py index 98896d37d1b..f74bfdcaa8c 100644 --- a/src/cloudflare/types/token_validation/configuration/credential_update_params.py +++ b/src/cloudflare/types/token_validation/configuration/credential_update_params.py @@ -15,7 +15,7 @@ class CredentialUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" keys: Required[Iterable[Key]] diff --git a/src/cloudflare/types/token_validation/configuration_create_params.py b/src/cloudflare/types/token_validation/configuration_create_params.py index e1dc1cbe588..4ba1be1bc62 100644 --- a/src/cloudflare/types/token_validation/configuration_create_params.py +++ b/src/cloudflare/types/token_validation/configuration_create_params.py @@ -18,7 +18,7 @@ class ConfigurationCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" credentials: Required[Credentials] diff --git a/src/cloudflare/types/token_validation/configuration_edit_params.py b/src/cloudflare/types/token_validation/configuration_edit_params.py index 8bfeca4a151..a702189c49e 100644 --- a/src/cloudflare/types/token_validation/configuration_edit_params.py +++ b/src/cloudflare/types/token_validation/configuration_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class ConfigurationEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" description: str diff --git a/src/cloudflare/types/token_validation/configuration_list_params.py b/src/cloudflare/types/token_validation/configuration_list_params.py index 5c5a00f5242..057a54d9d71 100644 --- a/src/cloudflare/types/token_validation/configuration_list_params.py +++ b/src/cloudflare/types/token_validation/configuration_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ConfigurationListParams"] class ConfigurationListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/token_validation/rule_bulk_create_params.py b/src/cloudflare/types/token_validation/rule_bulk_create_params.py index 36b178812c9..f16862236ca 100644 --- a/src/cloudflare/types/token_validation/rule_bulk_create_params.py +++ b/src/cloudflare/types/token_validation/rule_bulk_create_params.py @@ -11,7 +11,7 @@ class RuleBulkCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/token_validation/rule_bulk_edit_params.py b/src/cloudflare/types/token_validation/rule_bulk_edit_params.py index 7f68d7806b4..f31da854783 100644 --- a/src/cloudflare/types/token_validation/rule_bulk_edit_params.py +++ b/src/cloudflare/types/token_validation/rule_bulk_edit_params.py @@ -21,7 +21,7 @@ class RuleBulkEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/token_validation/rule_create_params.py b/src/cloudflare/types/token_validation/rule_create_params.py index f92cb7d21be..d8e11b79909 100644 --- a/src/cloudflare/types/token_validation/rule_create_params.py +++ b/src/cloudflare/types/token_validation/rule_create_params.py @@ -11,7 +11,7 @@ class RuleCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" action: Required[Literal["log", "block"]] diff --git a/src/cloudflare/types/token_validation/rule_edit_params.py b/src/cloudflare/types/token_validation/rule_edit_params.py index c59c6da7155..ccbd01b5bfb 100644 --- a/src/cloudflare/types/token_validation/rule_edit_params.py +++ b/src/cloudflare/types/token_validation/rule_edit_params.py @@ -20,7 +20,7 @@ class RuleEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" action: Literal["log", "block"] diff --git a/src/cloudflare/types/token_validation/rule_list_params.py b/src/cloudflare/types/token_validation/rule_list_params.py index a241d61c90c..89d4cff3f86 100644 --- a/src/cloudflare/types/token_validation/rule_list_params.py +++ b/src/cloudflare/types/token_validation/rule_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class RuleListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" id: str diff --git a/src/cloudflare/types/turnstile/widget_create_params.py b/src/cloudflare/types/turnstile/widget_create_params.py index 61de9dba0d4..5165dde3e8c 100644 --- a/src/cloudflare/types/turnstile/widget_create_params.py +++ b/src/cloudflare/types/turnstile/widget_create_params.py @@ -11,7 +11,7 @@ class WidgetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" domains: Required[SequenceNotStr[WidgetDomain]] diff --git a/src/cloudflare/types/turnstile/widget_list_params.py b/src/cloudflare/types/turnstile/widget_list_params.py index a66438ade2e..2a8512c96ef 100644 --- a/src/cloudflare/types/turnstile/widget_list_params.py +++ b/src/cloudflare/types/turnstile/widget_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["WidgetListParams"] class WidgetListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" direction: Literal["asc", "desc"] diff --git a/src/cloudflare/types/turnstile/widget_rotate_secret_params.py b/src/cloudflare/types/turnstile/widget_rotate_secret_params.py index 72e9f7b0754..bbaaf51c753 100644 --- a/src/cloudflare/types/turnstile/widget_rotate_secret_params.py +++ b/src/cloudflare/types/turnstile/widget_rotate_secret_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["WidgetRotateSecretParams"] class WidgetRotateSecretParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" invalidate_immediately: bool diff --git a/src/cloudflare/types/turnstile/widget_update_params.py b/src/cloudflare/types/turnstile/widget_update_params.py index ac0255a3a42..b605b06e4cd 100644 --- a/src/cloudflare/types/turnstile/widget_update_params.py +++ b/src/cloudflare/types/turnstile/widget_update_params.py @@ -11,7 +11,7 @@ class WidgetUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" domains: Required[SequenceNotStr[WidgetDomain]] diff --git a/src/cloudflare/types/url_normalization/url_normalization_update_params.py b/src/cloudflare/types/url_normalization/url_normalization_update_params.py index 06b9f4e31c5..973def90dd9 100644 --- a/src/cloudflare/types/url_normalization/url_normalization_update_params.py +++ b/src/cloudflare/types/url_normalization/url_normalization_update_params.py @@ -8,7 +8,7 @@ class URLNormalizationUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """The unique ID of the zone.""" scope: Required[Literal["incoming", "both", "none"]] diff --git a/src/cloudflare/types/url_scanner/scan_bulk_create_params.py b/src/cloudflare/types/url_scanner/scan_bulk_create_params.py index f02ccc3ebee..0976e9ad0b1 100644 --- a/src/cloudflare/types/url_scanner/scan_bulk_create_params.py +++ b/src/cloudflare/types/url_scanner/scan_bulk_create_params.py @@ -11,7 +11,7 @@ class ScanBulkCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" body: Iterable[Body] @@ -21,6 +21,9 @@ class ScanBulkCreateParams(TypedDict, total=False): class Body(TypedDict, total=False): url: Required[str] + agent_readiness: Annotated[bool, PropertyInfo(alias="agentReadiness")] + """Enable agent readiness checks.""" + customagent: str custom_headers: Annotated[Dict[str, str], PropertyInfo(alias="customHeaders")] diff --git a/src/cloudflare/types/url_scanner/scan_create_params.py b/src/cloudflare/types/url_scanner/scan_create_params.py index a53306462fb..6eaf5e4ee73 100644 --- a/src/cloudflare/types/url_scanner/scan_create_params.py +++ b/src/cloudflare/types/url_scanner/scan_create_params.py @@ -11,11 +11,14 @@ class ScanCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" url: Required[str] + agent_readiness: Annotated[bool, PropertyInfo(alias="agentReadiness")] + """Enable agent readiness checks.""" + country: Literal[ "AF", "AL", diff --git a/src/cloudflare/types/url_scanner/scan_get_response.py b/src/cloudflare/types/url_scanner/scan_get_response.py index 8b8ccc69f85..e1d334d1dd5 100644 --- a/src/cloudflare/types/url_scanner/scan_get_response.py +++ b/src/cloudflare/types/url_scanner/scan_get_response.py @@ -47,6 +47,105 @@ "MetaProcessorsWappaData", "MetaProcessorsWappaDataCategory", "MetaProcessorsWappaDataConfidence", + "MetaProcessorsAgentReadiness", + "MetaProcessorsAgentReadinessChecks", + "MetaProcessorsAgentReadinessChecksBotAccessControl", + "MetaProcessorsAgentReadinessChecksBotAccessControlContentSignals", + "MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidence", + "MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidenceFinding", + "MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidenceRequest", + "MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidenceResponse", + "MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTXTAIRules", + "MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidence", + "MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidenceFinding", + "MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidenceRequest", + "MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidenceResponse", + "MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuth", + "MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidence", + "MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidenceFinding", + "MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidenceRequest", + "MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidenceResponse", + "MetaProcessorsAgentReadinessChecksCommerce", + "MetaProcessorsAgentReadinessChecksCommerceAcp", + "MetaProcessorsAgentReadinessChecksCommerceAcpEvidence", + "MetaProcessorsAgentReadinessChecksCommerceAcpEvidenceFinding", + "MetaProcessorsAgentReadinessChecksCommerceAcpEvidenceRequest", + "MetaProcessorsAgentReadinessChecksCommerceAcpEvidenceResponse", + "MetaProcessorsAgentReadinessChecksCommerceAp2", + "MetaProcessorsAgentReadinessChecksCommerceAp2Evidence", + "MetaProcessorsAgentReadinessChecksCommerceAp2EvidenceFinding", + "MetaProcessorsAgentReadinessChecksCommerceAp2EvidenceRequest", + "MetaProcessorsAgentReadinessChecksCommerceAp2EvidenceResponse", + "MetaProcessorsAgentReadinessChecksCommerceUcp", + "MetaProcessorsAgentReadinessChecksCommerceUcpEvidence", + "MetaProcessorsAgentReadinessChecksCommerceUcpEvidenceFinding", + "MetaProcessorsAgentReadinessChecksCommerceUcpEvidenceRequest", + "MetaProcessorsAgentReadinessChecksCommerceUcpEvidenceResponse", + "MetaProcessorsAgentReadinessChecksCommerceX402", + "MetaProcessorsAgentReadinessChecksCommerceX402Evidence", + "MetaProcessorsAgentReadinessChecksCommerceX402EvidenceFinding", + "MetaProcessorsAgentReadinessChecksCommerceX402EvidenceRequest", + "MetaProcessorsAgentReadinessChecksCommerceX402EvidenceResponse", + "MetaProcessorsAgentReadinessChecksContentAccessibility", + "MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiation", + "MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidence", + "MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidenceFinding", + "MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidenceRequest", + "MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscoverability", + "MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeaders", + "MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidence", + "MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXT", + "MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidence", + "MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscoverabilitySitemap", + "MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidence", + "MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscovery", + "MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCard", + "MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidence", + "MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscoveryAgentSkills", + "MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidence", + "MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscoveryAPICatalog", + "MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidence", + "MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCard", + "MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidence", + "MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscovery", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidence", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResource", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidence", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidenceResponse", + "MetaProcessorsAgentReadinessChecksDiscoveryWebMcp", + "MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidence", + "MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidenceFinding", + "MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidenceRequest", + "MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidenceResponse", + "MetaProcessorsAgentReadinessNextLevel", + "MetaProcessorsAgentReadinessNextLevelRequirement", "MetaProcessorsPhishingV2", "MetaProcessorsRobotsTXT", "MetaProcessorsRobotsTXTData", @@ -504,6 +603,1044 @@ class MetaProcessorsWappa(BaseModel): data: List[MetaProcessorsWappaData] +class MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksBotAccessControlContentSignals(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksBotAccessControlContentSignalsEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTXTAIRules(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTxtaiRulesEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuth(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuthEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksBotAccessControl(BaseModel): + content_signals: MetaProcessorsAgentReadinessChecksBotAccessControlContentSignals = FieldInfo( + alias="contentSignals" + ) + + robots_txt_ai_rules: MetaProcessorsAgentReadinessChecksBotAccessControlRobotsTXTAIRules = FieldInfo( + alias="robotsTxtAiRules" + ) + + web_bot_auth: MetaProcessorsAgentReadinessChecksBotAccessControlWebBotAuth = FieldInfo(alias="webBotAuth") + + +class MetaProcessorsAgentReadinessChecksCommerceAcpEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksCommerceAcpEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksCommerceAcpEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksCommerceAcpEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksCommerceAcpEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksCommerceAcpEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksCommerceAcpEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksCommerceAcp(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksCommerceAcpEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksCommerceAp2EvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksCommerceAp2EvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksCommerceAp2EvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksCommerceAp2Evidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksCommerceAp2EvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksCommerceAp2EvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksCommerceAp2EvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksCommerceAp2(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksCommerceAp2Evidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksCommerceUcpEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksCommerceUcpEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksCommerceUcpEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksCommerceUcpEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksCommerceUcpEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksCommerceUcpEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksCommerceUcpEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksCommerceUcp(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksCommerceUcpEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksCommerceX402EvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksCommerceX402EvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksCommerceX402EvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksCommerceX402Evidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksCommerceX402EvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksCommerceX402EvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksCommerceX402EvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksCommerceX402(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksCommerceX402Evidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksCommerce(BaseModel): + acp: MetaProcessorsAgentReadinessChecksCommerceAcp + + ap2: MetaProcessorsAgentReadinessChecksCommerceAp2 + + ucp: MetaProcessorsAgentReadinessChecksCommerceUcp + + x402: MetaProcessorsAgentReadinessChecksCommerceX402 + + +class MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiation(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiationEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksContentAccessibility(BaseModel): + markdown_negotiation: MetaProcessorsAgentReadinessChecksContentAccessibilityMarkdownNegotiation = FieldInfo( + alias="markdownNegotiation" + ) + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeaders(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeadersEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXT(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXTEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoverabilitySitemap(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoverabilitySitemapEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscoverability(BaseModel): + link_headers: MetaProcessorsAgentReadinessChecksDiscoverabilityLinkHeaders = FieldInfo(alias="linkHeaders") + + robots_txt: MetaProcessorsAgentReadinessChecksDiscoverabilityRobotsTXT = FieldInfo(alias="robotsTxt") + + sitemap: MetaProcessorsAgentReadinessChecksDiscoverabilitySitemap + + +class MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCard(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCardEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryAgentSkills(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoveryAgentSkillsEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryAPICatalog(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoveryAPICatalogEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCard(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCardEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscovery(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscoveryEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResource(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResourceEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidenceFinding(BaseModel): + outcome: str + + summary: str + + +class MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidenceRequest(BaseModel): + method: str + + url: str + + headers: Optional[object] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidenceResponse(BaseModel): + status: int + + status_text: str = FieldInfo(alias="statusText") + + body_preview: Optional[str] = FieldInfo(alias="bodyPreview", default=None) + + body_size: Optional[int] = FieldInfo(alias="bodySize", default=None) + + headers: Optional[object] = None + + redirected_to: Optional[str] = FieldInfo(alias="redirectedTo", default=None) + + +class MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidence(BaseModel): + action: str + + label: str + + finding: Optional[MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidenceFinding] = None + + request: Optional[MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidenceRequest] = None + + response: Optional[MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidenceResponse] = None + + +class MetaProcessorsAgentReadinessChecksDiscoveryWebMcp(BaseModel): + status: str + + details: Optional[object] = None + + duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None) + + evidence: Optional[List[MetaProcessorsAgentReadinessChecksDiscoveryWebMcpEvidence]] = None + + message: Optional[str] = None + + +class MetaProcessorsAgentReadinessChecksDiscovery(BaseModel): + a2a_agent_card: MetaProcessorsAgentReadinessChecksDiscoveryA2aAgentCard = FieldInfo(alias="a2aAgentCard") + + agent_skills: MetaProcessorsAgentReadinessChecksDiscoveryAgentSkills = FieldInfo(alias="agentSkills") + + api_catalog: MetaProcessorsAgentReadinessChecksDiscoveryAPICatalog = FieldInfo(alias="apiCatalog") + + mcp_server_card: MetaProcessorsAgentReadinessChecksDiscoveryMcpServerCard = FieldInfo(alias="mcpServerCard") + + oauth_discovery: MetaProcessorsAgentReadinessChecksDiscoveryOAuthDiscovery = FieldInfo(alias="oauthDiscovery") + + oauth_protected_resource: MetaProcessorsAgentReadinessChecksDiscoveryOAuthProtectedResource = FieldInfo( + alias="oauthProtectedResource" + ) + + web_mcp: MetaProcessorsAgentReadinessChecksDiscoveryWebMcp = FieldInfo(alias="webMcp") + + +class MetaProcessorsAgentReadinessChecks(BaseModel): + bot_access_control: MetaProcessorsAgentReadinessChecksBotAccessControl = FieldInfo(alias="botAccessControl") + + commerce: MetaProcessorsAgentReadinessChecksCommerce + + content_accessibility: MetaProcessorsAgentReadinessChecksContentAccessibility = FieldInfo( + alias="contentAccessibility" + ) + + discoverability: MetaProcessorsAgentReadinessChecksDiscoverability + + discovery: MetaProcessorsAgentReadinessChecksDiscovery + + +class MetaProcessorsAgentReadinessNextLevelRequirement(BaseModel): + check: str + + description: str + + prompt: str + + skill_url: str = FieldInfo(alias="skillUrl") + + spec_urls: List[str] = FieldInfo(alias="specUrls") + + +class MetaProcessorsAgentReadinessNextLevel(BaseModel): + name: str + + requirements: List[MetaProcessorsAgentReadinessNextLevelRequirement] + + target: int + + +class MetaProcessorsAgentReadiness(BaseModel): + checks: MetaProcessorsAgentReadinessChecks + + level: int + + level_name: str = FieldInfo(alias="levelName") + + commerce_signals: Optional[List[str]] = FieldInfo(alias="commerceSignals", default=None) + + is_commerce: Optional[bool] = FieldInfo(alias="isCommerce", default=None) + + next_level: Optional[MetaProcessorsAgentReadinessNextLevel] = FieldInfo(alias="nextLevel", default=None) + + class MetaProcessorsPhishingV2(BaseModel): data: List[str] @@ -613,6 +1750,8 @@ class MetaProcessors(BaseModel): wappa: MetaProcessorsWappa + agent_readiness: Optional[MetaProcessorsAgentReadiness] = FieldInfo(alias="agentReadiness", default=None) + phishing_v2: Optional[MetaProcessorsPhishingV2] = None robots_txt: Optional[MetaProcessorsRobotsTXT] = FieldInfo(alias="robotsTxt", default=None) diff --git a/src/cloudflare/types/url_scanner/scan_list_params.py b/src/cloudflare/types/url_scanner/scan_list_params.py index 97421b92ccc..d784dea614c 100644 --- a/src/cloudflare/types/url_scanner/scan_list_params.py +++ b/src/cloudflare/types/url_scanner/scan_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ScanListParams"] class ScanListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" q: str diff --git a/src/cloudflare/types/url_scanner/scan_screenshot_params.py b/src/cloudflare/types/url_scanner/scan_screenshot_params.py index 263a003363f..7c7a1a22ce8 100644 --- a/src/cloudflare/types/url_scanner/scan_screenshot_params.py +++ b/src/cloudflare/types/url_scanner/scan_screenshot_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ScanScreenshotParams"] class ScanScreenshotParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account ID.""" resolution: Literal["desktop", "mobile", "tablet"] diff --git a/src/cloudflare/types/vectorize/index_create_params.py b/src/cloudflare/types/vectorize/index_create_params.py index 1754ce05d18..faa6ad94ba8 100644 --- a/src/cloudflare/types/vectorize/index_create_params.py +++ b/src/cloudflare/types/vectorize/index_create_params.py @@ -11,7 +11,7 @@ class IndexCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" config: Required[Config] diff --git a/src/cloudflare/types/vectorize/index_delete_by_ids_params.py b/src/cloudflare/types/vectorize/index_delete_by_ids_params.py index 4595f5458f3..1b21f4972af 100644 --- a/src/cloudflare/types/vectorize/index_delete_by_ids_params.py +++ b/src/cloudflare/types/vectorize/index_delete_by_ids_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class IndexDeleteByIDsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" ids: SequenceNotStr[str] diff --git a/src/cloudflare/types/vectorize/index_get_by_ids_params.py b/src/cloudflare/types/vectorize/index_get_by_ids_params.py index 8024b367604..4ea65a642b4 100644 --- a/src/cloudflare/types/vectorize/index_get_by_ids_params.py +++ b/src/cloudflare/types/vectorize/index_get_by_ids_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class IndexGetByIDsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" ids: SequenceNotStr[str] diff --git a/src/cloudflare/types/vectorize/index_insert_params.py b/src/cloudflare/types/vectorize/index_insert_params.py index 2a793667035..64b357d1b5a 100644 --- a/src/cloudflare/types/vectorize/index_insert_params.py +++ b/src/cloudflare/types/vectorize/index_insert_params.py @@ -11,7 +11,7 @@ class IndexInsertParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" body: Required[FileTypes] diff --git a/src/cloudflare/types/vectorize/index_list_vectors_params.py b/src/cloudflare/types/vectorize/index_list_vectors_params.py index 5f913ede275..c41a8ef03c4 100644 --- a/src/cloudflare/types/vectorize/index_list_vectors_params.py +++ b/src/cloudflare/types/vectorize/index_list_vectors_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["IndexListVectorsParams"] class IndexListVectorsParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" count: int diff --git a/src/cloudflare/types/vectorize/index_query_params.py b/src/cloudflare/types/vectorize/index_query_params.py index c0c488a2ccf..2c6c41ccb87 100644 --- a/src/cloudflare/types/vectorize/index_query_params.py +++ b/src/cloudflare/types/vectorize/index_query_params.py @@ -11,7 +11,7 @@ class IndexQueryParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" vector: Required[Iterable[float]] diff --git a/src/cloudflare/types/vectorize/index_upsert_params.py b/src/cloudflare/types/vectorize/index_upsert_params.py index 5e7dc3f3b55..9676180dab8 100644 --- a/src/cloudflare/types/vectorize/index_upsert_params.py +++ b/src/cloudflare/types/vectorize/index_upsert_params.py @@ -11,7 +11,7 @@ class IndexUpsertParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" body: Required[FileTypes] diff --git a/src/cloudflare/types/vectorize/indexes/metadata_index_create_params.py b/src/cloudflare/types/vectorize/indexes/metadata_index_create_params.py index 248cd1ceca6..341fb90216a 100644 --- a/src/cloudflare/types/vectorize/indexes/metadata_index_create_params.py +++ b/src/cloudflare/types/vectorize/indexes/metadata_index_create_params.py @@ -10,7 +10,7 @@ class MetadataIndexCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" index_type: Required[Annotated[Literal["string", "number", "boolean"], PropertyInfo(alias="indexType")]] diff --git a/src/cloudflare/types/vectorize/indexes/metadata_index_delete_params.py b/src/cloudflare/types/vectorize/indexes/metadata_index_delete_params.py index f9783b5a394..dc394dc4646 100644 --- a/src/cloudflare/types/vectorize/indexes/metadata_index_delete_params.py +++ b/src/cloudflare/types/vectorize/indexes/metadata_index_delete_params.py @@ -10,7 +10,7 @@ class MetadataIndexDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier""" property_name: Required[Annotated[str, PropertyInfo(alias="propertyName")]] diff --git a/src/cloudflare/types/vulnerability_scanner/credential_set_create_params.py b/src/cloudflare/types/vulnerability_scanner/credential_set_create_params.py index 83dc378d0e5..7521f765992 100644 --- a/src/cloudflare/types/vulnerability_scanner/credential_set_create_params.py +++ b/src/cloudflare/types/vulnerability_scanner/credential_set_create_params.py @@ -8,7 +8,7 @@ class CredentialSetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/vulnerability_scanner/credential_set_edit_params.py b/src/cloudflare/types/vulnerability_scanner/credential_set_edit_params.py index 0074dd20c81..fac0df0e24f 100644 --- a/src/cloudflare/types/vulnerability_scanner/credential_set_edit_params.py +++ b/src/cloudflare/types/vulnerability_scanner/credential_set_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CredentialSetEditParams"] class CredentialSetEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: str diff --git a/src/cloudflare/types/vulnerability_scanner/credential_set_list_params.py b/src/cloudflare/types/vulnerability_scanner/credential_set_list_params.py index 79175eeebe4..c7de2cec226 100644 --- a/src/cloudflare/types/vulnerability_scanner/credential_set_list_params.py +++ b/src/cloudflare/types/vulnerability_scanner/credential_set_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CredentialSetListParams"] class CredentialSetListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/vulnerability_scanner/credential_set_update_params.py b/src/cloudflare/types/vulnerability_scanner/credential_set_update_params.py index a49fc957fe4..bbc9031f034 100644 --- a/src/cloudflare/types/vulnerability_scanner/credential_set_update_params.py +++ b/src/cloudflare/types/vulnerability_scanner/credential_set_update_params.py @@ -8,7 +8,7 @@ class CredentialSetUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_create_params.py b/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_create_params.py index ec87d38ea9b..85881f654a6 100644 --- a/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_create_params.py +++ b/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_create_params.py @@ -8,7 +8,7 @@ class CredentialCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" location: Required[Literal["header", "cookie"]] diff --git a/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_edit_params.py b/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_edit_params.py index 00ba9e37f9c..503b346e706 100644 --- a/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_edit_params.py +++ b/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_edit_params.py @@ -8,7 +8,7 @@ class CredentialEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" credential_set_id: Required[str] diff --git a/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_list_params.py b/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_list_params.py index 842e7618875..8ae79300af5 100644 --- a/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_list_params.py +++ b/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CredentialListParams"] class CredentialListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_update_params.py b/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_update_params.py index 9c5a58dc2b0..cfc91e5489a 100644 --- a/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_update_params.py +++ b/src/cloudflare/types/vulnerability_scanner/credential_sets/credential_update_params.py @@ -8,7 +8,7 @@ class CredentialUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" credential_set_id: Required[str] diff --git a/src/cloudflare/types/vulnerability_scanner/scan_create_params.py b/src/cloudflare/types/vulnerability_scanner/scan_create_params.py index e22563278f2..43ff1fed642 100644 --- a/src/cloudflare/types/vulnerability_scanner/scan_create_params.py +++ b/src/cloudflare/types/vulnerability_scanner/scan_create_params.py @@ -10,7 +10,7 @@ class ScanCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" credential_sets: Required[CredentialSets] diff --git a/src/cloudflare/types/vulnerability_scanner/scan_list_params.py b/src/cloudflare/types/vulnerability_scanner/scan_list_params.py index 7c7a84a12d2..efe67db5f25 100644 --- a/src/cloudflare/types/vulnerability_scanner/scan_list_params.py +++ b/src/cloudflare/types/vulnerability_scanner/scan_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ScanListParams"] class ScanListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/vulnerability_scanner/target_environment_create_params.py b/src/cloudflare/types/vulnerability_scanner/target_environment_create_params.py index 51369f9d369..01391b97788 100644 --- a/src/cloudflare/types/vulnerability_scanner/target_environment_create_params.py +++ b/src/cloudflare/types/vulnerability_scanner/target_environment_create_params.py @@ -9,7 +9,7 @@ class TargetEnvironmentCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/vulnerability_scanner/target_environment_edit_params.py b/src/cloudflare/types/vulnerability_scanner/target_environment_edit_params.py index aeb3d688add..08058a73b09 100644 --- a/src/cloudflare/types/vulnerability_scanner/target_environment_edit_params.py +++ b/src/cloudflare/types/vulnerability_scanner/target_environment_edit_params.py @@ -9,7 +9,7 @@ class TargetEnvironmentEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" description: Optional[str] diff --git a/src/cloudflare/types/vulnerability_scanner/target_environment_list_params.py b/src/cloudflare/types/vulnerability_scanner/target_environment_list_params.py index 8cee1b38f60..e090fb87f30 100644 --- a/src/cloudflare/types/vulnerability_scanner/target_environment_list_params.py +++ b/src/cloudflare/types/vulnerability_scanner/target_environment_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["TargetEnvironmentListParams"] class TargetEnvironmentListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/vulnerability_scanner/target_environment_update_params.py b/src/cloudflare/types/vulnerability_scanner/target_environment_update_params.py index b4e7d9767d2..09c37bbefbd 100644 --- a/src/cloudflare/types/vulnerability_scanner/target_environment_update_params.py +++ b/src/cloudflare/types/vulnerability_scanner/target_environment_update_params.py @@ -9,7 +9,7 @@ class TargetEnvironmentUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/waiting_rooms/__init__.py b/src/cloudflare/types/waiting_rooms/__init__.py index 2515f745a0a..63ac8eb3b82 100644 --- a/src/cloudflare/types/waiting_rooms/__init__.py +++ b/src/cloudflare/types/waiting_rooms/__init__.py @@ -26,6 +26,7 @@ from .cookie_attributes_param import CookieAttributesParam as CookieAttributesParam from .setting_update_response import SettingUpdateResponse as SettingUpdateResponse from .waiting_room_edit_params import WaitingRoomEditParams as WaitingRoomEditParams +from .waiting_room_list_params import WaitingRoomListParams as WaitingRoomListParams from .waiting_room_create_params import WaitingRoomCreateParams as WaitingRoomCreateParams from .waiting_room_update_params import WaitingRoomUpdateParams as WaitingRoomUpdateParams from .waiting_room_delete_response import WaitingRoomDeleteResponse as WaitingRoomDeleteResponse diff --git a/src/cloudflare/types/waiting_rooms/event_create_params.py b/src/cloudflare/types/waiting_rooms/event_create_params.py index 06aa816b1f9..c66143a53ac 100644 --- a/src/cloudflare/types/waiting_rooms/event_create_params.py +++ b/src/cloudflare/types/waiting_rooms/event_create_params.py @@ -9,7 +9,7 @@ class EventCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" event_end_time: Required[str] diff --git a/src/cloudflare/types/waiting_rooms/event_edit_params.py b/src/cloudflare/types/waiting_rooms/event_edit_params.py index 722535af1fe..b63ae52165f 100644 --- a/src/cloudflare/types/waiting_rooms/event_edit_params.py +++ b/src/cloudflare/types/waiting_rooms/event_edit_params.py @@ -9,7 +9,7 @@ class EventEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" waiting_room_id: Required[str] diff --git a/src/cloudflare/types/waiting_rooms/event_list_params.py b/src/cloudflare/types/waiting_rooms/event_list_params.py index 9e585437ce8..201d74d75f7 100644 --- a/src/cloudflare/types/waiting_rooms/event_list_params.py +++ b/src/cloudflare/types/waiting_rooms/event_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["EventListParams"] class EventListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" page: float diff --git a/src/cloudflare/types/waiting_rooms/event_update_params.py b/src/cloudflare/types/waiting_rooms/event_update_params.py index e56d04d1241..7d43c940930 100644 --- a/src/cloudflare/types/waiting_rooms/event_update_params.py +++ b/src/cloudflare/types/waiting_rooms/event_update_params.py @@ -9,7 +9,7 @@ class EventUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" waiting_room_id: Required[str] diff --git a/src/cloudflare/types/waiting_rooms/page_preview_params.py b/src/cloudflare/types/waiting_rooms/page_preview_params.py index b79d818e12e..ec70a9ff0cf 100644 --- a/src/cloudflare/types/waiting_rooms/page_preview_params.py +++ b/src/cloudflare/types/waiting_rooms/page_preview_params.py @@ -8,7 +8,7 @@ class PagePreviewParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" custom_html: Required[str] diff --git a/src/cloudflare/types/waiting_rooms/rule_create_params.py b/src/cloudflare/types/waiting_rooms/rule_create_params.py index 541d44450cd..1bf5626169e 100644 --- a/src/cloudflare/types/waiting_rooms/rule_create_params.py +++ b/src/cloudflare/types/waiting_rooms/rule_create_params.py @@ -8,7 +8,7 @@ class RuleCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" rules: Required[Rules] diff --git a/src/cloudflare/types/waiting_rooms/rule_edit_params.py b/src/cloudflare/types/waiting_rooms/rule_edit_params.py index b47af6b93f6..81e75d24c5a 100644 --- a/src/cloudflare/types/waiting_rooms/rule_edit_params.py +++ b/src/cloudflare/types/waiting_rooms/rule_edit_params.py @@ -9,7 +9,7 @@ class RuleEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" waiting_room_id: Required[str] diff --git a/src/cloudflare/types/waiting_rooms/rule_update_params.py b/src/cloudflare/types/waiting_rooms/rule_update_params.py index 2f5cac8b5ba..d16432e4dec 100644 --- a/src/cloudflare/types/waiting_rooms/rule_update_params.py +++ b/src/cloudflare/types/waiting_rooms/rule_update_params.py @@ -9,7 +9,7 @@ class RuleUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" rules: Required[Iterable[Rule]] diff --git a/src/cloudflare/types/waiting_rooms/setting_edit_params.py b/src/cloudflare/types/waiting_rooms/setting_edit_params.py index e51589f9da3..2a3cdafc2da 100644 --- a/src/cloudflare/types/waiting_rooms/setting_edit_params.py +++ b/src/cloudflare/types/waiting_rooms/setting_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SettingEditParams"] class SettingEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" search_engine_crawler_bypass: bool diff --git a/src/cloudflare/types/waiting_rooms/setting_update_params.py b/src/cloudflare/types/waiting_rooms/setting_update_params.py index 8893bea54c3..39d410db660 100644 --- a/src/cloudflare/types/waiting_rooms/setting_update_params.py +++ b/src/cloudflare/types/waiting_rooms/setting_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SettingUpdateParams"] class SettingUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" search_engine_crawler_bypass: bool diff --git a/src/cloudflare/types/waiting_rooms/waiting_room_create_params.py b/src/cloudflare/types/waiting_rooms/waiting_room_create_params.py index fecbc179196..82b96e2f36c 100644 --- a/src/cloudflare/types/waiting_rooms/waiting_room_create_params.py +++ b/src/cloudflare/types/waiting_rooms/waiting_room_create_params.py @@ -12,7 +12,7 @@ class WaitingRoomCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" host: Required[str] diff --git a/src/cloudflare/types/waiting_rooms/waiting_room_edit_params.py b/src/cloudflare/types/waiting_rooms/waiting_room_edit_params.py index 77126b1a0aa..7ca823fd148 100644 --- a/src/cloudflare/types/waiting_rooms/waiting_room_edit_params.py +++ b/src/cloudflare/types/waiting_rooms/waiting_room_edit_params.py @@ -12,7 +12,7 @@ class WaitingRoomEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" host: Required[str] diff --git a/src/cloudflare/types/waiting_rooms/waiting_room_list_params.py b/src/cloudflare/types/waiting_rooms/waiting_room_list_params.py new file mode 100644 index 00000000000..cc9bc3ad63e --- /dev/null +++ b/src/cloudflare/types/waiting_rooms/waiting_room_list_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["WaitingRoomListParams"] + + +class WaitingRoomListParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + page: float + """Page number of paginated results.""" + + per_page: float + """Maximum number of results per page. Must be a multiple of 5.""" diff --git a/src/cloudflare/types/waiting_rooms/waiting_room_update_params.py b/src/cloudflare/types/waiting_rooms/waiting_room_update_params.py index 6e02d3de918..96112e5abf8 100644 --- a/src/cloudflare/types/waiting_rooms/waiting_room_update_params.py +++ b/src/cloudflare/types/waiting_rooms/waiting_room_update_params.py @@ -12,7 +12,7 @@ class WaitingRoomUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" host: Required[str] diff --git a/src/cloudflare/types/web3/hostname_create_params.py b/src/cloudflare/types/web3/hostname_create_params.py index 9bba7e142b7..656e45304e6 100644 --- a/src/cloudflare/types/web3/hostname_create_params.py +++ b/src/cloudflare/types/web3/hostname_create_params.py @@ -8,7 +8,7 @@ class HostnameCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Specify the identifier of the hostname.""" name: Required[str] diff --git a/src/cloudflare/types/web3/hostname_edit_params.py b/src/cloudflare/types/web3/hostname_edit_params.py index 48150e8906a..9b1e4e2dbc1 100644 --- a/src/cloudflare/types/web3/hostname_edit_params.py +++ b/src/cloudflare/types/web3/hostname_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HostnameEditParams"] class HostnameEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Specify the identifier of the hostname.""" description: str diff --git a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_params.py b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_params.py index 034933f46f6..9fda437f605 100644 --- a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_params.py +++ b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_params.py @@ -9,7 +9,7 @@ class ContentListUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Specify the identifier of the hostname.""" action: Required[Literal["block"]] diff --git a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_lists/entry_create_params.py b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_lists/entry_create_params.py index d405fc9ebe5..63b9b639ba7 100644 --- a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_lists/entry_create_params.py +++ b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_lists/entry_create_params.py @@ -8,7 +8,7 @@ class EntryCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Specify the identifier of the hostname.""" content: Required[str] diff --git a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_lists/entry_update_params.py b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_lists/entry_update_params.py index e48b25bd067..3a40dcf74fd 100644 --- a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_lists/entry_update_params.py +++ b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_lists/entry_update_params.py @@ -8,7 +8,7 @@ class EntryUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Specify the identifier of the hostname.""" identifier: Required[str] diff --git a/src/cloudflare/types/workers/account_setting_update_params.py b/src/cloudflare/types/workers/account_setting_update_params.py index 9dd07e89cf4..8f21932344d 100644 --- a/src/cloudflare/types/workers/account_setting_update_params.py +++ b/src/cloudflare/types/workers/account_setting_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["AccountSettingUpdateParams"] class AccountSettingUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" default_usage_model: str diff --git a/src/cloudflare/types/workers/assets/upload_create_params.py b/src/cloudflare/types/workers/assets/upload_create_params.py index 9e1388f5e55..4279447512f 100644 --- a/src/cloudflare/types/workers/assets/upload_create_params.py +++ b/src/cloudflare/types/workers/assets/upload_create_params.py @@ -9,7 +9,7 @@ class UploadCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" base64: Required[Literal[True]] diff --git a/src/cloudflare/types/workers/beta/worker_create_params.py b/src/cloudflare/types/workers/beta/worker_create_params.py index a5453a6e771..278236f44d3 100644 --- a/src/cloudflare/types/workers/beta/worker_create_params.py +++ b/src/cloudflare/types/workers/beta/worker_create_params.py @@ -18,7 +18,7 @@ class WorkerCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/workers/beta/worker_edit_params.py b/src/cloudflare/types/workers/beta/worker_edit_params.py index e0dfe008859..5ea5b5cbbd3 100644 --- a/src/cloudflare/types/workers/beta/worker_edit_params.py +++ b/src/cloudflare/types/workers/beta/worker_edit_params.py @@ -11,7 +11,7 @@ class WorkerEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" logpush: Required[bool] diff --git a/src/cloudflare/types/workers/beta/worker_list_params.py b/src/cloudflare/types/workers/beta/worker_list_params.py index 27f46845688..569a378cd18 100644 --- a/src/cloudflare/types/workers/beta/worker_list_params.py +++ b/src/cloudflare/types/workers/beta/worker_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["WorkerListParams"] class WorkerListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" order: Literal["asc", "desc"] diff --git a/src/cloudflare/types/workers/beta/worker_update_params.py b/src/cloudflare/types/workers/beta/worker_update_params.py index 79cb27cf00b..5c13f983c1f 100644 --- a/src/cloudflare/types/workers/beta/worker_update_params.py +++ b/src/cloudflare/types/workers/beta/worker_update_params.py @@ -18,7 +18,7 @@ class WorkerUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/workers/beta/workers/version_create_params.py b/src/cloudflare/types/workers/beta/workers/version_create_params.py index 9f4b87ffba3..de4efe5f1ea 100644 --- a/src/cloudflare/types/workers/beta/workers/version_create_params.py +++ b/src/cloudflare/types/workers/beta/workers/version_create_params.py @@ -78,7 +78,7 @@ class VersionCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" deploy: bool diff --git a/src/cloudflare/types/workers/beta/workers/version_get_params.py b/src/cloudflare/types/workers/beta/workers/version_get_params.py index e2030664541..97be509e649 100644 --- a/src/cloudflare/types/workers/beta/workers/version_get_params.py +++ b/src/cloudflare/types/workers/beta/workers/version_get_params.py @@ -8,7 +8,7 @@ class VersionGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" worker_id: Required[str] diff --git a/src/cloudflare/types/workers/beta/workers/version_list_params.py b/src/cloudflare/types/workers/beta/workers/version_list_params.py index d891cd5e824..d6ac2173cbf 100644 --- a/src/cloudflare/types/workers/beta/workers/version_list_params.py +++ b/src/cloudflare/types/workers/beta/workers/version_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["VersionListParams"] class VersionListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/workers/domain_list_params.py b/src/cloudflare/types/workers/domain_list_params.py index f3b4793f17d..a267aa1a4a0 100644 --- a/src/cloudflare/types/workers/domain_list_params.py +++ b/src/cloudflare/types/workers/domain_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DomainListParams"] class DomainListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" environment: str diff --git a/src/cloudflare/types/workers/domain_update_params.py b/src/cloudflare/types/workers/domain_update_params.py index 1fe70ad4906..7dd2c46700e 100644 --- a/src/cloudflare/types/workers/domain_update_params.py +++ b/src/cloudflare/types/workers/domain_update_params.py @@ -8,7 +8,7 @@ class DomainUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" hostname: Required[str] diff --git a/src/cloudflare/types/workers/observability/destination_create_params.py b/src/cloudflare/types/workers/observability/destination_create_params.py index 9af45a3f4fc..474ea0cee8a 100644 --- a/src/cloudflare/types/workers/observability/destination_create_params.py +++ b/src/cloudflare/types/workers/observability/destination_create_params.py @@ -11,7 +11,7 @@ class DestinationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str configuration: Required[Configuration] diff --git a/src/cloudflare/types/workers/observability/destination_list_params.py b/src/cloudflare/types/workers/observability/destination_list_params.py index 85d6519f33d..a7c0da46917 100644 --- a/src/cloudflare/types/workers/observability/destination_list_params.py +++ b/src/cloudflare/types/workers/observability/destination_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ...._utils import PropertyInfo @@ -10,7 +10,7 @@ class DestinationListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str order: Literal["asc", "desc"] diff --git a/src/cloudflare/types/workers/observability/destination_update_params.py b/src/cloudflare/types/workers/observability/destination_update_params.py index a6c2d729053..7b8754b4c43 100644 --- a/src/cloudflare/types/workers/observability/destination_update_params.py +++ b/src/cloudflare/types/workers/observability/destination_update_params.py @@ -9,7 +9,7 @@ class DestinationUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str configuration: Required[Configuration] diff --git a/src/cloudflare/types/workers/observability/telemetry_keys_params.py b/src/cloudflare/types/workers/observability/telemetry_keys_params.py index 275b94b0c97..15c446b608b 100644 --- a/src/cloudflare/types/workers/observability/telemetry_keys_params.py +++ b/src/cloudflare/types/workers/observability/telemetry_keys_params.py @@ -19,7 +19,7 @@ class TelemetryKeysParams(TypedDict, total=False): - account_id: Required[str] + account_id: str datasets: SequenceNotStr[str] """Leave this empty to use the default datasets""" diff --git a/src/cloudflare/types/workers/observability/telemetry_query_params.py b/src/cloudflare/types/workers/observability/telemetry_query_params.py index 6430ea3f9fb..e0a9dbdb6fa 100644 --- a/src/cloudflare/types/workers/observability/telemetry_query_params.py +++ b/src/cloudflare/types/workers/observability/telemetry_query_params.py @@ -24,7 +24,7 @@ class TelemetryQueryParams(TypedDict, total=False): - account_id: Required[str] + account_id: str query_id: Required[Annotated[str, PropertyInfo(alias="queryId")]] """Unique identifier for the query to execute""" diff --git a/src/cloudflare/types/workers/observability/telemetry_values_params.py b/src/cloudflare/types/workers/observability/telemetry_values_params.py index 9451743e295..9bd95acfbd3 100644 --- a/src/cloudflare/types/workers/observability/telemetry_values_params.py +++ b/src/cloudflare/types/workers/observability/telemetry_values_params.py @@ -19,7 +19,7 @@ class TelemetryValuesParams(TypedDict, total=False): - account_id: Required[str] + account_id: str datasets: Required[SequenceNotStr[str]] """Leave this empty to use the default datasets""" diff --git a/src/cloudflare/types/workers/route_create_params.py b/src/cloudflare/types/workers/route_create_params.py index d6972417d59..4b2916f5ae3 100644 --- a/src/cloudflare/types/workers/route_create_params.py +++ b/src/cloudflare/types/workers/route_create_params.py @@ -8,7 +8,7 @@ class RouteCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" pattern: Required[str] diff --git a/src/cloudflare/types/workers/route_update_params.py b/src/cloudflare/types/workers/route_update_params.py index 79a2b2a593f..5781866b531 100644 --- a/src/cloudflare/types/workers/route_update_params.py +++ b/src/cloudflare/types/workers/route_update_params.py @@ -8,7 +8,7 @@ class RouteUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" pattern: Required[str] diff --git a/src/cloudflare/types/workers/script_delete_params.py b/src/cloudflare/types/workers/script_delete_params.py index adbccee67d4..931d9702e3a 100644 --- a/src/cloudflare/types/workers/script_delete_params.py +++ b/src/cloudflare/types/workers/script_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ScriptDeleteParams"] class ScriptDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" force: bool diff --git a/src/cloudflare/types/workers/script_list_params.py b/src/cloudflare/types/workers/script_list_params.py index 61341782f60..a91b39be0e3 100644 --- a/src/cloudflare/types/workers/script_list_params.py +++ b/src/cloudflare/types/workers/script_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ScriptListParams"] class ScriptListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" tags: str diff --git a/src/cloudflare/types/workers/script_search_params.py b/src/cloudflare/types/workers/script_search_params.py index 001d332e90e..18e63a0b54c 100644 --- a/src/cloudflare/types/workers/script_search_params.py +++ b/src/cloudflare/types/workers/script_search_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ScriptSearchParams"] class ScriptSearchParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" id: str diff --git a/src/cloudflare/types/workers/script_update_params.py b/src/cloudflare/types/workers/script_update_params.py index fab83dc8675..a65c9f67530 100644 --- a/src/cloudflare/types/workers/script_update_params.py +++ b/src/cloudflare/types/workers/script_update_params.py @@ -80,7 +80,7 @@ class ScriptUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" metadata: Required[Metadata] diff --git a/src/cloudflare/types/workers/scripts/assets/upload_create_params.py b/src/cloudflare/types/workers/scripts/assets/upload_create_params.py index ee02d35a3ee..ce22605328f 100644 --- a/src/cloudflare/types/workers/scripts/assets/upload_create_params.py +++ b/src/cloudflare/types/workers/scripts/assets/upload_create_params.py @@ -9,7 +9,7 @@ class UploadCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" manifest: Required[Dict[str, Manifest]] diff --git a/src/cloudflare/types/workers/scripts/content_update_params.py b/src/cloudflare/types/workers/scripts/content_update_params.py index f24e76e9522..6de1579fb59 100644 --- a/src/cloudflare/types/workers/scripts/content_update_params.py +++ b/src/cloudflare/types/workers/scripts/content_update_params.py @@ -11,7 +11,7 @@ class ContentUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" metadata: Required[Metadata] diff --git a/src/cloudflare/types/workers/scripts/deployment_create_params.py b/src/cloudflare/types/workers/scripts/deployment_create_params.py index 1f8c35626b2..2227cfb1472 100644 --- a/src/cloudflare/types/workers/scripts/deployment_create_params.py +++ b/src/cloudflare/types/workers/scripts/deployment_create_params.py @@ -11,7 +11,7 @@ class DeploymentCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" strategy: Required[Literal["percentage"]] diff --git a/src/cloudflare/types/workers/scripts/schedule_update_params.py b/src/cloudflare/types/workers/scripts/schedule_update_params.py index 3f4e21c6d60..ba3997b29a1 100644 --- a/src/cloudflare/types/workers/scripts/schedule_update_params.py +++ b/src/cloudflare/types/workers/scripts/schedule_update_params.py @@ -9,7 +9,7 @@ class ScheduleUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/workers/scripts/script_and_version_setting_edit_params.py b/src/cloudflare/types/workers/scripts/script_and_version_setting_edit_params.py index 4307e6a11f3..f3c1dfbbfeb 100644 --- a/src/cloudflare/types/workers/scripts/script_and_version_setting_edit_params.py +++ b/src/cloudflare/types/workers/scripts/script_and_version_setting_edit_params.py @@ -78,7 +78,7 @@ class ScriptAndVersionSettingEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" settings: Settings diff --git a/src/cloudflare/types/workers/scripts/secret_delete_params.py b/src/cloudflare/types/workers/scripts/secret_delete_params.py index 072856d75f3..ae6656f059e 100644 --- a/src/cloudflare/types/workers/scripts/secret_delete_params.py +++ b/src/cloudflare/types/workers/scripts/secret_delete_params.py @@ -8,7 +8,7 @@ class SecretDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" script_name: Required[str] diff --git a/src/cloudflare/types/workers/scripts/secret_get_params.py b/src/cloudflare/types/workers/scripts/secret_get_params.py index ec1372cc8a0..baf73df92ba 100644 --- a/src/cloudflare/types/workers/scripts/secret_get_params.py +++ b/src/cloudflare/types/workers/scripts/secret_get_params.py @@ -8,7 +8,7 @@ class SecretGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" script_name: Required[str] diff --git a/src/cloudflare/types/workers/scripts/secret_update_params.py b/src/cloudflare/types/workers/scripts/secret_update_params.py index 50a322f91ee..4e5896aebc8 100644 --- a/src/cloudflare/types/workers/scripts/secret_update_params.py +++ b/src/cloudflare/types/workers/scripts/secret_update_params.py @@ -9,7 +9,7 @@ class WorkersBindingKindSecretText(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] @@ -23,7 +23,7 @@ class WorkersBindingKindSecretText(TypedDict, total=False): class WorkersBindingKindSecretKey(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" algorithm: Required[object] diff --git a/src/cloudflare/types/workers/scripts/setting_edit_params.py b/src/cloudflare/types/workers/scripts/setting_edit_params.py index 79602173d79..f9d4bde187e 100644 --- a/src/cloudflare/types/workers/scripts/setting_edit_params.py +++ b/src/cloudflare/types/workers/scripts/setting_edit_params.py @@ -12,7 +12,7 @@ class SettingEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" logpush: bool diff --git a/src/cloudflare/types/workers/scripts/subdomain_create_params.py b/src/cloudflare/types/workers/scripts/subdomain_create_params.py index eaa360b970f..20f50b6b23b 100644 --- a/src/cloudflare/types/workers/scripts/subdomain_create_params.py +++ b/src/cloudflare/types/workers/scripts/subdomain_create_params.py @@ -8,7 +8,7 @@ class SubdomainCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" enabled: Required[bool] diff --git a/src/cloudflare/types/workers/scripts/tail_create_params.py b/src/cloudflare/types/workers/scripts/tail_create_params.py index b139916d2e4..3b521e8753d 100644 --- a/src/cloudflare/types/workers/scripts/tail_create_params.py +++ b/src/cloudflare/types/workers/scripts/tail_create_params.py @@ -8,7 +8,7 @@ class TailCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" body: Required[object] diff --git a/src/cloudflare/types/workers/scripts/version_create_params.py b/src/cloudflare/types/workers/scripts/version_create_params.py index 1d985b2f937..e72537650ab 100644 --- a/src/cloudflare/types/workers/scripts/version_create_params.py +++ b/src/cloudflare/types/workers/scripts/version_create_params.py @@ -56,7 +56,7 @@ class VersionCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" metadata: Required[Metadata] diff --git a/src/cloudflare/types/workers/scripts/version_list_params.py b/src/cloudflare/types/workers/scripts/version_list_params.py index 8ec395b7c57..b15c6f57451 100644 --- a/src/cloudflare/types/workers/scripts/version_list_params.py +++ b/src/cloudflare/types/workers/scripts/version_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["VersionListParams"] class VersionListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" deployable: bool diff --git a/src/cloudflare/types/workers/subdomain_update_params.py b/src/cloudflare/types/workers/subdomain_update_params.py index e9c859e2742..5c084d8f162 100644 --- a/src/cloudflare/types/workers/subdomain_update_params.py +++ b/src/cloudflare/types/workers/subdomain_update_params.py @@ -8,7 +8,7 @@ class SubdomainUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" subdomain: Required[str] diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespace_create_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespace_create_params.py index cda0173ef7b..2ec301cb276 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespace_create_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespace_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["NamespaceCreateParams"] class NamespaceCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: str diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/script_delete_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/script_delete_params.py index e319bb4dd06..01fbc554213 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/script_delete_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/script_delete_params.py @@ -8,7 +8,7 @@ class ScriptDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/script_update_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/script_update_params.py index ff2bf226887..53b6b423ec9 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/script_update_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/script_update_params.py @@ -78,7 +78,7 @@ class ScriptUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/asset_upload_create_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/asset_upload_create_params.py index 9371d50af54..cbe0f755011 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/asset_upload_create_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/asset_upload_create_params.py @@ -9,7 +9,7 @@ class AssetUploadCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/content_update_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/content_update_params.py index a9e37d435a5..2bf785834a3 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/content_update_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/content_update_params.py @@ -12,7 +12,7 @@ class ContentUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_delete_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_delete_params.py index 4ab02ea8f63..be86bc2d495 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_delete_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_delete_params.py @@ -8,7 +8,7 @@ class SecretDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_get_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_get_params.py index f80e8635077..7ed09305784 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_get_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_get_params.py @@ -8,7 +8,7 @@ class SecretGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_update_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_update_params.py index 546fbeb728d..2b0a73a4a10 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_update_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/secret_update_params.py @@ -9,7 +9,7 @@ class WorkersBindingKindSecretText(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] @@ -26,7 +26,7 @@ class WorkersBindingKindSecretText(TypedDict, total=False): class WorkersBindingKindSecretKey(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/setting_edit_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/setting_edit_params.py index f11ee4e853d..59b2361abbc 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/setting_edit_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/setting_edit_params.py @@ -76,7 +76,7 @@ class SettingEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] diff --git a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/tag_update_params.py b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/tag_update_params.py index d7ec6256208..f2bc3c16f65 100644 --- a/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/tag_update_params.py +++ b/src/cloudflare/types/workers_for_platforms/dispatch/namespaces/scripts/tag_update_params.py @@ -11,7 +11,7 @@ class TagUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" dispatch_namespace: Required[str] diff --git a/src/cloudflare/types/workflows/instance_bulk_params.py b/src/cloudflare/types/workflows/instance_bulk_params.py index 6e306f00583..660a1602d65 100644 --- a/src/cloudflare/types/workflows/instance_bulk_params.py +++ b/src/cloudflare/types/workflows/instance_bulk_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["InstanceBulkParams", "Body", "BodyInstanceRetention"] class InstanceBulkParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Iterable[Body] diff --git a/src/cloudflare/types/workflows/instance_create_params.py b/src/cloudflare/types/workflows/instance_create_params.py index 15d684fa37e..03ea41e3994 100644 --- a/src/cloudflare/types/workflows/instance_create_params.py +++ b/src/cloudflare/types/workflows/instance_create_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Union -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["InstanceCreateParams", "InstanceRetention"] class InstanceCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str instance_id: str diff --git a/src/cloudflare/types/workflows/instance_get_params.py b/src/cloudflare/types/workflows/instance_get_params.py index eb22c5965ce..cd5b2080455 100644 --- a/src/cloudflare/types/workflows/instance_get_params.py +++ b/src/cloudflare/types/workflows/instance_get_params.py @@ -8,7 +8,7 @@ class InstanceGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str workflow_name: Required[str] diff --git a/src/cloudflare/types/workflows/instance_list_params.py b/src/cloudflare/types/workflows/instance_list_params.py index 113a939233c..c0239a5e171 100644 --- a/src/cloudflare/types/workflows/instance_list_params.py +++ b/src/cloudflare/types/workflows/instance_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class InstanceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str cursor: str """Opaque token for cursor-based pagination. Mutually exclusive with `page`.""" diff --git a/src/cloudflare/types/workflows/instances/event_create_params.py b/src/cloudflare/types/workflows/instances/event_create_params.py index 52118424ae5..c9b47fb4ad5 100644 --- a/src/cloudflare/types/workflows/instances/event_create_params.py +++ b/src/cloudflare/types/workflows/instances/event_create_params.py @@ -8,7 +8,7 @@ class EventCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str workflow_name: Required[str] diff --git a/src/cloudflare/types/workflows/instances/status_edit_params.py b/src/cloudflare/types/workflows/instances/status_edit_params.py index d70d048a1ee..edce6009d3c 100644 --- a/src/cloudflare/types/workflows/instances/status_edit_params.py +++ b/src/cloudflare/types/workflows/instances/status_edit_params.py @@ -8,7 +8,7 @@ class StatusEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str workflow_name: Required[str] diff --git a/src/cloudflare/types/workflows/version_list_params.py b/src/cloudflare/types/workflows/version_list_params.py index 05e3c443227..2621680c26d 100644 --- a/src/cloudflare/types/workflows/version_list_params.py +++ b/src/cloudflare/types/workflows/version_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["VersionListParams"] class VersionListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: float diff --git a/src/cloudflare/types/workflows/workflow_list_params.py b/src/cloudflare/types/workflows/workflow_list_params.py index 8c5c598864e..b37f48483cb 100644 --- a/src/cloudflare/types/workflows/workflow_list_params.py +++ b/src/cloudflare/types/workflows/workflow_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["WorkflowListParams"] class WorkflowListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: float diff --git a/src/cloudflare/types/workflows/workflow_update_params.py b/src/cloudflare/types/workflows/workflow_update_params.py index 2ff781a484d..a360e5711e8 100644 --- a/src/cloudflare/types/workflows/workflow_update_params.py +++ b/src/cloudflare/types/workflows/workflow_update_params.py @@ -8,7 +8,7 @@ class WorkflowUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str class_name: Required[str] diff --git a/src/cloudflare/types/zaraz/config_update_params.py b/src/cloudflare/types/zaraz/config_update_params.py index 7fa005e627b..e4176952429 100644 --- a/src/cloudflare/types/zaraz/config_update_params.py +++ b/src/cloudflare/types/zaraz/config_update_params.py @@ -60,7 +60,7 @@ class ConfigUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" data_layer: Required[Annotated[bool, PropertyInfo(alias="dataLayer")]] diff --git a/src/cloudflare/types/zaraz/history/config_get_params.py b/src/cloudflare/types/zaraz/history/config_get_params.py index 2549133ac3d..79669793324 100644 --- a/src/cloudflare/types/zaraz/history/config_get_params.py +++ b/src/cloudflare/types/zaraz/history/config_get_params.py @@ -9,7 +9,7 @@ class ConfigGetParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" ids: Required[Iterable[int]] diff --git a/src/cloudflare/types/zaraz/history_list_params.py b/src/cloudflare/types/zaraz/history_list_params.py index c7b5fb731e6..e1d91107400 100644 --- a/src/cloudflare/types/zaraz/history_list_params.py +++ b/src/cloudflare/types/zaraz/history_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -10,7 +10,7 @@ class HistoryListParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" limit: int diff --git a/src/cloudflare/types/zaraz/history_update_params.py b/src/cloudflare/types/zaraz/history_update_params.py index 7f6f60d5cff..2b7e48926db 100644 --- a/src/cloudflare/types/zaraz/history_update_params.py +++ b/src/cloudflare/types/zaraz/history_update_params.py @@ -8,7 +8,7 @@ class HistoryUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: Required[int] diff --git a/src/cloudflare/types/zaraz/publish_create_params.py b/src/cloudflare/types/zaraz/publish_create_params.py index 574d851996f..879affbfab0 100644 --- a/src/cloudflare/types/zaraz/publish_create_params.py +++ b/src/cloudflare/types/zaraz/publish_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PublishCreateParams"] class PublishCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" body: str diff --git a/src/cloudflare/types/zaraz/zaraz_update_params.py b/src/cloudflare/types/zaraz/zaraz_update_params.py index 5e781b346e3..5bd68188049 100644 --- a/src/cloudflare/types/zaraz/zaraz_update_params.py +++ b/src/cloudflare/types/zaraz/zaraz_update_params.py @@ -10,7 +10,7 @@ class ZarazUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" workflow: Required[Workflow] diff --git a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_create_params.py b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_create_params.py index 19bc795be10..a0f75248657 100644 --- a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_create_params.py +++ b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_create_params.py @@ -9,7 +9,7 @@ class PortalCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: Required[str] """portal id""" diff --git a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_list_params.py b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_list_params.py index 33f5100d91a..f85ee9d9fd7 100644 --- a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_list_params.py +++ b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PortalListParams"] class PortalListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: int diff --git a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_update_params.py b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_update_params.py index 1bd9dd5b4a7..fa83cb47438 100644 --- a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_update_params.py +++ b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/portal_update_params.py @@ -9,7 +9,7 @@ class PortalUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str allow_code_mode: bool """Allow remote code execution in Dynamic Workers (beta)""" diff --git a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_create_params.py b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_create_params.py index 57c26163547..258a5f8db78 100644 --- a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_create_params.py +++ b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_create_params.py @@ -9,7 +9,7 @@ class ServerCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: Required[str] """server id""" diff --git a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_list_params.py b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_list_params.py index 139f6ab9bad..70602b65651 100644 --- a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_list_params.py +++ b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ServerListParams"] class ServerListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: int diff --git a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_update_params.py b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_update_params.py index 38cf578f571..4cf2de448a2 100644 --- a/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_update_params.py +++ b/src/cloudflare/types/zero_trust/access/ai_controls/mcp/server_update_params.py @@ -9,7 +9,7 @@ class ServerUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str auth_credentials: str diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_test_create_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_test_create_params.py index 6be89506f1f..410342be187 100755 --- a/src/cloudflare/types/zero_trust/access/applications/policy_test_create_params.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_test_create_params.py @@ -21,7 +21,7 @@ class PolicyTestCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" policies: SequenceNotStr[Policy] diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_tests/user_list_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_tests/user_list_params.py index a35a3e075c7..03d89d49e6a 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_tests/user_list_params.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_tests/user_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["UserListParams"] class UserListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/zero_trust/access/bookmark_create_params.py b/src/cloudflare/types/zero_trust/access/bookmark_create_params.py index a0278f281d7..7c5005a97be 100644 --- a/src/cloudflare/types/zero_trust/access/bookmark_create_params.py +++ b/src/cloudflare/types/zero_trust/access/bookmark_create_params.py @@ -8,6 +8,6 @@ class BookmarkCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[object] diff --git a/src/cloudflare/types/zero_trust/access/bookmark_update_params.py b/src/cloudflare/types/zero_trust/access/bookmark_update_params.py index 82a32f4b5e0..9b9c4e561a9 100644 --- a/src/cloudflare/types/zero_trust/access/bookmark_update_params.py +++ b/src/cloudflare/types/zero_trust/access/bookmark_update_params.py @@ -8,6 +8,6 @@ class BookmarkUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[object] diff --git a/src/cloudflare/types/zero_trust/access/custom_page_create_params.py b/src/cloudflare/types/zero_trust/access/custom_page_create_params.py index ce8b80d12b5..25e1816d8cd 100644 --- a/src/cloudflare/types/zero_trust/access/custom_page_create_params.py +++ b/src/cloudflare/types/zero_trust/access/custom_page_create_params.py @@ -8,7 +8,7 @@ class CustomPageCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" custom_html: Required[str] diff --git a/src/cloudflare/types/zero_trust/access/custom_page_list_params.py b/src/cloudflare/types/zero_trust/access/custom_page_list_params.py index 2cb0f7545b7..d01502439ed 100644 --- a/src/cloudflare/types/zero_trust/access/custom_page_list_params.py +++ b/src/cloudflare/types/zero_trust/access/custom_page_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CustomPageListParams"] class CustomPageListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/zero_trust/access/custom_page_update_params.py b/src/cloudflare/types/zero_trust/access/custom_page_update_params.py index 1b82f6cf05b..0ef8ee8a790 100644 --- a/src/cloudflare/types/zero_trust/access/custom_page_update_params.py +++ b/src/cloudflare/types/zero_trust/access/custom_page_update_params.py @@ -8,7 +8,7 @@ class CustomPageUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" custom_html: Required[str] diff --git a/src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_delete_v2_params.py b/src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_delete_v2_params.py index 645b0c9ac78..3c57589949e 100644 --- a/src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_delete_v2_params.py +++ b/src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_delete_v2_params.py @@ -10,7 +10,7 @@ class TargetBulkDeleteV2Params(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" target_ids: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_update_params.py b/src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_update_params.py index df2dd331801..6a41d2d1c46 100644 --- a/src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_update_params.py +++ b/src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_update_params.py @@ -9,7 +9,7 @@ class TargetBulkUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/zero_trust/access/infrastructure/target_create_params.py b/src/cloudflare/types/zero_trust/access/infrastructure/target_create_params.py index 465af47967d..ee62803e7b8 100644 --- a/src/cloudflare/types/zero_trust/access/infrastructure/target_create_params.py +++ b/src/cloudflare/types/zero_trust/access/infrastructure/target_create_params.py @@ -8,7 +8,7 @@ class TargetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" hostname: Required[str] diff --git a/src/cloudflare/types/zero_trust/access/infrastructure/target_list_params.py b/src/cloudflare/types/zero_trust/access/infrastructure/target_list_params.py index 210b5e5fe2c..719d45f687b 100644 --- a/src/cloudflare/types/zero_trust/access/infrastructure/target_list_params.py +++ b/src/cloudflare/types/zero_trust/access/infrastructure/target_list_params.py @@ -4,7 +4,7 @@ from typing import Union, Optional from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ....._types import SequenceNotStr from ....._utils import PropertyInfo @@ -13,7 +13,7 @@ class TargetListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" created_after: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/zero_trust/access/infrastructure/target_update_params.py b/src/cloudflare/types/zero_trust/access/infrastructure/target_update_params.py index 1728fcc15f3..b1ccf2c9819 100644 --- a/src/cloudflare/types/zero_trust/access/infrastructure/target_update_params.py +++ b/src/cloudflare/types/zero_trust/access/infrastructure/target_update_params.py @@ -8,7 +8,7 @@ class TargetUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Account identifier""" hostname: Required[str] diff --git a/src/cloudflare/types/zero_trust/access/key_update_params.py b/src/cloudflare/types/zero_trust/access/key_update_params.py index 8eb5a1c7049..571f88fb261 100644 --- a/src/cloudflare/types/zero_trust/access/key_update_params.py +++ b/src/cloudflare/types/zero_trust/access/key_update_params.py @@ -8,7 +8,7 @@ class KeyUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" key_rotation_interval_days: Required[float] diff --git a/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py b/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py index c22b8ff0793..c1f4164c41a 100644 --- a/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py +++ b/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ....._utils import PropertyInfo @@ -12,7 +12,7 @@ class AccessRequestListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" allowed_op: Annotated[Literal["eq", "neq"], PropertyInfo(alias="allowedOp")] diff --git a/src/cloudflare/types/zero_trust/access/logs/scim/update_list_params.py b/src/cloudflare/types/zero_trust/access/logs/scim/update_list_params.py index 6ef5bb55bb5..4612dd9c6e2 100644 --- a/src/cloudflare/types/zero_trust/access/logs/scim/update_list_params.py +++ b/src/cloudflare/types/zero_trust/access/logs/scim/update_list_params.py @@ -13,7 +13,7 @@ class UpdateListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" idp_id: Required[SequenceNotStr[str]] diff --git a/src/cloudflare/types/zero_trust/access/policy_create_params.py b/src/cloudflare/types/zero_trust/access/policy_create_params.py index 880b61d6c48..c92ee7af8a7 100644 --- a/src/cloudflare/types/zero_trust/access/policy_create_params.py +++ b/src/cloudflare/types/zero_trust/access/policy_create_params.py @@ -13,7 +13,7 @@ class PolicyCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" decision: Required[Decision] diff --git a/src/cloudflare/types/zero_trust/access/policy_list_params.py b/src/cloudflare/types/zero_trust/access/policy_list_params.py index 81043b62ad6..e644aaa5882 100644 --- a/src/cloudflare/types/zero_trust/access/policy_list_params.py +++ b/src/cloudflare/types/zero_trust/access/policy_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["PolicyListParams"] class PolicyListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/zero_trust/access/policy_update_params.py b/src/cloudflare/types/zero_trust/access/policy_update_params.py index 57c3cd9cd3a..06268d2dcb3 100644 --- a/src/cloudflare/types/zero_trust/access/policy_update_params.py +++ b/src/cloudflare/types/zero_trust/access/policy_update_params.py @@ -13,7 +13,7 @@ class PolicyUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" decision: Required[Decision] diff --git a/src/cloudflare/types/zero_trust/access/service_token_rotate_params.py b/src/cloudflare/types/zero_trust/access/service_token_rotate_params.py index 2fb1017ea1a..cb1b7e25555 100644 --- a/src/cloudflare/types/zero_trust/access/service_token_rotate_params.py +++ b/src/cloudflare/types/zero_trust/access/service_token_rotate_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class ServiceTokenRotateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" previous_client_secret_expires_at: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/cloudflare/types/zero_trust/access/tag_create_params.py b/src/cloudflare/types/zero_trust/access/tag_create_params.py index 91785c49db9..a446d2652ea 100644 --- a/src/cloudflare/types/zero_trust/access/tag_create_params.py +++ b/src/cloudflare/types/zero_trust/access/tag_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["TagCreateParams"] class TagCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: str diff --git a/src/cloudflare/types/zero_trust/access/tag_list_params.py b/src/cloudflare/types/zero_trust/access/tag_list_params.py index 18e55a02101..931f00cd432 100644 --- a/src/cloudflare/types/zero_trust/access/tag_list_params.py +++ b/src/cloudflare/types/zero_trust/access/tag_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["TagListParams"] class TagListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" page: int diff --git a/src/cloudflare/types/zero_trust/access/tag_update_params.py b/src/cloudflare/types/zero_trust/access/tag_update_params.py index 0a939594f6d..6e1cfbcad82 100644 --- a/src/cloudflare/types/zero_trust/access/tag_update_params.py +++ b/src/cloudflare/types/zero_trust/access/tag_update_params.py @@ -8,7 +8,7 @@ class TagUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" name: Required[str] diff --git a/src/cloudflare/types/zero_trust/access/user_create_params.py b/src/cloudflare/types/zero_trust/access/user_create_params.py index dcbedcff9d8..683e9a484a4 100644 --- a/src/cloudflare/types/zero_trust/access/user_create_params.py +++ b/src/cloudflare/types/zero_trust/access/user_create_params.py @@ -8,7 +8,7 @@ class UserCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" email: Required[str] diff --git a/src/cloudflare/types/zero_trust/access/user_list_params.py b/src/cloudflare/types/zero_trust/access/user_list_params.py index 98afd06454a..32538d6b244 100644 --- a/src/cloudflare/types/zero_trust/access/user_list_params.py +++ b/src/cloudflare/types/zero_trust/access/user_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["UserListParams"] class UserListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" email: str diff --git a/src/cloudflare/types/zero_trust/access/user_update_params.py b/src/cloudflare/types/zero_trust/access/user_update_params.py index 8501df104cc..a8c79eea873 100644 --- a/src/cloudflare/types/zero_trust/access/user_update_params.py +++ b/src/cloudflare/types/zero_trust/access/user_update_params.py @@ -8,7 +8,7 @@ class UserUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" email: Required[str] diff --git a/src/cloudflare/types/zero_trust/connectivity_setting_edit_params.py b/src/cloudflare/types/zero_trust/connectivity_setting_edit_params.py index 22aee0433e8..78d77113210 100644 --- a/src/cloudflare/types/zero_trust/connectivity_setting_edit_params.py +++ b/src/cloudflare/types/zero_trust/connectivity_setting_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ConnectivitySettingEditParams"] class ConnectivitySettingEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" icmp_proxy_enabled: bool diff --git a/src/cloudflare/types/zero_trust/devices/device_get_params.py b/src/cloudflare/types/zero_trust/devices/device_get_params.py index c81fa9ea02e..c9711f4283a 100644 --- a/src/cloudflare/types/zero_trust/devices/device_get_params.py +++ b/src/cloudflare/types/zero_trust/devices/device_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DeviceGetParams"] class DeviceGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str include: str """ diff --git a/src/cloudflare/types/zero_trust/devices/device_list_params.py b/src/cloudflare/types/zero_trust/devices/device_list_params.py index 8e3b593f846..6691b995f29 100644 --- a/src/cloudflare/types/zero_trust/devices/device_list_params.py +++ b/src/cloudflare/types/zero_trust/devices/device_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ...._types import SequenceNotStr @@ -10,7 +10,7 @@ class DeviceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: SequenceNotStr[str] """Filter by a one or more device IDs.""" diff --git a/src/cloudflare/types/zero_trust/devices/dex_test_create_params.py b/src/cloudflare/types/zero_trust/devices/dex_test_create_params.py index 8cb648370a6..552dcdb3e2b 100644 --- a/src/cloudflare/types/zero_trust/devices/dex_test_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/dex_test_create_params.py @@ -9,7 +9,7 @@ class DEXTestCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str data: Required[Data] """ diff --git a/src/cloudflare/types/zero_trust/devices/dex_test_list_params.py b/src/cloudflare/types/zero_trust/devices/dex_test_list_params.py index 6a0abe911f6..8d970e815d5 100644 --- a/src/cloudflare/types/zero_trust/devices/dex_test_list_params.py +++ b/src/cloudflare/types/zero_trust/devices/dex_test_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ...._utils import PropertyInfo @@ -10,7 +10,7 @@ class DEXTestListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str kind: Literal["http", "traceroute"] """Filter by test type""" diff --git a/src/cloudflare/types/zero_trust/devices/dex_test_update_params.py b/src/cloudflare/types/zero_trust/devices/dex_test_update_params.py index 9f4c11b91f7..b9c272fc9c4 100644 --- a/src/cloudflare/types/zero_trust/devices/dex_test_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/dex_test_update_params.py @@ -9,7 +9,7 @@ class DEXTestUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str data: Required[Data] """ diff --git a/src/cloudflare/types/zero_trust/devices/fleet_status_get_params.py b/src/cloudflare/types/zero_trust/devices/fleet_status_get_params.py index 09a81b98c51..0150564db3f 100644 --- a/src/cloudflare/types/zero_trust/devices/fleet_status_get_params.py +++ b/src/cloudflare/types/zero_trust/devices/fleet_status_get_params.py @@ -8,7 +8,7 @@ class FleetStatusGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str since_minutes: Required[float] """Number of minutes before current time""" diff --git a/src/cloudflare/types/zero_trust/devices/ip_profile_create_params.py b/src/cloudflare/types/zero_trust/devices/ip_profile_create_params.py index 60ab6588144..420c2111746 100644 --- a/src/cloudflare/types/zero_trust/devices/ip_profile_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/ip_profile_create_params.py @@ -9,7 +9,7 @@ class IPProfileCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str match: Required[str] """The wirefilter expression to match registrations. diff --git a/src/cloudflare/types/zero_trust/devices/ip_profile_list_params.py b/src/cloudflare/types/zero_trust/devices/ip_profile_list_params.py index 184eba34c9b..91214396f60 100644 --- a/src/cloudflare/types/zero_trust/devices/ip_profile_list_params.py +++ b/src/cloudflare/types/zero_trust/devices/ip_profile_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["IPProfileListParams"] class IPProfileListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str per_page: int """The number of IP profiles to return per page.""" diff --git a/src/cloudflare/types/zero_trust/devices/ip_profile_update_params.py b/src/cloudflare/types/zero_trust/devices/ip_profile_update_params.py index 793212497f8..d948f84418e 100644 --- a/src/cloudflare/types/zero_trust/devices/ip_profile_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/ip_profile_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["IPProfileUpdateParams"] class IPProfileUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str description: str """An optional description of the Device IP profile.""" diff --git a/src/cloudflare/types/zero_trust/devices/kolide_input.py b/src/cloudflare/types/zero_trust/devices/kolide_input.py index a4ce2ef705f..a18da6e1fcc 100644 --- a/src/cloudflare/types/zero_trust/devices/kolide_input.py +++ b/src/cloudflare/types/zero_trust/devices/kolide_input.py @@ -1,5 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from typing import List, Optional from typing_extensions import Literal from pydantic import Field as FieldInfo @@ -13,8 +14,14 @@ class KolideInput(BaseModel): connection_id: str """Posture Integration ID.""" - count_operator: Literal["<", "<=", ">", ">=", "=="] = FieldInfo(alias="countOperator") + auth_state: Optional[List[Literal["Good", "Notified", "Will Block", "Blocked"]]] = None + """The set of Kolide device authentication states that pass the posture check. + + Device must match one of the specified states. + """ + + count_operator: Optional[Literal["<", "<=", ">", ">=", "=="]] = FieldInfo(alias="countOperator", default=None) """Count Operator.""" - issue_count: str + issue_count: Optional[str] = None """The Number of Issues.""" diff --git a/src/cloudflare/types/zero_trust/devices/kolide_input_param.py b/src/cloudflare/types/zero_trust/devices/kolide_input_param.py index 250cfc62c3a..85990a105bb 100644 --- a/src/cloudflare/types/zero_trust/devices/kolide_input_param.py +++ b/src/cloudflare/types/zero_trust/devices/kolide_input_param.py @@ -2,6 +2,7 @@ from __future__ import annotations +from typing import List from typing_extensions import Literal, Required, Annotated, TypedDict from ...._utils import PropertyInfo @@ -13,8 +14,14 @@ class KolideInputParam(TypedDict, total=False): connection_id: Required[str] """Posture Integration ID.""" - count_operator: Required[Annotated[Literal["<", "<=", ">", ">=", "=="], PropertyInfo(alias="countOperator")]] + auth_state: List[Literal["Good", "Notified", "Will Block", "Blocked"]] + """The set of Kolide device authentication states that pass the posture check. + + Device must match one of the specified states. + """ + + count_operator: Annotated[Literal["<", "<=", ">", ">=", "=="], PropertyInfo(alias="countOperator")] """Count Operator.""" - issue_count: Required[str] + issue_count: str """The Number of Issues.""" diff --git a/src/cloudflare/types/zero_trust/devices/network_create_params.py b/src/cloudflare/types/zero_trust/devices/network_create_params.py index 482bde1c2e7..fb82d096ee0 100644 --- a/src/cloudflare/types/zero_trust/devices/network_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/network_create_params.py @@ -8,7 +8,7 @@ class NetworkCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str config: Required[Config] """ diff --git a/src/cloudflare/types/zero_trust/devices/network_update_params.py b/src/cloudflare/types/zero_trust/devices/network_update_params.py index b85625ef578..bbbbc52ff21 100644 --- a/src/cloudflare/types/zero_trust/devices/network_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/network_update_params.py @@ -8,7 +8,7 @@ class NetworkUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str config: Config """ diff --git a/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_params.py index 3bdc54c4c9f..2db57a8cb1a 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_params.py @@ -11,6 +11,6 @@ class ExcludeUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[Iterable[SplitTunnelExcludeParam]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_params.py index 2c284e47aee..643d80dd6b4 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_params.py @@ -11,6 +11,6 @@ class FallbackDomainUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str domains: Required[Iterable[FallbackDomainParam]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/custom/include_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom/include_update_params.py index 6568d4ef985..771825e4380 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/custom/include_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/include_update_params.py @@ -11,6 +11,6 @@ class IncludeUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[Iterable[SplitTunnelIncludeParam]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/custom_create_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom_create_params.py index d2302201175..2d407e89019 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/custom_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom_create_params.py @@ -12,7 +12,7 @@ class CustomCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str match: Required[str] """The wirefilter expression to match devices. diff --git a/src/cloudflare/types/zero_trust/devices/policies/custom_edit_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom_edit_params.py index 85e7e19bd3c..05af477c3b8 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/custom_edit_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..split_tunnel_exclude_param import SplitTunnelExcludeParam from ..split_tunnel_include_param import SplitTunnelIncludeParam @@ -12,7 +12,7 @@ class CustomEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str allow_mode_switch: bool """Whether to allow the user to switch WARP between modes.""" diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_params.py b/src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_params.py index 5660da8891b..baa65057b57 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_params.py @@ -8,7 +8,7 @@ class CertificateEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str enabled: Required[bool] """ diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_params.py index 3bdc54c4c9f..2db57a8cb1a 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_params.py @@ -11,6 +11,6 @@ class ExcludeUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[Iterable[SplitTunnelExcludeParam]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_params.py index 2c284e47aee..643d80dd6b4 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_params.py @@ -11,6 +11,6 @@ class FallbackDomainUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str domains: Required[Iterable[FallbackDomainParam]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/include_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/default/include_update_params.py index 6568d4ef985..771825e4380 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/default/include_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/default/include_update_params.py @@ -11,6 +11,6 @@ class IncludeUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[Iterable[SplitTunnelIncludeParam]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default_edit_params.py b/src/cloudflare/types/zero_trust/devices/policies/default_edit_params.py index 9a6b533464c..9aab6b426e2 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/default_edit_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/default_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ..split_tunnel_exclude_param import SplitTunnelExcludeParam from ..split_tunnel_include_param import SplitTunnelIncludeParam @@ -12,7 +12,7 @@ class DefaultEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str allow_mode_switch: bool """Whether to allow the user to switch WARP between modes.""" diff --git a/src/cloudflare/types/zero_trust/devices/posture/integration_create_params.py b/src/cloudflare/types/zero_trust/devices/posture/integration_create_params.py index 00121f538be..c7fd4445570 100644 --- a/src/cloudflare/types/zero_trust/devices/posture/integration_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/posture/integration_create_params.py @@ -20,7 +20,7 @@ class IntegrationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str config: Required[Config] """The configuration object containing third-party integration information.""" diff --git a/src/cloudflare/types/zero_trust/devices/posture/integration_edit_params.py b/src/cloudflare/types/zero_trust/devices/posture/integration_edit_params.py index c23e0af1787..b9a0dca3cad 100644 --- a/src/cloudflare/types/zero_trust/devices/posture/integration_edit_params.py +++ b/src/cloudflare/types/zero_trust/devices/posture/integration_edit_params.py @@ -20,7 +20,7 @@ class IntegrationEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str config: Config """The configuration object containing third-party integration information.""" diff --git a/src/cloudflare/types/zero_trust/devices/posture_create_params.py b/src/cloudflare/types/zero_trust/devices/posture_create_params.py index 1d923fd3fac..24fd77b0c48 100644 --- a/src/cloudflare/types/zero_trust/devices/posture_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/posture_create_params.py @@ -12,7 +12,7 @@ class PostureCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] """The name of the device posture rule.""" diff --git a/src/cloudflare/types/zero_trust/devices/posture_update_params.py b/src/cloudflare/types/zero_trust/devices/posture_update_params.py index dbb5308e3a7..a1e477c7be3 100644 --- a/src/cloudflare/types/zero_trust/devices/posture_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/posture_update_params.py @@ -12,7 +12,7 @@ class PostureUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] """The name of the device posture rule.""" diff --git a/src/cloudflare/types/zero_trust/devices/registration_bulk_delete_params.py b/src/cloudflare/types/zero_trust/devices/registration_bulk_delete_params.py index bcca1ca09a6..39fbaeb052b 100644 --- a/src/cloudflare/types/zero_trust/devices/registration_bulk_delete_params.py +++ b/src/cloudflare/types/zero_trust/devices/registration_bulk_delete_params.py @@ -10,7 +10,7 @@ class RegistrationBulkDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: Required[SequenceNotStr[str]] """A list of registration IDs to delete.""" diff --git a/src/cloudflare/types/zero_trust/devices/registration_get_params.py b/src/cloudflare/types/zero_trust/devices/registration_get_params.py index fa02ad65420..9b7e47ef8e8 100644 --- a/src/cloudflare/types/zero_trust/devices/registration_get_params.py +++ b/src/cloudflare/types/zero_trust/devices/registration_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["RegistrationGetParams"] class RegistrationGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str include: str """ diff --git a/src/cloudflare/types/zero_trust/devices/registration_list_params.py b/src/cloudflare/types/zero_trust/devices/registration_list_params.py index a8cc4ebe404..8e729ac067e 100644 --- a/src/cloudflare/types/zero_trust/devices/registration_list_params.py +++ b/src/cloudflare/types/zero_trust/devices/registration_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ...._types import SequenceNotStr @@ -10,7 +10,7 @@ class RegistrationListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: SequenceNotStr[str] """Filter by registration ID.""" diff --git a/src/cloudflare/types/zero_trust/devices/registration_revoke_params.py b/src/cloudflare/types/zero_trust/devices/registration_revoke_params.py index 8f93798909d..bafa35f0dbf 100644 --- a/src/cloudflare/types/zero_trust/devices/registration_revoke_params.py +++ b/src/cloudflare/types/zero_trust/devices/registration_revoke_params.py @@ -10,7 +10,7 @@ class RegistrationRevokeParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: Required[SequenceNotStr[str]] """A list of registration IDs to revoke.""" diff --git a/src/cloudflare/types/zero_trust/devices/registration_unrevoke_params.py b/src/cloudflare/types/zero_trust/devices/registration_unrevoke_params.py index d94490cb4b6..0e40f547f39 100644 --- a/src/cloudflare/types/zero_trust/devices/registration_unrevoke_params.py +++ b/src/cloudflare/types/zero_trust/devices/registration_unrevoke_params.py @@ -10,7 +10,7 @@ class RegistrationUnrevokeParams(TypedDict, total=False): - account_id: Required[str] + account_id: str id: Required[SequenceNotStr[str]] """A list of registration IDs to unrevoke.""" diff --git a/src/cloudflare/types/zero_trust/devices/resilience/global_warp_override_create_params.py b/src/cloudflare/types/zero_trust/devices/resilience/global_warp_override_create_params.py index 362f206b71e..c0100344a90 100644 --- a/src/cloudflare/types/zero_trust/devices/resilience/global_warp_override_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/resilience/global_warp_override_create_params.py @@ -8,7 +8,7 @@ class GlobalWARPOverrideCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str disconnect: Required[bool] """Disconnects all devices on the account using Global WARP override.""" diff --git a/src/cloudflare/types/zero_trust/devices/revoke_create_params.py b/src/cloudflare/types/zero_trust/devices/revoke_create_params.py index c418c69dbd4..badc4356567 100644 --- a/src/cloudflare/types/zero_trust/devices/revoke_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/revoke_create_params.py @@ -10,7 +10,7 @@ class RevokeCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[SequenceNotStr[str]] """A list of Registration IDs to revoke.""" diff --git a/src/cloudflare/types/zero_trust/devices/setting_edit_params.py b/src/cloudflare/types/zero_trust/devices/setting_edit_params.py index 2516e80cc9f..89a0af28640 100755 --- a/src/cloudflare/types/zero_trust/devices/setting_edit_params.py +++ b/src/cloudflare/types/zero_trust/devices/setting_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SettingEditParams"] class SettingEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str disable_for_time: float """ diff --git a/src/cloudflare/types/zero_trust/devices/setting_update_params.py b/src/cloudflare/types/zero_trust/devices/setting_update_params.py index 2cb606e33b5..f7d697d11be 100644 --- a/src/cloudflare/types/zero_trust/devices/setting_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/setting_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SettingUpdateParams"] class SettingUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str disable_for_time: float """ diff --git a/src/cloudflare/types/zero_trust/devices/unrevoke_create_params.py b/src/cloudflare/types/zero_trust/devices/unrevoke_create_params.py index bdb31360c3c..9eaf7df3f08 100644 --- a/src/cloudflare/types/zero_trust/devices/unrevoke_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/unrevoke_create_params.py @@ -10,7 +10,7 @@ class UnrevokeCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[SequenceNotStr[str]] """A list of Registration IDs to unrevoke.""" diff --git a/src/cloudflare/types/zero_trust/dex/colo_list_params.py b/src/cloudflare/types/zero_trust/dex/colo_list_params.py index c208fcae20f..2625ebb785b 100644 --- a/src/cloudflare/types/zero_trust/dex/colo_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/colo_list_params.py @@ -10,7 +10,7 @@ class ColoListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for connection period in ISO (RFC3339 - ISO 8601) format""" diff --git a/src/cloudflare/types/zero_trust/dex/command_create_params.py b/src/cloudflare/types/zero_trust/dex/command_create_params.py index a118d017e6d..39e3a1a5682 100644 --- a/src/cloudflare/types/zero_trust/dex/command_create_params.py +++ b/src/cloudflare/types/zero_trust/dex/command_create_params.py @@ -11,7 +11,7 @@ class CommandCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str commands: Required[Iterable[Command]] """List of device-level commands to execute""" diff --git a/src/cloudflare/types/zero_trust/dex/command_list_params.py b/src/cloudflare/types/zero_trust/dex/command_list_params.py index cbe58116f27..09735f0c677 100644 --- a/src/cloudflare/types/zero_trust/dex/command_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/command_list_params.py @@ -12,7 +12,7 @@ class CommandListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: Required[float] """Page number for pagination""" diff --git a/src/cloudflare/types/zero_trust/dex/commands/device_list_params.py b/src/cloudflare/types/zero_trust/dex/commands/device_list_params.py index 126d1a8cb20..f5e8326e9ee 100644 --- a/src/cloudflare/types/zero_trust/dex/commands/device_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/commands/device_list_params.py @@ -8,7 +8,7 @@ class DeviceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: Required[float] """Page number of paginated results""" diff --git a/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py b/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py index 2e4d8182f1b..48759bfa68c 100644 --- a/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py @@ -10,7 +10,7 @@ class DeviceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Time range beginning in ISO format""" diff --git a/src/cloudflare/types/zero_trust/dex/fleet_status_live_params.py b/src/cloudflare/types/zero_trust/dex/fleet_status_live_params.py index 3f30049cf2d..654db032d61 100644 --- a/src/cloudflare/types/zero_trust/dex/fleet_status_live_params.py +++ b/src/cloudflare/types/zero_trust/dex/fleet_status_live_params.py @@ -8,7 +8,7 @@ class FleetStatusLiveParams(TypedDict, total=False): - account_id: Required[str] + account_id: str since_minutes: Required[float] """Number of minutes before current time""" diff --git a/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py b/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py index 662cf4e307c..bb30c840f2e 100644 --- a/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py +++ b/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py @@ -10,7 +10,7 @@ class FleetStatusOverTimeParams(TypedDict, total=False): - account_id: Required[str] + account_id: str from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Time range beginning in ISO format""" diff --git a/src/cloudflare/types/zero_trust/dex/http_test_get_params.py b/src/cloudflare/types/zero_trust/dex/http_test_get_params.py index 0ebbb588734..00dd9312acc 100644 --- a/src/cloudflare/types/zero_trust/dex/http_test_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/http_test_get_params.py @@ -11,7 +11,7 @@ class HTTPTestGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for aggregate metrics in ISO ms""" diff --git a/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py b/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py index 393e611ad5e..210f0c728e7 100644 --- a/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py @@ -11,7 +11,7 @@ class PercentileGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for the query in ISO (RFC3339 - ISO 8601) format""" diff --git a/src/cloudflare/types/zero_trust/dex/rule_create_params.py b/src/cloudflare/types/zero_trust/dex/rule_create_params.py index db10c6a7be7..b5f8d24b83a 100644 --- a/src/cloudflare/types/zero_trust/dex/rule_create_params.py +++ b/src/cloudflare/types/zero_trust/dex/rule_create_params.py @@ -8,7 +8,7 @@ class RuleCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str match: Required[str] """The wirefilter expression to match.""" diff --git a/src/cloudflare/types/zero_trust/dex/rule_list_params.py b/src/cloudflare/types/zero_trust/dex/rule_list_params.py index f7a59482cd0..63acdee7e4b 100644 --- a/src/cloudflare/types/zero_trust/dex/rule_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/rule_list_params.py @@ -8,7 +8,7 @@ class RuleListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str page: Required[float] """Page number of paginated results""" diff --git a/src/cloudflare/types/zero_trust/dex/rule_update_params.py b/src/cloudflare/types/zero_trust/dex/rule_update_params.py index 4bafbd979b1..0f007cc4ba9 100644 --- a/src/cloudflare/types/zero_trust/dex/rule_update_params.py +++ b/src/cloudflare/types/zero_trust/dex/rule_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["RuleUpdateParams"] class RuleUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str description: str diff --git a/src/cloudflare/types/zero_trust/dex/test_list_params.py b/src/cloudflare/types/zero_trust/dex/test_list_params.py index eeadc12677d..765d40018da 100644 --- a/src/cloudflare/types/zero_trust/dex/test_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/test_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ...._types import SequenceNotStr from ...._utils import PropertyInfo @@ -11,7 +11,7 @@ class TestListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/tests/unique_device_list_params.py b/src/cloudflare/types/zero_trust/dex/tests/unique_device_list_params.py index 6aae8692406..cb9d339cd1d 100644 --- a/src/cloudflare/types/zero_trust/dex/tests/unique_device_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/tests/unique_device_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Annotated, TypedDict from ....._types import SequenceNotStr from ....._utils import PropertyInfo @@ -11,7 +11,7 @@ class UniqueDeviceListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str device_id: Annotated[SequenceNotStr[str], PropertyInfo(alias="deviceId")] """Optionally filter result stats to a specific device(s). diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py index 912f057de27..7b620a7f3b0 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py @@ -11,7 +11,7 @@ class TracerouteTestGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for aggregate metrics in ISO ms""" diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py index b6ffc3f49e0..b45a8088649 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py @@ -10,7 +10,7 @@ class TracerouteTestNetworkPathParams(TypedDict, total=False): - account_id: Required[str] + account_id: str device_id: Required[Annotated[str, PropertyInfo(alias="deviceId")]] """Device to filter tracroute result runs to""" diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py index 7c6a8511b34..aef8d037e5d 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py @@ -11,7 +11,7 @@ class TracerouteTestPercentilesParams(TypedDict, total=False): - account_id: Required[str] + account_id: str from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for the query in ISO (RFC3339 - ISO 8601) format""" diff --git a/src/cloudflare/types/zero_trust/dex/warp_change_event_get_params.py b/src/cloudflare/types/zero_trust/dex/warp_change_event_get_params.py index 33c691637a0..19c8db30c0a 100644 --- a/src/cloudflare/types/zero_trust/dex/warp_change_event_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/warp_change_event_get_params.py @@ -10,7 +10,7 @@ class WARPChangeEventGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for the query in ISO (RFC3339 - ISO 8601) format""" diff --git a/src/cloudflare/types/zero_trust/dlp/__init__.py b/src/cloudflare/types/zero_trust/dlp/__init__.py index fa6d87dbb47..d52a21d063b 100644 --- a/src/cloudflare/types/zero_trust/dlp/__init__.py +++ b/src/cloudflare/types/zero_trust/dlp/__init__.py @@ -4,6 +4,7 @@ from .dataset import Dataset as Dataset from .profile import Profile as Profile +from .dlp_settings import DLPSettings as DLPSettings from .dataset_array import DatasetArray as DatasetArray from .dataset_creation import DatasetCreation as DatasetCreation from .context_awareness import ContextAwareness as ContextAwareness @@ -14,10 +15,12 @@ from .entry_update_params import EntryUpdateParams as EntryUpdateParams from .limit_list_response import LimitListResponse as LimitListResponse from .profile_list_params import ProfileListParams as ProfileListParams +from .setting_edit_params import SettingEditParams as SettingEditParams from .dataset_create_params import DatasetCreateParams as DatasetCreateParams from .dataset_update_params import DatasetUpdateParams as DatasetUpdateParams from .entry_create_response import EntryCreateResponse as EntryCreateResponse from .entry_update_response import EntryUpdateResponse as EntryUpdateResponse +from .setting_update_params import SettingUpdateParams as SettingUpdateParams from .context_awareness_param import ContextAwarenessParam as ContextAwarenessParam from .pattern_validate_params import PatternValidateParams as PatternValidateParams from .payload_log_get_response import PayloadLogGetResponse as PayloadLogGetResponse diff --git a/src/cloudflare/types/zero_trust/dlp/dataset_create_params.py b/src/cloudflare/types/zero_trust/dlp/dataset_create_params.py index ebf338df37d..18aa16a47dc 100644 --- a/src/cloudflare/types/zero_trust/dlp/dataset_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/dataset_create_params.py @@ -9,7 +9,7 @@ class DatasetCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] diff --git a/src/cloudflare/types/zero_trust/dlp/dataset_update_params.py b/src/cloudflare/types/zero_trust/dlp/dataset_update_params.py index e372f053cc5..058af5acc78 100644 --- a/src/cloudflare/types/zero_trust/dlp/dataset_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/dataset_update_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DatasetUpdateParams"] class DatasetUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str case_sensitive: bool """Determines if the words should be matched in a case-sensitive manner. diff --git a/src/cloudflare/types/zero_trust/dlp/datasets/upload_edit_params.py b/src/cloudflare/types/zero_trust/dlp/datasets/upload_edit_params.py index d0dc07005e5..bb4e16f3e97 100644 --- a/src/cloudflare/types/zero_trust/dlp/datasets/upload_edit_params.py +++ b/src/cloudflare/types/zero_trust/dlp/datasets/upload_edit_params.py @@ -8,6 +8,6 @@ class UploadEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str dataset_id: Required[str] diff --git a/src/cloudflare/types/zero_trust/dlp/datasets/version_create_params.py b/src/cloudflare/types/zero_trust/dlp/datasets/version_create_params.py index f08ed008a8f..dba758785d2 100755 --- a/src/cloudflare/types/zero_trust/dlp/datasets/version_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/datasets/version_create_params.py @@ -9,7 +9,7 @@ class VersionCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str dataset_id: Required[str] diff --git a/src/cloudflare/types/zero_trust/dlp/datasets/versions/entry_create_params.py b/src/cloudflare/types/zero_trust/dlp/datasets/versions/entry_create_params.py index cee7c6bbd09..7c8194bf019 100755 --- a/src/cloudflare/types/zero_trust/dlp/datasets/versions/entry_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/datasets/versions/entry_create_params.py @@ -8,7 +8,7 @@ class EntryCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str dataset_id: Required[str] diff --git a/src/cloudflare/types/zero_trust/dlp/dlp_settings.py b/src/cloudflare/types/zero_trust/dlp/dlp_settings.py new file mode 100644 index 00000000000..0de8daedd93 --- /dev/null +++ b/src/cloudflare/types/zero_trust/dlp/dlp_settings.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["DLPSettings", "PayloadLogging"] + + +class PayloadLogging(BaseModel): + updated_at: datetime + + masking_level: Optional[Literal["full", "partial", "clear", "default"]] = None + """Masking level for payload logs. + + - `full`: The entire payload is masked. + - `partial`: Only partial payload content is masked. + - `clear`: No masking is applied to the payload content. + - `default`: DLP uses its default masking behavior. + """ + + public_key: Optional[str] = None + """Base64-encoded public key for encrypting payload logs. + + Null when payload logging is disabled. + """ + + +class DLPSettings(BaseModel): + """DLP account-level settings response.""" + + ai_context_analysis: bool + """Whether AI context analysis is enabled at the account level.""" + + ocr: bool + """Whether OCR is enabled at the account level.""" + + payload_logging: PayloadLogging diff --git a/src/cloudflare/types/zero_trust/dlp/email/account_mapping_create_params.py b/src/cloudflare/types/zero_trust/dlp/email/account_mapping_create_params.py index a45d1167bd9..456655f7a66 100644 --- a/src/cloudflare/types/zero_trust/dlp/email/account_mapping_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/email/account_mapping_create_params.py @@ -11,7 +11,7 @@ class AccountMappingCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str auth_requirements: Required[AuthRequirements] diff --git a/src/cloudflare/types/zero_trust/dlp/email/rule_bulk_edit_params.py b/src/cloudflare/types/zero_trust/dlp/email/rule_bulk_edit_params.py index bd76fa7aa29..fbc51160a5b 100644 --- a/src/cloudflare/types/zero_trust/dlp/email/rule_bulk_edit_params.py +++ b/src/cloudflare/types/zero_trust/dlp/email/rule_bulk_edit_params.py @@ -9,6 +9,6 @@ class RuleBulkEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str new_priorities: Required[Dict[str, int]] diff --git a/src/cloudflare/types/zero_trust/dlp/email/rule_create_params.py b/src/cloudflare/types/zero_trust/dlp/email/rule_create_params.py index 0da93ecb30f..6c569509382 100644 --- a/src/cloudflare/types/zero_trust/dlp/email/rule_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/email/rule_create_params.py @@ -11,7 +11,7 @@ class RuleCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str action: Required[Action] diff --git a/src/cloudflare/types/zero_trust/dlp/email/rule_update_params.py b/src/cloudflare/types/zero_trust/dlp/email/rule_update_params.py index 8f0da8d978b..8d1a76ee0f7 100644 --- a/src/cloudflare/types/zero_trust/dlp/email/rule_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/email/rule_update_params.py @@ -11,7 +11,7 @@ class RuleUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str action: Required[Action] diff --git a/src/cloudflare/types/zero_trust/dlp/entries/custom_create_params.py b/src/cloudflare/types/zero_trust/dlp/entries/custom_create_params.py index 8700d3d8469..ab4901f167f 100644 --- a/src/cloudflare/types/zero_trust/dlp/entries/custom_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/entries/custom_create_params.py @@ -11,7 +11,7 @@ class CustomCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str enabled: Required[bool] diff --git a/src/cloudflare/types/zero_trust/dlp/entries/custom_update_params.py b/src/cloudflare/types/zero_trust/dlp/entries/custom_update_params.py index c6e957d80d3..a6d618a292f 100644 --- a/src/cloudflare/types/zero_trust/dlp/entries/custom_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/entries/custom_update_params.py @@ -11,7 +11,7 @@ class CustomUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str enabled: Required[bool] diff --git a/src/cloudflare/types/zero_trust/dlp/entries/integration_create_params.py b/src/cloudflare/types/zero_trust/dlp/entries/integration_create_params.py index ad70062920b..8f7d5865400 100644 --- a/src/cloudflare/types/zero_trust/dlp/entries/integration_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/entries/integration_create_params.py @@ -9,7 +9,7 @@ class IntegrationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str enabled: Required[bool] diff --git a/src/cloudflare/types/zero_trust/dlp/entries/integration_update_params.py b/src/cloudflare/types/zero_trust/dlp/entries/integration_update_params.py index a17458b6ae0..39b842cbf36 100644 --- a/src/cloudflare/types/zero_trust/dlp/entries/integration_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/entries/integration_update_params.py @@ -8,6 +8,6 @@ class IntegrationUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str enabled: Required[bool] diff --git a/src/cloudflare/types/zero_trust/dlp/entries/predefined_create_params.py b/src/cloudflare/types/zero_trust/dlp/entries/predefined_create_params.py index 92446899f90..9d6921694bf 100644 --- a/src/cloudflare/types/zero_trust/dlp/entries/predefined_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/entries/predefined_create_params.py @@ -9,7 +9,7 @@ class PredefinedCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str enabled: Required[bool] diff --git a/src/cloudflare/types/zero_trust/dlp/entries/predefined_update_params.py b/src/cloudflare/types/zero_trust/dlp/entries/predefined_update_params.py index d38e07163d7..326e3c0e8d2 100644 --- a/src/cloudflare/types/zero_trust/dlp/entries/predefined_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/entries/predefined_update_params.py @@ -8,6 +8,6 @@ class PredefinedUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str enabled: Required[bool] diff --git a/src/cloudflare/types/zero_trust/dlp/entry_create_params.py b/src/cloudflare/types/zero_trust/dlp/entry_create_params.py index 6b6c3364021..afd25aa535a 100644 --- a/src/cloudflare/types/zero_trust/dlp/entry_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/entry_create_params.py @@ -11,7 +11,7 @@ class EntryCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str enabled: Required[bool] diff --git a/src/cloudflare/types/zero_trust/dlp/entry_update_params.py b/src/cloudflare/types/zero_trust/dlp/entry_update_params.py index 04a45767afe..69c57d42868 100644 --- a/src/cloudflare/types/zero_trust/dlp/entry_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/entry_update_params.py @@ -11,7 +11,7 @@ class Variant0(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] @@ -25,7 +25,7 @@ class Variant0(TypedDict, total=False): class Variant1(TypedDict, total=False): - account_id: Required[str] + account_id: str type: Required[Literal["predefined"]] @@ -33,7 +33,7 @@ class Variant1(TypedDict, total=False): class Variant2(TypedDict, total=False): - account_id: Required[str] + account_id: str type: Required[Literal["integration"]] diff --git a/src/cloudflare/types/zero_trust/dlp/pattern_validate_params.py b/src/cloudflare/types/zero_trust/dlp/pattern_validate_params.py index edd77e78e03..c2b4db8cb20 100644 --- a/src/cloudflare/types/zero_trust/dlp/pattern_validate_params.py +++ b/src/cloudflare/types/zero_trust/dlp/pattern_validate_params.py @@ -9,7 +9,7 @@ class PatternValidateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str regex: Required[str] diff --git a/src/cloudflare/types/zero_trust/dlp/payload_log_update_params.py b/src/cloudflare/types/zero_trust/dlp/payload_log_update_params.py index 03c7029235e..5f17c63f1eb 100644 --- a/src/cloudflare/types/zero_trust/dlp/payload_log_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/payload_log_update_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["PayloadLogUpdateParams"] class PayloadLogUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str masking_level: Literal["full", "partial", "clear", "default"] """Masking level for payload logs. diff --git a/src/cloudflare/types/zero_trust/dlp/profile_list_params.py b/src/cloudflare/types/zero_trust/dlp/profile_list_params.py index 861653b1128..afe648ac7ec 100755 --- a/src/cloudflare/types/zero_trust/dlp/profile_list_params.py +++ b/src/cloudflare/types/zero_trust/dlp/profile_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ProfileListParams"] class ProfileListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str all: bool """ diff --git a/src/cloudflare/types/zero_trust/dlp/profiles/custom_create_params.py b/src/cloudflare/types/zero_trust/dlp/profiles/custom_create_params.py index 72c03184d69..aefd0b83b30 100644 --- a/src/cloudflare/types/zero_trust/dlp/profiles/custom_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/profiles/custom_create_params.py @@ -20,7 +20,7 @@ class CustomCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] diff --git a/src/cloudflare/types/zero_trust/dlp/profiles/custom_update_params.py b/src/cloudflare/types/zero_trust/dlp/profiles/custom_update_params.py index a426c95bff5..a8a3c6bf523 100644 --- a/src/cloudflare/types/zero_trust/dlp/profiles/custom_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/profiles/custom_update_params.py @@ -20,7 +20,7 @@ class CustomUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] diff --git a/src/cloudflare/types/zero_trust/dlp/profiles/predefined_update_params.py b/src/cloudflare/types/zero_trust/dlp/profiles/predefined_update_params.py index 9b25d9eaef5..fbacb4fe569 100644 --- a/src/cloudflare/types/zero_trust/dlp/profiles/predefined_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/profiles/predefined_update_params.py @@ -11,7 +11,7 @@ class PredefinedUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str ai_context_enabled: bool diff --git a/src/cloudflare/types/zero_trust/dlp/setting_edit_params.py b/src/cloudflare/types/zero_trust/dlp/setting_edit_params.py new file mode 100644 index 00000000000..fb8e430a40a --- /dev/null +++ b/src/cloudflare/types/zero_trust/dlp/setting_edit_params.py @@ -0,0 +1,50 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, TypedDict + +__all__ = ["SettingEditParams", "PayloadLogging"] + + +class SettingEditParams(TypedDict, total=False): + account_id: str + + ai_context_analysis: Optional[bool] + """Whether AI context analysis is enabled at the account level.""" + + ocr: Optional[bool] + """Whether OCR is enabled at the account level.""" + + payload_logging: PayloadLogging + """ + Request model for payload log settings within the DLP settings endpoint. Unlike + the legacy endpoint, null and missing are treated identically here (both mean + "not provided" for PATCH, "reset to default" for PUT). + """ + + +class PayloadLogging(TypedDict, total=False): + """ + Request model for payload log settings within the DLP settings endpoint. + Unlike the legacy endpoint, null and missing are treated identically here + (both mean "not provided" for PATCH, "reset to default" for PUT). + """ + + masking_level: Literal["full", "partial", "clear", "default"] + """Masking level for payload logs. + + - `full`: The entire payload is masked. + - `partial`: Only partial payload content is masked. + - `clear`: No masking is applied to the payload content. + - `default`: DLP uses its default masking behavior. + """ + + public_key: Optional[str] + """Base64-encoded public key for encrypting payload logs. + + - Set to a non-empty base64 string to enable payload logging with the given key. + - Set to an empty string to disable payload logging. + - Omit or set to null to leave unchanged (PATCH) or reset to disabled (PUT). + """ diff --git a/src/cloudflare/types/zero_trust/dlp/setting_update_params.py b/src/cloudflare/types/zero_trust/dlp/setting_update_params.py new file mode 100644 index 00000000000..4ebe720f0cb --- /dev/null +++ b/src/cloudflare/types/zero_trust/dlp/setting_update_params.py @@ -0,0 +1,50 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, TypedDict + +__all__ = ["SettingUpdateParams", "PayloadLogging"] + + +class SettingUpdateParams(TypedDict, total=False): + account_id: str + + ai_context_analysis: Optional[bool] + """Whether AI context analysis is enabled at the account level.""" + + ocr: Optional[bool] + """Whether OCR is enabled at the account level.""" + + payload_logging: PayloadLogging + """ + Request model for payload log settings within the DLP settings endpoint. Unlike + the legacy endpoint, null and missing are treated identically here (both mean + "not provided" for PATCH, "reset to default" for PUT). + """ + + +class PayloadLogging(TypedDict, total=False): + """ + Request model for payload log settings within the DLP settings endpoint. + Unlike the legacy endpoint, null and missing are treated identically here + (both mean "not provided" for PATCH, "reset to default" for PUT). + """ + + masking_level: Literal["full", "partial", "clear", "default"] + """Masking level for payload logs. + + - `full`: The entire payload is masked. + - `partial`: Only partial payload content is masked. + - `clear`: No masking is applied to the payload content. + - `default`: DLP uses its default masking behavior. + """ + + public_key: Optional[str] + """Base64-encoded public key for encrypting payload logs. + + - Set to a non-empty base64 string to enable payload logging with the given key. + - Set to an empty string to disable payload logging. + - Omit or set to null to leave unchanged (PATCH) or reset to disabled (PUT). + """ diff --git a/src/cloudflare/types/zero_trust/gateway/audit_ssh_setting_update_params.py b/src/cloudflare/types/zero_trust/gateway/audit_ssh_setting_update_params.py index 2cf5b52ec81..865a8563fcf 100644 --- a/src/cloudflare/types/zero_trust/gateway/audit_ssh_setting_update_params.py +++ b/src/cloudflare/types/zero_trust/gateway/audit_ssh_setting_update_params.py @@ -8,7 +8,7 @@ class AuditSSHSettingUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str public_key: Required[str] """Provide the Base64-encoded HPKE public key that encrypts SSH session logs. diff --git a/src/cloudflare/types/zero_trust/gateway/certificate_activate_params.py b/src/cloudflare/types/zero_trust/gateway/certificate_activate_params.py index a3b1cfe0f98..92b93714483 100644 --- a/src/cloudflare/types/zero_trust/gateway/certificate_activate_params.py +++ b/src/cloudflare/types/zero_trust/gateway/certificate_activate_params.py @@ -8,6 +8,6 @@ class CertificateActivateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[object] diff --git a/src/cloudflare/types/zero_trust/gateway/certificate_create_params.py b/src/cloudflare/types/zero_trust/gateway/certificate_create_params.py index b88ce811bc9..d7e6e663dac 100644 --- a/src/cloudflare/types/zero_trust/gateway/certificate_create_params.py +++ b/src/cloudflare/types/zero_trust/gateway/certificate_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CertificateCreateParams"] class CertificateCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str validity_period_days: int """Sets the certificate validity period in days (range: 1-10,950 days / ~30 years). diff --git a/src/cloudflare/types/zero_trust/gateway/certificate_deactivate_params.py b/src/cloudflare/types/zero_trust/gateway/certificate_deactivate_params.py index c938aee6c9b..473d3572a43 100644 --- a/src/cloudflare/types/zero_trust/gateway/certificate_deactivate_params.py +++ b/src/cloudflare/types/zero_trust/gateway/certificate_deactivate_params.py @@ -8,6 +8,6 @@ class CertificateDeactivateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str body: Required[object] diff --git a/src/cloudflare/types/zero_trust/gateway/configuration_edit_params.py b/src/cloudflare/types/zero_trust/gateway/configuration_edit_params.py index a0c4d70d7aa..f97e59958d3 100644 --- a/src/cloudflare/types/zero_trust/gateway/configuration_edit_params.py +++ b/src/cloudflare/types/zero_trust/gateway/configuration_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from .gateway_configuration_settings_param import GatewayConfigurationSettingsParam @@ -10,7 +10,7 @@ class ConfigurationEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str settings: GatewayConfigurationSettingsParam """Specify account settings.""" diff --git a/src/cloudflare/types/zero_trust/gateway/configuration_update_params.py b/src/cloudflare/types/zero_trust/gateway/configuration_update_params.py index 8c3f25cf55e..21d12f7c7d0 100644 --- a/src/cloudflare/types/zero_trust/gateway/configuration_update_params.py +++ b/src/cloudflare/types/zero_trust/gateway/configuration_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from .gateway_configuration_settings_param import GatewayConfigurationSettingsParam @@ -10,7 +10,7 @@ class ConfigurationUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str settings: GatewayConfigurationSettingsParam """Specify account settings.""" diff --git a/src/cloudflare/types/zero_trust/gateway/list_create_params.py b/src/cloudflare/types/zero_trust/gateway/list_create_params.py index 10c5bcf8675..aee65050a6b 100644 --- a/src/cloudflare/types/zero_trust/gateway/list_create_params.py +++ b/src/cloudflare/types/zero_trust/gateway/list_create_params.py @@ -9,7 +9,7 @@ class ListCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] """Specify the list name.""" diff --git a/src/cloudflare/types/zero_trust/gateway/list_edit_params.py b/src/cloudflare/types/zero_trust/gateway/list_edit_params.py index 7a5444a78cb..aebac4e6132 100644 --- a/src/cloudflare/types/zero_trust/gateway/list_edit_params.py +++ b/src/cloudflare/types/zero_trust/gateway/list_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ...._types import SequenceNotStr @@ -11,7 +11,7 @@ class ListEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str append: Iterable[Append] """Add items to the list.""" diff --git a/src/cloudflare/types/zero_trust/gateway/list_list_params.py b/src/cloudflare/types/zero_trust/gateway/list_list_params.py index c16707c6ffd..5d15d3a75fe 100644 --- a/src/cloudflare/types/zero_trust/gateway/list_list_params.py +++ b/src/cloudflare/types/zero_trust/gateway/list_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["ListListParams"] class ListListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str type: Literal["SERIAL", "URL", "DOMAIN", "EMAIL", "IP", "CATEGORY", "LOCATION", "DEVICE"] """Specify the list type.""" diff --git a/src/cloudflare/types/zero_trust/gateway/list_update_params.py b/src/cloudflare/types/zero_trust/gateway/list_update_params.py index bcca5a2f5fe..5557340be66 100644 --- a/src/cloudflare/types/zero_trust/gateway/list_update_params.py +++ b/src/cloudflare/types/zero_trust/gateway/list_update_params.py @@ -9,7 +9,7 @@ class ListUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] """Specify the list name.""" diff --git a/src/cloudflare/types/zero_trust/gateway/location_create_params.py b/src/cloudflare/types/zero_trust/gateway/location_create_params.py index f20f9f2845a..d3e9f47d878 100644 --- a/src/cloudflare/types/zero_trust/gateway/location_create_params.py +++ b/src/cloudflare/types/zero_trust/gateway/location_create_params.py @@ -11,7 +11,7 @@ class LocationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] """Specify the location name.""" diff --git a/src/cloudflare/types/zero_trust/gateway/location_update_params.py b/src/cloudflare/types/zero_trust/gateway/location_update_params.py index b374d0096a0..6acbf843af8 100644 --- a/src/cloudflare/types/zero_trust/gateway/location_update_params.py +++ b/src/cloudflare/types/zero_trust/gateway/location_update_params.py @@ -11,7 +11,7 @@ class LocationUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] """Specify the location name.""" diff --git a/src/cloudflare/types/zero_trust/gateway/logging_update_params.py b/src/cloudflare/types/zero_trust/gateway/logging_update_params.py index 9adfdbf29e4..cb25a1ccd5f 100644 --- a/src/cloudflare/types/zero_trust/gateway/logging_update_params.py +++ b/src/cloudflare/types/zero_trust/gateway/logging_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = [ "LoggingUpdateParams", @@ -14,7 +14,7 @@ class LoggingUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str redact_pii: bool """ diff --git a/src/cloudflare/types/zero_trust/gateway/pacfile_create_params.py b/src/cloudflare/types/zero_trust/gateway/pacfile_create_params.py index e37e43b96b1..929bada1461 100644 --- a/src/cloudflare/types/zero_trust/gateway/pacfile_create_params.py +++ b/src/cloudflare/types/zero_trust/gateway/pacfile_create_params.py @@ -8,7 +8,7 @@ class PacfileCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str contents: Required[str] """Actual contents of the PAC file""" diff --git a/src/cloudflare/types/zero_trust/gateway/pacfile_update_params.py b/src/cloudflare/types/zero_trust/gateway/pacfile_update_params.py index 60f44fe4a85..61ec547ed7c 100644 --- a/src/cloudflare/types/zero_trust/gateway/pacfile_update_params.py +++ b/src/cloudflare/types/zero_trust/gateway/pacfile_update_params.py @@ -8,7 +8,7 @@ class PacfileUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str contents: Required[str] """Actual contents of the PAC file""" diff --git a/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_create_params.py b/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_create_params.py index 344ef9e7c9c..beb9a69ec02 100644 --- a/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_create_params.py +++ b/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_create_params.py @@ -13,7 +13,7 @@ class ZeroTrustGatewayProxyEndpointIPCreate(TypedDict, total=False): - account_id: Required[str] + account_id: str name: Required[str] """Specify the name of the proxy endpoint.""" @@ -23,7 +23,7 @@ class ZeroTrustGatewayProxyEndpointIPCreate(TypedDict, total=False): class ZeroTrustGatewayProxyEndpointIdentityCreate(TypedDict, total=False): - account_id: Required[str] + account_id: str kind: Required[Literal["identity"]] """The proxy endpoint kind""" diff --git a/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_edit_params.py b/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_edit_params.py index b986f7f9480..1225cd9f3ab 100644 --- a/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_edit_params.py +++ b/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict from ...._types import SequenceNotStr from .gateway_ips import GatewayIPs @@ -11,7 +11,7 @@ class ProxyEndpointEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str ips: SequenceNotStr[GatewayIPs] """Specify the list of CIDRs to restrict ingress connections.""" diff --git a/src/cloudflare/types/zero_trust/gateway/rule_create_params.py b/src/cloudflare/types/zero_trust/gateway/rule_create_params.py index f3bf649d539..a249c58ce57 100644 --- a/src/cloudflare/types/zero_trust/gateway/rule_create_params.py +++ b/src/cloudflare/types/zero_trust/gateway/rule_create_params.py @@ -15,7 +15,7 @@ class RuleCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str action: Required[ Literal[ diff --git a/src/cloudflare/types/zero_trust/gateway/rule_update_params.py b/src/cloudflare/types/zero_trust/gateway/rule_update_params.py index cb1c5873581..bc9e2086650 100644 --- a/src/cloudflare/types/zero_trust/gateway/rule_update_params.py +++ b/src/cloudflare/types/zero_trust/gateway/rule_update_params.py @@ -15,7 +15,7 @@ class RuleUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str action: Required[ Literal[ diff --git a/src/cloudflare/types/zero_trust/identity_providers/scim/group_list_params.py b/src/cloudflare/types/zero_trust/identity_providers/scim/group_list_params.py index c94b4b175b1..4a7068c50f1 100644 --- a/src/cloudflare/types/zero_trust/identity_providers/scim/group_list_params.py +++ b/src/cloudflare/types/zero_trust/identity_providers/scim/group_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["GroupListParams"] class GroupListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" cf_resource_id: str diff --git a/src/cloudflare/types/zero_trust/identity_providers/scim/user_list_params.py b/src/cloudflare/types/zero_trust/identity_providers/scim/user_list_params.py index 6ce2445eec1..77efd5bcb06 100644 --- a/src/cloudflare/types/zero_trust/identity_providers/scim/user_list_params.py +++ b/src/cloudflare/types/zero_trust/identity_providers/scim/user_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["UserListParams"] class UserListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" cf_resource_id: str diff --git a/src/cloudflare/types/zero_trust/networks/hostname_route_create_params.py b/src/cloudflare/types/zero_trust/networks/hostname_route_create_params.py index cf16e4aef75..376549012c0 100644 --- a/src/cloudflare/types/zero_trust/networks/hostname_route_create_params.py +++ b/src/cloudflare/types/zero_trust/networks/hostname_route_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HostnameRouteCreateParams"] class HostnameRouteCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" comment: str diff --git a/src/cloudflare/types/zero_trust/networks/hostname_route_edit_params.py b/src/cloudflare/types/zero_trust/networks/hostname_route_edit_params.py index 1429767026a..bdd47d98291 100644 --- a/src/cloudflare/types/zero_trust/networks/hostname_route_edit_params.py +++ b/src/cloudflare/types/zero_trust/networks/hostname_route_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HostnameRouteEditParams"] class HostnameRouteEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" comment: str diff --git a/src/cloudflare/types/zero_trust/networks/hostname_route_list_params.py b/src/cloudflare/types/zero_trust/networks/hostname_route_list_params.py index cda69373764..34d5a5c09ee 100644 --- a/src/cloudflare/types/zero_trust/networks/hostname_route_list_params.py +++ b/src/cloudflare/types/zero_trust/networks/hostname_route_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HostnameRouteListParams"] class HostnameRouteListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" id: str diff --git a/src/cloudflare/types/zero_trust/networks/route_create_params.py b/src/cloudflare/types/zero_trust/networks/route_create_params.py index 635da63698f..aa74c4ec181 100644 --- a/src/cloudflare/types/zero_trust/networks/route_create_params.py +++ b/src/cloudflare/types/zero_trust/networks/route_create_params.py @@ -8,7 +8,7 @@ class RouteCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" network: Required[str] diff --git a/src/cloudflare/types/zero_trust/networks/route_edit_params.py b/src/cloudflare/types/zero_trust/networks/route_edit_params.py index 5d0a383e5f0..266bea9a463 100644 --- a/src/cloudflare/types/zero_trust/networks/route_edit_params.py +++ b/src/cloudflare/types/zero_trust/networks/route_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["RouteEditParams"] class RouteEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" comment: str diff --git a/src/cloudflare/types/zero_trust/networks/route_list_params.py b/src/cloudflare/types/zero_trust/networks/route_list_params.py index 3d1b86f0b2c..1496ed784fa 100644 --- a/src/cloudflare/types/zero_trust/networks/route_list_params.py +++ b/src/cloudflare/types/zero_trust/networks/route_list_params.py @@ -3,13 +3,13 @@ from __future__ import annotations from typing import List -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["RouteListParams"] class RouteListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" comment: str diff --git a/src/cloudflare/types/zero_trust/networks/routes/ip_get_params.py b/src/cloudflare/types/zero_trust/networks/routes/ip_get_params.py index b2b941639c2..4269be34d5f 100644 --- a/src/cloudflare/types/zero_trust/networks/routes/ip_get_params.py +++ b/src/cloudflare/types/zero_trust/networks/routes/ip_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["IPGetParams"] class IPGetParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" default_virtual_network_fallback: bool diff --git a/src/cloudflare/types/zero_trust/networks/routes/network_create_params.py b/src/cloudflare/types/zero_trust/networks/routes/network_create_params.py index f33811b5e5e..41bd04a5b18 100644 --- a/src/cloudflare/types/zero_trust/networks/routes/network_create_params.py +++ b/src/cloudflare/types/zero_trust/networks/routes/network_create_params.py @@ -8,7 +8,7 @@ class NetworkCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" tunnel_id: Required[str] diff --git a/src/cloudflare/types/zero_trust/networks/routes/network_delete_params.py b/src/cloudflare/types/zero_trust/networks/routes/network_delete_params.py index c99764abdd3..f2a45de26be 100644 --- a/src/cloudflare/types/zero_trust/networks/routes/network_delete_params.py +++ b/src/cloudflare/types/zero_trust/networks/routes/network_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["NetworkDeleteParams"] class NetworkDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" tun_type: Literal["cfd_tunnel", "warp_connector", "warp", "magic", "ip_sec", "gre", "cni"] diff --git a/src/cloudflare/types/zero_trust/networks/subnet_list_params.py b/src/cloudflare/types/zero_trust/networks/subnet_list_params.py index ef5475b16ad..929fbd30c21 100644 --- a/src/cloudflare/types/zero_trust/networks/subnet_list_params.py +++ b/src/cloudflare/types/zero_trust/networks/subnet_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = ["SubnetListParams"] class SubnetListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" address_family: Literal["v4", "v6"] diff --git a/src/cloudflare/types/zero_trust/networks/subnets/cloudflare_source_update_params.py b/src/cloudflare/types/zero_trust/networks/subnets/cloudflare_source_update_params.py index a45818011ea..08ec75be53b 100644 --- a/src/cloudflare/types/zero_trust/networks/subnets/cloudflare_source_update_params.py +++ b/src/cloudflare/types/zero_trust/networks/subnets/cloudflare_source_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CloudflareSourceUpdateParams"] class CloudflareSourceUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" comment: str diff --git a/src/cloudflare/types/zero_trust/networks/subnets/warp_create_params.py b/src/cloudflare/types/zero_trust/networks/subnets/warp_create_params.py index e9ea45f0951..d8cf3dbb8ec 100644 --- a/src/cloudflare/types/zero_trust/networks/subnets/warp_create_params.py +++ b/src/cloudflare/types/zero_trust/networks/subnets/warp_create_params.py @@ -8,7 +8,7 @@ class WARPCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" name: Required[str] diff --git a/src/cloudflare/types/zero_trust/networks/subnets/warp_edit_params.py b/src/cloudflare/types/zero_trust/networks/subnets/warp_edit_params.py index d38b538fda5..0e94244cfcd 100644 --- a/src/cloudflare/types/zero_trust/networks/subnets/warp_edit_params.py +++ b/src/cloudflare/types/zero_trust/networks/subnets/warp_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["WARPEditParams"] class WARPEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" comment: str diff --git a/src/cloudflare/types/zero_trust/networks/virtual_network_create_params.py b/src/cloudflare/types/zero_trust/networks/virtual_network_create_params.py index 2ffa581aed1..22a5a599c90 100644 --- a/src/cloudflare/types/zero_trust/networks/virtual_network_create_params.py +++ b/src/cloudflare/types/zero_trust/networks/virtual_network_create_params.py @@ -8,7 +8,7 @@ class VirtualNetworkCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" name: Required[str] diff --git a/src/cloudflare/types/zero_trust/networks/virtual_network_edit_params.py b/src/cloudflare/types/zero_trust/networks/virtual_network_edit_params.py index 920ec9b111f..340ae7ae2e0 100644 --- a/src/cloudflare/types/zero_trust/networks/virtual_network_edit_params.py +++ b/src/cloudflare/types/zero_trust/networks/virtual_network_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["VirtualNetworkEditParams"] class VirtualNetworkEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" comment: str diff --git a/src/cloudflare/types/zero_trust/networks/virtual_network_list_params.py b/src/cloudflare/types/zero_trust/networks/virtual_network_list_params.py index 116077ae8be..8de49750c34 100644 --- a/src/cloudflare/types/zero_trust/networks/virtual_network_list_params.py +++ b/src/cloudflare/types/zero_trust/networks/virtual_network_list_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["VirtualNetworkListParams"] class VirtualNetworkListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" id: str diff --git a/src/cloudflare/types/zero_trust/organizations/doh_update_params.py b/src/cloudflare/types/zero_trust/organizations/doh_update_params.py index 4bb1bb7a67a..85c122f487c 100644 --- a/src/cloudflare/types/zero_trust/organizations/doh_update_params.py +++ b/src/cloudflare/types/zero_trust/organizations/doh_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["DOHUpdateParams"] class DOHUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" doh_jwt_duration: str diff --git a/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py index 6caa1e31244..0213b5a1666 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py @@ -9,7 +9,7 @@ class BehaviourUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str behaviors: Required[Dict[str, Behaviors]] diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_create_params.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_create_params.py index e572a4b3ed1..08a921cbdee 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/integration_create_params.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_create_params.py @@ -9,7 +9,7 @@ class IntegrationCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str integration_type: Required[Literal["Okta"]] diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_update_params.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_update_params.py index 44bcbbc8308..237270137a5 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/integration_update_params.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_update_params.py @@ -9,7 +9,7 @@ class IntegrationUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str active: Required[bool] """Whether this integration is enabled. diff --git a/src/cloudflare/types/zero_trust/seat_edit_params.py b/src/cloudflare/types/zero_trust/seat_edit_params.py index 34e26899551..fcb033e9699 100644 --- a/src/cloudflare/types/zero_trust/seat_edit_params.py +++ b/src/cloudflare/types/zero_trust/seat_edit_params.py @@ -9,7 +9,7 @@ class SeatEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" body: Required[Iterable[Body]] diff --git a/src/cloudflare/types/zero_trust/tunnel_list_params.py b/src/cloudflare/types/zero_trust/tunnel_list_params.py index cd805857059..addfa62a7ca 100644 --- a/src/cloudflare/types/zero_trust/tunnel_list_params.py +++ b/src/cloudflare/types/zero_trust/tunnel_list_params.py @@ -4,7 +4,7 @@ from typing import List, Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ..._utils import PropertyInfo @@ -12,7 +12,7 @@ class TunnelListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" exclude_prefix: str diff --git a/src/cloudflare/types/zero_trust/tunnels/cloudflared/configuration_update_params.py b/src/cloudflare/types/zero_trust/tunnels/cloudflared/configuration_update_params.py index a1a79a2a334..176a8de8072 100644 --- a/src/cloudflare/types/zero_trust/tunnels/cloudflared/configuration_update_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/cloudflared/configuration_update_params.py @@ -20,7 +20,7 @@ class ConfigurationUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Identifier.""" config: Config diff --git a/src/cloudflare/types/zero_trust/tunnels/cloudflared/connection_delete_params.py b/src/cloudflare/types/zero_trust/tunnels/cloudflared/connection_delete_params.py index b40d7b56a22..23a8d63f5cf 100644 --- a/src/cloudflare/types/zero_trust/tunnels/cloudflared/connection_delete_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/cloudflared/connection_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["ConnectionDeleteParams"] class ConnectionDeleteParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" client_id: str diff --git a/src/cloudflare/types/zero_trust/tunnels/cloudflared/management_create_params.py b/src/cloudflare/types/zero_trust/tunnels/cloudflared/management_create_params.py index b151c2b8600..9d2105f01bd 100644 --- a/src/cloudflare/types/zero_trust/tunnels/cloudflared/management_create_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/cloudflared/management_create_params.py @@ -9,7 +9,7 @@ class ManagementCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" resources: Required[List[Literal["logs"]]] diff --git a/src/cloudflare/types/zero_trust/tunnels/cloudflared_create_params.py b/src/cloudflare/types/zero_trust/tunnels/cloudflared_create_params.py index 6e77f7c3e75..d4df6ef4d79 100644 --- a/src/cloudflare/types/zero_trust/tunnels/cloudflared_create_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/cloudflared_create_params.py @@ -8,7 +8,7 @@ class CloudflaredCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" name: Required[str] diff --git a/src/cloudflare/types/zero_trust/tunnels/cloudflared_edit_params.py b/src/cloudflare/types/zero_trust/tunnels/cloudflared_edit_params.py index ba11c0c1235..d6cbc6977f3 100644 --- a/src/cloudflare/types/zero_trust/tunnels/cloudflared_edit_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/cloudflared_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CloudflaredEditParams"] class CloudflaredEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" name: str diff --git a/src/cloudflare/types/zero_trust/tunnels/cloudflared_list_params.py b/src/cloudflare/types/zero_trust/tunnels/cloudflared_list_params.py index cd8091795f0..c0d8ca2a75d 100644 --- a/src/cloudflare/types/zero_trust/tunnels/cloudflared_list_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/cloudflared_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class CloudflaredListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" exclude_prefix: str diff --git a/src/cloudflare/types/zero_trust/tunnels/warp_connector/failover_update_params.py b/src/cloudflare/types/zero_trust/tunnels/warp_connector/failover_update_params.py index 64f182eae95..a363d9c39de 100644 --- a/src/cloudflare/types/zero_trust/tunnels/warp_connector/failover_update_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/warp_connector/failover_update_params.py @@ -8,7 +8,7 @@ class FailoverUpdateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" client_id: Required[str] diff --git a/src/cloudflare/types/zero_trust/tunnels/warp_connector_create_params.py b/src/cloudflare/types/zero_trust/tunnels/warp_connector_create_params.py index ec86583c773..5cd53c0bfac 100644 --- a/src/cloudflare/types/zero_trust/tunnels/warp_connector_create_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/warp_connector_create_params.py @@ -8,7 +8,7 @@ class WARPConnectorCreateParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" name: Required[str] diff --git a/src/cloudflare/types/zero_trust/tunnels/warp_connector_edit_params.py b/src/cloudflare/types/zero_trust/tunnels/warp_connector_edit_params.py index 86d2f3b97b9..6035605ceec 100644 --- a/src/cloudflare/types/zero_trust/tunnels/warp_connector_edit_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/warp_connector_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["WARPConnectorEditParams"] class WARPConnectorEditParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" name: str diff --git a/src/cloudflare/types/zero_trust/tunnels/warp_connector_list_params.py b/src/cloudflare/types/zero_trust/tunnels/warp_connector_list_params.py index a3b8aa866a9..b981f14fd69 100644 --- a/src/cloudflare/types/zero_trust/tunnels/warp_connector_list_params.py +++ b/src/cloudflare/types/zero_trust/tunnels/warp_connector_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Annotated, TypedDict from ...._utils import PropertyInfo @@ -12,7 +12,7 @@ class WARPConnectorListParams(TypedDict, total=False): - account_id: Required[str] + account_id: str """Cloudflare account ID""" exclude_prefix: str diff --git a/src/cloudflare/types/zones/custom_nameserver_update_params.py b/src/cloudflare/types/zones/custom_nameserver_update_params.py index 0bf2a635c70..8e558982ef8 100644 --- a/src/cloudflare/types/zones/custom_nameserver_update_params.py +++ b/src/cloudflare/types/zones/custom_nameserver_update_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["CustomNameserverUpdateParams"] class CustomNameserverUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" enabled: bool diff --git a/src/cloudflare/types/zones/environment_create_params.py b/src/cloudflare/types/zones/environment_create_params.py index ea384561f63..3400dfb8834 100644 --- a/src/cloudflare/types/zones/environment_create_params.py +++ b/src/cloudflare/types/zones/environment_create_params.py @@ -11,7 +11,7 @@ class EnvironmentCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str environments: Required[Iterable[Environment]] diff --git a/src/cloudflare/types/zones/environment_edit_params.py b/src/cloudflare/types/zones/environment_edit_params.py index 54aa7ffa214..5660d0e26f5 100644 --- a/src/cloudflare/types/zones/environment_edit_params.py +++ b/src/cloudflare/types/zones/environment_edit_params.py @@ -11,7 +11,7 @@ class EnvironmentEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str environments: Required[Iterable[Environment]] diff --git a/src/cloudflare/types/zones/environment_update_params.py b/src/cloudflare/types/zones/environment_update_params.py index 7cb409fe6f8..98e07ac3176 100644 --- a/src/cloudflare/types/zones/environment_update_params.py +++ b/src/cloudflare/types/zones/environment_update_params.py @@ -11,7 +11,7 @@ class EnvironmentUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str environments: Required[Iterable[Environment]] diff --git a/src/cloudflare/types/zones/hold_create_params.py b/src/cloudflare/types/zones/hold_create_params.py index addb06f3ca2..ace239a7696 100644 --- a/src/cloudflare/types/zones/hold_create_params.py +++ b/src/cloudflare/types/zones/hold_create_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HoldCreateParams"] class HoldCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" include_subdomains: bool diff --git a/src/cloudflare/types/zones/hold_delete_params.py b/src/cloudflare/types/zones/hold_delete_params.py index 3610944f01b..6ce5383d89a 100644 --- a/src/cloudflare/types/zones/hold_delete_params.py +++ b/src/cloudflare/types/zones/hold_delete_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HoldDeleteParams"] class HoldDeleteParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" hold_after: str diff --git a/src/cloudflare/types/zones/hold_edit_params.py b/src/cloudflare/types/zones/hold_edit_params.py index 6c86882616b..fcddff40b8e 100644 --- a/src/cloudflare/types/zones/hold_edit_params.py +++ b/src/cloudflare/types/zones/hold_edit_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["HoldEditParams"] class HoldEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier.""" hold_after: str diff --git a/src/cloudflare/types/zones/setting_edit_params.py b/src/cloudflare/types/zones/setting_edit_params.py index 7151cf62b94..f9d3344faf2 100644 --- a/src/cloudflare/types/zones/setting_edit_params.py +++ b/src/cloudflare/types/zones/setting_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Union -from typing_extensions import Required, TypeAlias, TypedDict +from typing_extensions import TypeAlias, TypedDict from ..._types import SequenceNotStr from .automatic_platform_optimization_param import AutomaticPlatformOptimizationParam @@ -21,7 +21,7 @@ class Variant0(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" enabled: bool @@ -29,7 +29,7 @@ class Variant0(TypedDict, total=False): class Variant1(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" value: Variant1Value diff --git a/src/cloudflare/types/zones/subscription_create_params.py b/src/cloudflare/types/zones/subscription_create_params.py index e4ceb39bcc8..8398616d270 100644 --- a/src/cloudflare/types/zones/subscription_create_params.py +++ b/src/cloudflare/types/zones/subscription_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..shared_params.rate_plan import RatePlan @@ -10,7 +10,7 @@ class SubscriptionCreateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" frequency: Literal["weekly", "monthly", "quarterly", "yearly"] diff --git a/src/cloudflare/types/zones/subscription_update_params.py b/src/cloudflare/types/zones/subscription_update_params.py index f6b2ae0ac96..03925833fe1 100644 --- a/src/cloudflare/types/zones/subscription_update_params.py +++ b/src/cloudflare/types/zones/subscription_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..shared_params.rate_plan import RatePlan @@ -10,7 +10,7 @@ class SubscriptionUpdateParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" frequency: Literal["weekly", "monthly", "quarterly", "yearly"] diff --git a/src/cloudflare/types/zones/zone_edit_params.py b/src/cloudflare/types/zones/zone_edit_params.py index 607b488c29e..09495085630 100644 --- a/src/cloudflare/types/zones/zone_edit_params.py +++ b/src/cloudflare/types/zones/zone_edit_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..._types import SequenceNotStr @@ -10,7 +10,7 @@ class ZoneEditParams(TypedDict, total=False): - zone_id: Required[str] + zone_id: str """Identifier""" paused: bool diff --git a/tests/api_resources/ai/finetunes/test_assets.py b/tests/api_resources/ai/finetunes/test_assets.py index 015f0a5c02d..24fb8014d29 100644 --- a/tests/api_resources/ai/finetunes/test_assets.py +++ b/tests/api_resources/ai/finetunes/test_assets.py @@ -30,7 +30,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: asset = client.ai.finetunes.assets.create( finetune_id="bc451aef-f723-4b26-a6b2-901afd2e7a8a", account_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", file_name="file_name", ) assert_matches_type(AssetCreateResponse, asset, path=["response"]) @@ -94,7 +94,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare asset = await async_client.ai.finetunes.assets.create( finetune_id="bc451aef-f723-4b26-a6b2-901afd2e7a8a", account_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", file_name="file_name", ) assert_matches_type(AssetCreateResponse, asset, path=["response"]) diff --git a/tests/api_resources/ai/test_to_markdown.py b/tests/api_resources/ai/test_to_markdown.py index 607dd536533..fcf3612ea77 100644 --- a/tests/api_resources/ai/test_to_markdown.py +++ b/tests/api_resources/ai/test_to_markdown.py @@ -61,7 +61,7 @@ def test_path_params_supported(self, client: Cloudflare) -> None: def test_method_transform(self, client: Cloudflare) -> None: to_markdown = client.ai.to_markdown.transform( account_id="023e105f4ecef8ad9ca31a8372d0c353", - file={"files": [b"raw file contents"]}, + file={"files": [b"Example data"]}, ) assert_matches_type(SyncSinglePage[ToMarkdownTransformResponse], to_markdown, path=["response"]) @@ -70,7 +70,7 @@ def test_method_transform(self, client: Cloudflare) -> None: def test_raw_response_transform(self, client: Cloudflare) -> None: response = client.ai.to_markdown.with_raw_response.transform( account_id="023e105f4ecef8ad9ca31a8372d0c353", - file={"files": [b"raw file contents"]}, + file={"files": [b"Example data"]}, ) assert response.is_closed is True @@ -83,7 +83,7 @@ def test_raw_response_transform(self, client: Cloudflare) -> None: def test_streaming_response_transform(self, client: Cloudflare) -> None: with client.ai.to_markdown.with_streaming_response.transform( account_id="023e105f4ecef8ad9ca31a8372d0c353", - file={"files": [b"raw file contents"]}, + file={"files": [b"Example data"]}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -99,7 +99,7 @@ def test_path_params_transform(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.ai.to_markdown.with_raw_response.transform( account_id="", - file={"files": [b"raw file contents"]}, + file={"files": [b"Example data"]}, ) @@ -151,7 +151,7 @@ async def test_path_params_supported(self, async_client: AsyncCloudflare) -> Non async def test_method_transform(self, async_client: AsyncCloudflare) -> None: to_markdown = await async_client.ai.to_markdown.transform( account_id="023e105f4ecef8ad9ca31a8372d0c353", - file={"files": [b"raw file contents"]}, + file={"files": [b"Example data"]}, ) assert_matches_type(AsyncSinglePage[ToMarkdownTransformResponse], to_markdown, path=["response"]) @@ -160,7 +160,7 @@ async def test_method_transform(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_transform(self, async_client: AsyncCloudflare) -> None: response = await async_client.ai.to_markdown.with_raw_response.transform( account_id="023e105f4ecef8ad9ca31a8372d0c353", - file={"files": [b"raw file contents"]}, + file={"files": [b"Example data"]}, ) assert response.is_closed is True @@ -173,7 +173,7 @@ async def test_raw_response_transform(self, async_client: AsyncCloudflare) -> No async def test_streaming_response_transform(self, async_client: AsyncCloudflare) -> None: async with async_client.ai.to_markdown.with_streaming_response.transform( account_id="023e105f4ecef8ad9ca31a8372d0c353", - file={"files": [b"raw file contents"]}, + file={"files": [b"Example data"]}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -189,5 +189,5 @@ async def test_path_params_transform(self, async_client: AsyncCloudflare) -> Non with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.ai.to_markdown.with_raw_response.transform( account_id="", - file={"files": [b"raw file contents"]}, + file={"files": [b"Example data"]}, ) diff --git a/tests/api_resources/cloudforce_one/threat_events/datasets/__init__.py b/tests/api_resources/aisearch/namespaces/__init__.py similarity index 100% rename from tests/api_resources/cloudforce_one/threat_events/datasets/__init__.py rename to tests/api_resources/aisearch/namespaces/__init__.py diff --git a/tests/api_resources/aisearch/namespaces/instances/__init__.py b/tests/api_resources/aisearch/namespaces/instances/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/aisearch/namespaces/instances/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/aisearch/namespaces/instances/test_items.py b/tests/api_resources/aisearch/namespaces/instances/test_items.py new file mode 100644 index 00000000000..d7a6b9b7bed --- /dev/null +++ b/tests/api_resources/aisearch/namespaces/instances/test_items.py @@ -0,0 +1,1486 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import httpx +import pytest +from respx import MockRouter + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._response import ( + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, +) +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.aisearch.namespaces.instances import ( + ItemGetResponse, + ItemListResponse, + ItemLogsResponse, + ItemSyncResponse, + ItemChunksResponse, + ItemDeleteResponse, + ItemUploadResponse, + ItemCreateOrUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestItems: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(SyncV4PagePaginationArray[ItemListResponse], item, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + item_id="item_id", + metadata_filter="metadata_filter", + page=1, + per_page=0, + search="search", + sort_by="status", + source="source", + status="queued", + ) + assert_matches_type(SyncV4PagePaginationArray[ItemListResponse], item, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.items.with_raw_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(SyncV4PagePaginationArray[ItemListResponse], item, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.items.with_streaming_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(SyncV4PagePaginationArray[ItemListResponse], item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.list( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.list( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(ItemDeleteResponse, item, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(ItemDeleteResponse, item, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.items.with_streaming_response.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(ItemDeleteResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + def test_method_chunks(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(ItemChunksResponse, item, path=["response"]) + + @parametrize + def test_method_chunks_with_all_params(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + limit=1, + offset=0, + ) + assert_matches_type(ItemChunksResponse, item, path=["response"]) + + @parametrize + def test_raw_response_chunks(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(ItemChunksResponse, item, path=["response"]) + + @parametrize + def test_streaming_response_chunks(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.items.with_streaming_response.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(ItemChunksResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_chunks(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + def test_method_create_or_update(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.create_or_update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + key="key", + next_action="INDEX", + ) + assert_matches_type(ItemCreateOrUpdateResponse, item, path=["response"]) + + @parametrize + def test_raw_response_create_or_update(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.items.with_raw_response.create_or_update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + key="key", + next_action="INDEX", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(ItemCreateOrUpdateResponse, item, path=["response"]) + + @parametrize + def test_streaming_response_create_or_update(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.items.with_streaming_response.create_or_update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + key="key", + next_action="INDEX", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(ItemCreateOrUpdateResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_or_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.create_or_update( + id="my-ai-search", + account_id="", + name="my-namespace", + key="key", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.create_or_update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + key="key", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.create_or_update( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + key="key", + next_action="INDEX", + ) + + @parametrize + @pytest.mark.respx(base_url=base_url) + def test_method_download(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/c3dc5f0b34a14ff8e1b3ec04895e1b22/ai-search/namespaces/my-namespace/instances/my-ai-search/items/item_id/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + item = client.aisearch.namespaces.instances.items.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert item.is_closed + assert item.json() == {"foo": "bar"} + assert cast(Any, item.is_closed) is True + assert isinstance(item, BinaryAPIResponse) + + @parametrize + @pytest.mark.respx(base_url=base_url) + def test_raw_response_download(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/c3dc5f0b34a14ff8e1b3ec04895e1b22/ai-search/namespaces/my-namespace/instances/my-ai-search/items/item_id/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + + item = client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert item.is_closed is True + assert item.http_request.headers.get("X-Stainless-Lang") == "python" + assert item.json() == {"foo": "bar"} + assert isinstance(item, BinaryAPIResponse) + + @parametrize + @pytest.mark.respx(base_url=base_url) + def test_streaming_response_download(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/c3dc5f0b34a14ff8e1b3ec04895e1b22/ai-search/namespaces/my-namespace/instances/my-ai-search/items/item_id/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + with client.aisearch.namespaces.instances.items.with_streaming_response.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as item: + assert not item.is_closed + assert item.http_request.headers.get("X-Stainless-Lang") == "python" + + assert item.json() == {"foo": "bar"} + assert cast(Any, item.is_closed) is True + assert isinstance(item, StreamedBinaryAPIResponse) + + assert cast(Any, item.is_closed) is True + + @parametrize + @pytest.mark.respx(base_url=base_url) + def test_path_params_download(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(ItemGetResponse, item, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(ItemGetResponse, item, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.items.with_streaming_response.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(ItemGetResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + def test_method_logs(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(ItemLogsResponse, item, path=["response"]) + + @parametrize + def test_method_logs_with_all_params(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + cursor="cursor", + limit=1, + ) + assert_matches_type(ItemLogsResponse, item, path=["response"]) + + @parametrize + def test_raw_response_logs(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(ItemLogsResponse, item, path=["response"]) + + @parametrize + def test_streaming_response_logs(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.items.with_streaming_response.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(ItemLogsResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_logs(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + def test_method_sync(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) + assert_matches_type(ItemSyncResponse, item, path=["response"]) + + @parametrize + def test_raw_response_sync(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(ItemSyncResponse, item, path=["response"]) + + @parametrize + def test_streaming_response_sync(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.items.with_streaming_response.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(ItemSyncResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_sync(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) + + @parametrize + def test_method_upload(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={"file": b"Example data"}, + ) + assert_matches_type(ItemUploadResponse, item, path=["response"]) + + @parametrize + def test_method_upload_with_all_params(self, client: Cloudflare) -> None: + item = client.aisearch.namespaces.instances.items.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={ + "file": b"Example data", + "metadata": "metadata", + "wait_for_completion": True, + }, + ) + assert_matches_type(ItemUploadResponse, item, path=["response"]) + + @parametrize + def test_raw_response_upload(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.items.with_raw_response.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={"file": b"Example data"}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(ItemUploadResponse, item, path=["response"]) + + @parametrize + def test_streaming_response_upload(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.items.with_streaming_response.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={"file": b"Example data"}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(ItemUploadResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_upload(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.upload( + id="my-ai-search", + account_id="", + name="my-namespace", + file={"file": b"Example data"}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + file={"file": b"Example data"}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.items.with_raw_response.upload( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={"file": b"Example data"}, + ) + + +class TestAsyncItems: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(AsyncV4PagePaginationArray[ItemListResponse], item, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + item_id="item_id", + metadata_filter="metadata_filter", + page=1, + per_page=0, + search="search", + sort_by="status", + source="source", + status="queued", + ) + assert_matches_type(AsyncV4PagePaginationArray[ItemListResponse], item, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.items.with_raw_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[ItemListResponse], item, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.items.with_streaming_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[ItemListResponse], item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.list( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.list( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(ItemDeleteResponse, item, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(ItemDeleteResponse, item, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.items.with_streaming_response.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(ItemDeleteResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.delete( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + async def test_method_chunks(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(ItemChunksResponse, item, path=["response"]) + + @parametrize + async def test_method_chunks_with_all_params(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + limit=1, + offset=0, + ) + assert_matches_type(ItemChunksResponse, item, path=["response"]) + + @parametrize + async def test_raw_response_chunks(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(ItemChunksResponse, item, path=["response"]) + + @parametrize + async def test_streaming_response_chunks(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.items.with_streaming_response.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(ItemChunksResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_chunks(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.chunks( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + async def test_method_create_or_update(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.create_or_update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + key="key", + next_action="INDEX", + ) + assert_matches_type(ItemCreateOrUpdateResponse, item, path=["response"]) + + @parametrize + async def test_raw_response_create_or_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.items.with_raw_response.create_or_update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + key="key", + next_action="INDEX", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(ItemCreateOrUpdateResponse, item, path=["response"]) + + @parametrize + async def test_streaming_response_create_or_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.items.with_streaming_response.create_or_update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + key="key", + next_action="INDEX", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(ItemCreateOrUpdateResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_or_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.create_or_update( + id="my-ai-search", + account_id="", + name="my-namespace", + key="key", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.create_or_update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + key="key", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.create_or_update( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + key="key", + next_action="INDEX", + ) + + @parametrize + @pytest.mark.respx(base_url=base_url) + async def test_method_download(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/c3dc5f0b34a14ff8e1b3ec04895e1b22/ai-search/namespaces/my-namespace/instances/my-ai-search/items/item_id/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + item = await async_client.aisearch.namespaces.instances.items.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert item.is_closed + assert await item.json() == {"foo": "bar"} + assert cast(Any, item.is_closed) is True + assert isinstance(item, AsyncBinaryAPIResponse) + + @parametrize + @pytest.mark.respx(base_url=base_url) + async def test_raw_response_download(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/c3dc5f0b34a14ff8e1b3ec04895e1b22/ai-search/namespaces/my-namespace/instances/my-ai-search/items/item_id/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + + item = await async_client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert item.is_closed is True + assert item.http_request.headers.get("X-Stainless-Lang") == "python" + assert await item.json() == {"foo": "bar"} + assert isinstance(item, AsyncBinaryAPIResponse) + + @parametrize + @pytest.mark.respx(base_url=base_url) + async def test_streaming_response_download(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/c3dc5f0b34a14ff8e1b3ec04895e1b22/ai-search/namespaces/my-namespace/instances/my-ai-search/items/item_id/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + async with async_client.aisearch.namespaces.instances.items.with_streaming_response.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as item: + assert not item.is_closed + assert item.http_request.headers.get("X-Stainless-Lang") == "python" + + assert await item.json() == {"foo": "bar"} + assert cast(Any, item.is_closed) is True + assert isinstance(item, AsyncStreamedBinaryAPIResponse) + + assert cast(Any, item.is_closed) is True + + @parametrize + @pytest.mark.respx(base_url=base_url) + async def test_path_params_download(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.download( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(ItemGetResponse, item, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(ItemGetResponse, item, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.items.with_streaming_response.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(ItemGetResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.get( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + async def test_method_logs(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(ItemLogsResponse, item, path=["response"]) + + @parametrize + async def test_method_logs_with_all_params(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + cursor="cursor", + limit=1, + ) + assert_matches_type(ItemLogsResponse, item, path=["response"]) + + @parametrize + async def test_raw_response_logs(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(ItemLogsResponse, item, path=["response"]) + + @parametrize + async def test_streaming_response_logs(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.items.with_streaming_response.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(ItemLogsResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_logs(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.logs( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + async def test_method_sync(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) + assert_matches_type(ItemSyncResponse, item, path=["response"]) + + @parametrize + async def test_raw_response_sync(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(ItemSyncResponse, item, path=["response"]) + + @parametrize + async def test_streaming_response_sync(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.items.with_streaming_response.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(ItemSyncResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_sync(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="item_id", + account_id="", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="item_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + next_action="INDEX", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.sync( + item_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + next_action="INDEX", + ) + + @parametrize + async def test_method_upload(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={"file": b"Example data"}, + ) + assert_matches_type(ItemUploadResponse, item, path=["response"]) + + @parametrize + async def test_method_upload_with_all_params(self, async_client: AsyncCloudflare) -> None: + item = await async_client.aisearch.namespaces.instances.items.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={ + "file": b"Example data", + "metadata": "metadata", + "wait_for_completion": True, + }, + ) + assert_matches_type(ItemUploadResponse, item, path=["response"]) + + @parametrize + async def test_raw_response_upload(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.items.with_raw_response.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={"file": b"Example data"}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(ItemUploadResponse, item, path=["response"]) + + @parametrize + async def test_streaming_response_upload(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.items.with_streaming_response.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={"file": b"Example data"}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(ItemUploadResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_upload(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.upload( + id="my-ai-search", + account_id="", + name="my-namespace", + file={"file": b"Example data"}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.upload( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + file={"file": b"Example data"}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.items.with_raw_response.upload( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + file={"file": b"Example data"}, + ) diff --git a/tests/api_resources/aisearch/namespaces/instances/test_jobs.py b/tests/api_resources/aisearch/namespaces/instances/test_jobs.py new file mode 100644 index 00000000000..83dc130dee3 --- /dev/null +++ b/tests/api_resources/aisearch/namespaces/instances/test_jobs.py @@ -0,0 +1,795 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.aisearch.namespaces.instances import ( + JobGetResponse, + JobListResponse, + JobLogsResponse, + JobCreateResponse, + JobUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestJobs: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + job = client.aisearch.namespaces.instances.jobs.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(JobCreateResponse, job, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + job = client.aisearch.namespaces.instances.jobs.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + description="description", + ) + assert_matches_type(JobCreateResponse, job, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.jobs.with_raw_response.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = response.parse() + assert_matches_type(JobCreateResponse, job, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.jobs.with_streaming_response.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = response.parse() + assert_matches_type(JobCreateResponse, job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.create( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.create( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + job = client.aisearch.namespaces.instances.jobs.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) + assert_matches_type(JobUpdateResponse, job, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = response.parse() + assert_matches_type(JobUpdateResponse, job, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.jobs.with_streaming_response.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = response.parse() + assert_matches_type(JobUpdateResponse, job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="job_id", + account_id="", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + action="cancel", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + action="cancel", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + job = client.aisearch.namespaces.instances.jobs.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(SyncV4PagePaginationArray[JobListResponse], job, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + job = client.aisearch.namespaces.instances.jobs.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + page=1, + per_page=0, + ) + assert_matches_type(SyncV4PagePaginationArray[JobListResponse], job, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.jobs.with_raw_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = response.parse() + assert_matches_type(SyncV4PagePaginationArray[JobListResponse], job, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.jobs.with_streaming_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = response.parse() + assert_matches_type(SyncV4PagePaginationArray[JobListResponse], job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.list( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.list( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + job = client.aisearch.namespaces.instances.jobs.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(JobGetResponse, job, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = response.parse() + assert_matches_type(JobGetResponse, job, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.jobs.with_streaming_response.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = response.parse() + assert_matches_type(JobGetResponse, job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="job_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + def test_method_logs(self, client: Cloudflare) -> None: + job = client.aisearch.namespaces.instances.jobs.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(JobLogsResponse, job, path=["response"]) + + @parametrize + def test_method_logs_with_all_params(self, client: Cloudflare) -> None: + job = client.aisearch.namespaces.instances.jobs.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + page=1, + per_page=0, + ) + assert_matches_type(JobLogsResponse, job, path=["response"]) + + @parametrize + def test_raw_response_logs(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = response.parse() + assert_matches_type(JobLogsResponse, job, path=["response"]) + + @parametrize + def test_streaming_response_logs(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.jobs.with_streaming_response.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = response.parse() + assert_matches_type(JobLogsResponse, job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_logs(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="job_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + +class TestAsyncJobs: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + job = await async_client.aisearch.namespaces.instances.jobs.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(JobCreateResponse, job, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + job = await async_client.aisearch.namespaces.instances.jobs.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + description="description", + ) + assert_matches_type(JobCreateResponse, job, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.jobs.with_raw_response.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = await response.parse() + assert_matches_type(JobCreateResponse, job, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.jobs.with_streaming_response.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = await response.parse() + assert_matches_type(JobCreateResponse, job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.create( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.create( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + job = await async_client.aisearch.namespaces.instances.jobs.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) + assert_matches_type(JobUpdateResponse, job, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = await response.parse() + assert_matches_type(JobUpdateResponse, job, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.jobs.with_streaming_response.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = await response.parse() + assert_matches_type(JobUpdateResponse, job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="job_id", + account_id="", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + action="cancel", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + action="cancel", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.update( + job_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + action="cancel", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + job = await async_client.aisearch.namespaces.instances.jobs.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(AsyncV4PagePaginationArray[JobListResponse], job, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + job = await async_client.aisearch.namespaces.instances.jobs.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + page=1, + per_page=0, + ) + assert_matches_type(AsyncV4PagePaginationArray[JobListResponse], job, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.jobs.with_raw_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[JobListResponse], job, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.jobs.with_streaming_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[JobListResponse], job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.list( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.list( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.list( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + job = await async_client.aisearch.namespaces.instances.jobs.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(JobGetResponse, job, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = await response.parse() + assert_matches_type(JobGetResponse, job, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.jobs.with_streaming_response.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = await response.parse() + assert_matches_type(JobGetResponse, job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="job_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.get( + job_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + @parametrize + async def test_method_logs(self, async_client: AsyncCloudflare) -> None: + job = await async_client.aisearch.namespaces.instances.jobs.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + assert_matches_type(JobLogsResponse, job, path=["response"]) + + @parametrize + async def test_method_logs_with_all_params(self, async_client: AsyncCloudflare) -> None: + job = await async_client.aisearch.namespaces.instances.jobs.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + page=1, + per_page=0, + ) + assert_matches_type(JobLogsResponse, job, path=["response"]) + + @parametrize + async def test_raw_response_logs(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + job = await response.parse() + assert_matches_type(JobLogsResponse, job, path=["response"]) + + @parametrize + async def test_streaming_response_logs(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.jobs.with_streaming_response.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + job = await response.parse() + assert_matches_type(JobLogsResponse, job, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_logs(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="job_id", + account_id="", + name="my-namespace", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="job_id", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + await async_client.aisearch.namespaces.instances.jobs.with_raw_response.logs( + job_id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + id="my-ai-search", + ) diff --git a/tests/api_resources/aisearch/namespaces/test_instances.py b/tests/api_resources/aisearch/namespaces/test_instances.py new file mode 100644 index 00000000000..3aab8040ce6 --- /dev/null +++ b/tests/api_resources/aisearch/namespaces/test_instances.py @@ -0,0 +1,1692 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.aisearch.namespaces import ( + InstanceListResponse, + InstanceReadResponse, + InstanceStatsResponse, + InstanceCreateResponse, + InstanceDeleteResponse, + InstanceSearchResponse, + InstanceUpdateResponse, + InstanceChatCompletionsResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestInstances: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.create( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ) + assert_matches_type(InstanceCreateResponse, instance, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.create( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ai_gateway_id="ai_gateway_id", + aisearch_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + cache=True, + cache_threshold="super_strict_match", + chunk=True, + chunk_overlap=0, + chunk_size=64, + custom_metadata=[ + { + "data_type": "text", + "field_name": "x", + } + ], + embedding_model="@cf/qwen/qwen3-embedding-0.6b", + fusion_method="max", + hybrid_search_enabled=True, + index_method={ + "keyword": True, + "vector": True, + }, + indexing_options={"keyword_tokenizer": "porter"}, + max_num_results=1, + metadata={ + "created_from_aisearch_wizard": True, + "search_for_agents": { + "hostname": "hostname", + "zone_id": "zone_id", + "zone_name": "zone_name", + }, + "worker_domain": "worker_domain", + }, + public_endpoint_params={ + "authorized_hosts": ["string"], + "chat_completions_endpoint": {"disabled": True}, + "enabled": True, + "mcp": { + "description": "description", + "disabled": True, + }, + "rate_limit": { + "period_ms": 60000, + "requests": 1, + "technique": "fixed", + }, + "search_endpoint": {"disabled": True}, + }, + reranking=True, + reranking_model="@cf/baai/bge-reranker-base", + retrieval_options={ + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "keyword_match_mode": "and", + }, + rewrite_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + rewrite_query=True, + score_threshold=0, + source="source", + source_params={ + "exclude_items": ["/admin/**", "/private/**", "**\\temp\\**"], + "include_items": ["/blog/**", "/docs/**/*.html", "**\\blog\\**.html"], + "prefix": "prefix", + "r2_jurisdiction": "r2_jurisdiction", + "web_crawler": { + "crawl_options": { + "depth": 1, + "include_external_links": True, + "include_subdomains": True, + "max_age": 0, + "source": "all", + }, + "parse_options": { + "content_selector": [ + { + "path": "**/blog/**", + "selector": "article .post-body", + } + ], + "include_headers": {"foo": "string"}, + "include_images": True, + "specific_sitemaps": [ + "https://example.com/sitemap.xml", + "https://example.com/blog-sitemap.xml", + ], + "use_browser_rendering": True, + }, + "parse_type": "sitemap", + "store_options": { + "storage_id": "storage_id", + "r2_jurisdiction": "r2_jurisdiction", + "storage_type": "r2", + }, + }, + }, + sync_interval=900, + token_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + type="r2", + ) + assert_matches_type(InstanceCreateResponse, instance, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.with_raw_response.create( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = response.parse() + assert_matches_type(InstanceCreateResponse, instance, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.with_streaming_response.create( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = response.parse() + assert_matches_type(InstanceCreateResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.create( + name="my-namespace", + account_id="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.create( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceUpdateResponse, instance, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ai_gateway_id="ai_gateway_id", + aisearch_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + cache=True, + cache_threshold="super_strict_match", + chunk=True, + chunk_overlap=0, + chunk_size=64, + custom_metadata=[ + { + "data_type": "text", + "field_name": "x", + } + ], + embedding_model="@cf/qwen/qwen3-embedding-0.6b", + fusion_method="max", + index_method={ + "keyword": True, + "vector": True, + }, + indexing_options={"keyword_tokenizer": "porter"}, + max_num_results=1, + metadata={ + "created_from_aisearch_wizard": True, + "search_for_agents": { + "hostname": "hostname", + "zone_id": "zone_id", + "zone_name": "zone_name", + }, + "worker_domain": "worker_domain", + }, + paused=True, + public_endpoint_params={ + "authorized_hosts": ["string"], + "chat_completions_endpoint": {"disabled": True}, + "enabled": True, + "mcp": { + "description": "description", + "disabled": True, + }, + "rate_limit": { + "period_ms": 60000, + "requests": 1, + "technique": "fixed", + }, + "search_endpoint": {"disabled": True}, + }, + reranking=True, + reranking_model="@cf/baai/bge-reranker-base", + retrieval_options={ + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "keyword_match_mode": "and", + }, + rewrite_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + rewrite_query=True, + score_threshold=0, + source_params={ + "exclude_items": ["/admin/**", "/private/**", "**\\temp\\**"], + "include_items": ["/blog/**", "/docs/**/*.html", "**\\blog\\**.html"], + "prefix": "prefix", + "r2_jurisdiction": "r2_jurisdiction", + "web_crawler": { + "crawl_options": { + "depth": 1, + "include_external_links": True, + "include_subdomains": True, + "max_age": 0, + "source": "all", + }, + "parse_options": { + "content_selector": [ + { + "path": "**/blog/**", + "selector": "article .post-body", + } + ], + "include_headers": {"foo": "string"}, + "include_images": True, + "specific_sitemaps": [ + "https://example.com/sitemap.xml", + "https://example.com/blog-sitemap.xml", + ], + "use_browser_rendering": True, + }, + "parse_type": "sitemap", + "store_options": { + "storage_id": "storage_id", + "r2_jurisdiction": "r2_jurisdiction", + "storage_type": "r2", + }, + }, + }, + summarization=True, + summarization_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + sync_interval=900, + system_prompt_aisearch="system_prompt_ai_search", + system_prompt_index_summarization="system_prompt_index_summarization", + system_prompt_rewrite_query="system_prompt_rewrite_query", + token_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(InstanceUpdateResponse, instance, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.with_raw_response.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = response.parse() + assert_matches_type(InstanceUpdateResponse, instance, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.with_streaming_response.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = response.parse() + assert_matches_type(InstanceUpdateResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.update( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.update( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.list( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(SyncV4PagePaginationArray[InstanceListResponse], instance, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.list( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + namespace="namespace", + order_by="created_at", + order_by_direction="asc", + page=1, + per_page=1, + search="search", + ) + assert_matches_type(SyncV4PagePaginationArray[InstanceListResponse], instance, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.with_raw_response.list( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = response.parse() + assert_matches_type(SyncV4PagePaginationArray[InstanceListResponse], instance, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.with_streaming_response.list( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = response.parse() + assert_matches_type(SyncV4PagePaginationArray[InstanceListResponse], instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.list( + name="my-namespace", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.list( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.delete( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceDeleteResponse, instance, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.with_raw_response.delete( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = response.parse() + assert_matches_type(InstanceDeleteResponse, instance, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.with_streaming_response.delete( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = response.parse() + assert_matches_type(InstanceDeleteResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.delete( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.delete( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.delete( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + def test_method_chat_completions(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + assert_matches_type(InstanceChatCompletionsResponse, instance, path=["response"]) + + @parametrize + def test_method_chat_completions_with_all_params(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + aisearch_options={ + "cache": { + "cache_threshold": "super_strict_match", + "enabled": True, + }, + "query_rewrite": { + "enabled": True, + "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "rewrite_prompt": "rewrite_prompt", + }, + "reranking": { + "enabled": True, + "match_threshold": 0, + "model": "@cf/baai/bge-reranker-base", + }, + "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "context_expansion": 0, + "filters": {"foo": "bar"}, + "fusion_method": "max", + "keyword_match_mode": "and", + "match_threshold": 0, + "max_num_results": 1, + "retrieval_type": "vector", + "return_on_failure": True, + }, + }, + model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + stream=True, + ) + assert_matches_type(InstanceChatCompletionsResponse, instance, path=["response"]) + + @parametrize + def test_raw_response_chat_completions(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.with_raw_response.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = response.parse() + assert_matches_type(InstanceChatCompletionsResponse, instance, path=["response"]) + + @parametrize + def test_streaming_response_chat_completions(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.with_streaming_response.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = response.parse() + assert_matches_type(InstanceChatCompletionsResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_chat_completions(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.chat_completions( + id="my-ai-search", + account_id="", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.chat_completions( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + @parametrize + def test_method_read(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.read( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceReadResponse, instance, path=["response"]) + + @parametrize + def test_raw_response_read(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.with_raw_response.read( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = response.parse() + assert_matches_type(InstanceReadResponse, instance, path=["response"]) + + @parametrize + def test_streaming_response_read(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.with_streaming_response.read( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = response.parse() + assert_matches_type(InstanceReadResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_read(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.read( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.read( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.read( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + def test_method_search(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceSearchResponse, instance, path=["response"]) + + @parametrize + def test_method_search_with_all_params(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + aisearch_options={ + "cache": { + "cache_threshold": "super_strict_match", + "enabled": True, + }, + "query_rewrite": { + "enabled": True, + "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "rewrite_prompt": "rewrite_prompt", + }, + "reranking": { + "enabled": True, + "match_threshold": 0, + "model": "@cf/baai/bge-reranker-base", + }, + "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "context_expansion": 0, + "filters": {"foo": "bar"}, + "fusion_method": "max", + "keyword_match_mode": "and", + "match_threshold": 0, + "max_num_results": 1, + "retrieval_type": "vector", + "return_on_failure": True, + }, + }, + messages=[ + { + "content": "content", + "role": "system", + } + ], + query="x", + ) + assert_matches_type(InstanceSearchResponse, instance, path=["response"]) + + @parametrize + def test_raw_response_search(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.with_raw_response.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = response.parse() + assert_matches_type(InstanceSearchResponse, instance, path=["response"]) + + @parametrize + def test_streaming_response_search(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.with_streaming_response.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = response.parse() + assert_matches_type(InstanceSearchResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_search(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.search( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.search( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + def test_method_stats(self, client: Cloudflare) -> None: + instance = client.aisearch.namespaces.instances.stats( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceStatsResponse, instance, path=["response"]) + + @parametrize + def test_raw_response_stats(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.instances.with_raw_response.stats( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = response.parse() + assert_matches_type(InstanceStatsResponse, instance, path=["response"]) + + @parametrize + def test_streaming_response_stats(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.instances.with_streaming_response.stats( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = response.parse() + assert_matches_type(InstanceStatsResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_stats(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.stats( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.stats( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.aisearch.namespaces.instances.with_raw_response.stats( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + +class TestAsyncInstances: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.create( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ) + assert_matches_type(InstanceCreateResponse, instance, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.create( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ai_gateway_id="ai_gateway_id", + aisearch_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + cache=True, + cache_threshold="super_strict_match", + chunk=True, + chunk_overlap=0, + chunk_size=64, + custom_metadata=[ + { + "data_type": "text", + "field_name": "x", + } + ], + embedding_model="@cf/qwen/qwen3-embedding-0.6b", + fusion_method="max", + hybrid_search_enabled=True, + index_method={ + "keyword": True, + "vector": True, + }, + indexing_options={"keyword_tokenizer": "porter"}, + max_num_results=1, + metadata={ + "created_from_aisearch_wizard": True, + "search_for_agents": { + "hostname": "hostname", + "zone_id": "zone_id", + "zone_name": "zone_name", + }, + "worker_domain": "worker_domain", + }, + public_endpoint_params={ + "authorized_hosts": ["string"], + "chat_completions_endpoint": {"disabled": True}, + "enabled": True, + "mcp": { + "description": "description", + "disabled": True, + }, + "rate_limit": { + "period_ms": 60000, + "requests": 1, + "technique": "fixed", + }, + "search_endpoint": {"disabled": True}, + }, + reranking=True, + reranking_model="@cf/baai/bge-reranker-base", + retrieval_options={ + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "keyword_match_mode": "and", + }, + rewrite_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + rewrite_query=True, + score_threshold=0, + source="source", + source_params={ + "exclude_items": ["/admin/**", "/private/**", "**\\temp\\**"], + "include_items": ["/blog/**", "/docs/**/*.html", "**\\blog\\**.html"], + "prefix": "prefix", + "r2_jurisdiction": "r2_jurisdiction", + "web_crawler": { + "crawl_options": { + "depth": 1, + "include_external_links": True, + "include_subdomains": True, + "max_age": 0, + "source": "all", + }, + "parse_options": { + "content_selector": [ + { + "path": "**/blog/**", + "selector": "article .post-body", + } + ], + "include_headers": {"foo": "string"}, + "include_images": True, + "specific_sitemaps": [ + "https://example.com/sitemap.xml", + "https://example.com/blog-sitemap.xml", + ], + "use_browser_rendering": True, + }, + "parse_type": "sitemap", + "store_options": { + "storage_id": "storage_id", + "r2_jurisdiction": "r2_jurisdiction", + "storage_type": "r2", + }, + }, + }, + sync_interval=900, + token_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + type="r2", + ) + assert_matches_type(InstanceCreateResponse, instance, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.with_raw_response.create( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = await response.parse() + assert_matches_type(InstanceCreateResponse, instance, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.with_streaming_response.create( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = await response.parse() + assert_matches_type(InstanceCreateResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.create( + name="my-namespace", + account_id="", + id="my-ai-search", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.create( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + id="my-ai-search", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceUpdateResponse, instance, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ai_gateway_id="ai_gateway_id", + aisearch_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + cache=True, + cache_threshold="super_strict_match", + chunk=True, + chunk_overlap=0, + chunk_size=64, + custom_metadata=[ + { + "data_type": "text", + "field_name": "x", + } + ], + embedding_model="@cf/qwen/qwen3-embedding-0.6b", + fusion_method="max", + index_method={ + "keyword": True, + "vector": True, + }, + indexing_options={"keyword_tokenizer": "porter"}, + max_num_results=1, + metadata={ + "created_from_aisearch_wizard": True, + "search_for_agents": { + "hostname": "hostname", + "zone_id": "zone_id", + "zone_name": "zone_name", + }, + "worker_domain": "worker_domain", + }, + paused=True, + public_endpoint_params={ + "authorized_hosts": ["string"], + "chat_completions_endpoint": {"disabled": True}, + "enabled": True, + "mcp": { + "description": "description", + "disabled": True, + }, + "rate_limit": { + "period_ms": 60000, + "requests": 1, + "technique": "fixed", + }, + "search_endpoint": {"disabled": True}, + }, + reranking=True, + reranking_model="@cf/baai/bge-reranker-base", + retrieval_options={ + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "keyword_match_mode": "and", + }, + rewrite_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + rewrite_query=True, + score_threshold=0, + source_params={ + "exclude_items": ["/admin/**", "/private/**", "**\\temp\\**"], + "include_items": ["/blog/**", "/docs/**/*.html", "**\\blog\\**.html"], + "prefix": "prefix", + "r2_jurisdiction": "r2_jurisdiction", + "web_crawler": { + "crawl_options": { + "depth": 1, + "include_external_links": True, + "include_subdomains": True, + "max_age": 0, + "source": "all", + }, + "parse_options": { + "content_selector": [ + { + "path": "**/blog/**", + "selector": "article .post-body", + } + ], + "include_headers": {"foo": "string"}, + "include_images": True, + "specific_sitemaps": [ + "https://example.com/sitemap.xml", + "https://example.com/blog-sitemap.xml", + ], + "use_browser_rendering": True, + }, + "parse_type": "sitemap", + "store_options": { + "storage_id": "storage_id", + "r2_jurisdiction": "r2_jurisdiction", + "storage_type": "r2", + }, + }, + }, + summarization=True, + summarization_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + sync_interval=900, + system_prompt_aisearch="system_prompt_ai_search", + system_prompt_index_summarization="system_prompt_index_summarization", + system_prompt_rewrite_query="system_prompt_rewrite_query", + token_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(InstanceUpdateResponse, instance, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.with_raw_response.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = await response.parse() + assert_matches_type(InstanceUpdateResponse, instance, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.with_streaming_response.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = await response.parse() + assert_matches_type(InstanceUpdateResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.update( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.update( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.update( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.list( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(AsyncV4PagePaginationArray[InstanceListResponse], instance, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.list( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + namespace="namespace", + order_by="created_at", + order_by_direction="asc", + page=1, + per_page=1, + search="search", + ) + assert_matches_type(AsyncV4PagePaginationArray[InstanceListResponse], instance, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.with_raw_response.list( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[InstanceListResponse], instance, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.with_streaming_response.list( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[InstanceListResponse], instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.list( + name="my-namespace", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.list( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.delete( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceDeleteResponse, instance, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.with_raw_response.delete( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = await response.parse() + assert_matches_type(InstanceDeleteResponse, instance, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.with_streaming_response.delete( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = await response.parse() + assert_matches_type(InstanceDeleteResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.delete( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.delete( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.delete( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + async def test_method_chat_completions(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + assert_matches_type(InstanceChatCompletionsResponse, instance, path=["response"]) + + @parametrize + async def test_method_chat_completions_with_all_params(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + aisearch_options={ + "cache": { + "cache_threshold": "super_strict_match", + "enabled": True, + }, + "query_rewrite": { + "enabled": True, + "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "rewrite_prompt": "rewrite_prompt", + }, + "reranking": { + "enabled": True, + "match_threshold": 0, + "model": "@cf/baai/bge-reranker-base", + }, + "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "context_expansion": 0, + "filters": {"foo": "bar"}, + "fusion_method": "max", + "keyword_match_mode": "and", + "match_threshold": 0, + "max_num_results": 1, + "retrieval_type": "vector", + "return_on_failure": True, + }, + }, + model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + stream=True, + ) + assert_matches_type(InstanceChatCompletionsResponse, instance, path=["response"]) + + @parametrize + async def test_raw_response_chat_completions(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.with_raw_response.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = await response.parse() + assert_matches_type(InstanceChatCompletionsResponse, instance, path=["response"]) + + @parametrize + async def test_streaming_response_chat_completions(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.with_streaming_response.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = await response.parse() + assert_matches_type(InstanceChatCompletionsResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_chat_completions(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.chat_completions( + id="my-ai-search", + account_id="", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.chat_completions( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.chat_completions( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + @parametrize + async def test_method_read(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.read( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceReadResponse, instance, path=["response"]) + + @parametrize + async def test_raw_response_read(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.with_raw_response.read( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = await response.parse() + assert_matches_type(InstanceReadResponse, instance, path=["response"]) + + @parametrize + async def test_streaming_response_read(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.with_streaming_response.read( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = await response.parse() + assert_matches_type(InstanceReadResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_read(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.read( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.read( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.read( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + async def test_method_search(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceSearchResponse, instance, path=["response"]) + + @parametrize + async def test_method_search_with_all_params(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + aisearch_options={ + "cache": { + "cache_threshold": "super_strict_match", + "enabled": True, + }, + "query_rewrite": { + "enabled": True, + "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "rewrite_prompt": "rewrite_prompt", + }, + "reranking": { + "enabled": True, + "match_threshold": 0, + "model": "@cf/baai/bge-reranker-base", + }, + "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "context_expansion": 0, + "filters": {"foo": "bar"}, + "fusion_method": "max", + "keyword_match_mode": "and", + "match_threshold": 0, + "max_num_results": 1, + "retrieval_type": "vector", + "return_on_failure": True, + }, + }, + messages=[ + { + "content": "content", + "role": "system", + } + ], + query="x", + ) + assert_matches_type(InstanceSearchResponse, instance, path=["response"]) + + @parametrize + async def test_raw_response_search(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.with_raw_response.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = await response.parse() + assert_matches_type(InstanceSearchResponse, instance, path=["response"]) + + @parametrize + async def test_streaming_response_search(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.with_streaming_response.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = await response.parse() + assert_matches_type(InstanceSearchResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_search(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.search( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.search( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.search( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + @parametrize + async def test_method_stats(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.aisearch.namespaces.instances.stats( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + assert_matches_type(InstanceStatsResponse, instance, path=["response"]) + + @parametrize + async def test_raw_response_stats(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.instances.with_raw_response.stats( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + instance = await response.parse() + assert_matches_type(InstanceStatsResponse, instance, path=["response"]) + + @parametrize + async def test_streaming_response_stats(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.instances.with_streaming_response.stats( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + instance = await response.parse() + assert_matches_type(InstanceStatsResponse, instance, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_stats(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.stats( + id="my-ai-search", + account_id="", + name="my-namespace", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.stats( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.aisearch.namespaces.instances.with_raw_response.stats( + id="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="my-namespace", + ) diff --git a/tests/api_resources/aisearch/test_instances.py b/tests/api_resources/aisearch/test_instances.py index decf3cc7f95..80bd18541ba 100644 --- a/tests/api_resources/aisearch/test_instances.py +++ b/tests/api_resources/aisearch/test_instances.py @@ -137,7 +137,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: }, }, }, - sync_interval=3600, + sync_interval=900, token_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", type="r2", ) @@ -288,7 +288,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: }, summarization=True, summarization_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", - sync_interval=3600, + sync_interval=900, system_prompt_aisearch="system_prompt_ai_search", system_prompt_index_summarization="system_prompt_index_summarization", system_prompt_rewrite_query="system_prompt_rewrite_query", @@ -868,7 +868,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare }, }, }, - sync_interval=3600, + sync_interval=900, token_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", type="r2", ) @@ -1019,7 +1019,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare }, summarization=True, summarization_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", - sync_interval=3600, + sync_interval=900, system_prompt_aisearch="system_prompt_ai_search", system_prompt_index_summarization="system_prompt_index_summarization", system_prompt_rewrite_query="system_prompt_rewrite_query", diff --git a/tests/api_resources/aisearch/test_namespaces.py b/tests/api_resources/aisearch/test_namespaces.py new file mode 100644 index 00000000000..a6662cb7e9b --- /dev/null +++ b/tests/api_resources/aisearch/test_namespaces.py @@ -0,0 +1,1002 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.aisearch import ( + NamespaceListResponse, + NamespaceReadResponse, + NamespaceCreateResponse, + NamespaceSearchResponse, + NamespaceUpdateResponse, + NamespaceChatCompletionsResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestNamespaces: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="name", + ) + assert_matches_type(NamespaceCreateResponse, namespace, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="name", + description="Production environment", + ) + assert_matches_type(NamespaceCreateResponse, namespace, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.with_raw_response.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = response.parse() + assert_matches_type(NamespaceCreateResponse, namespace, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.with_streaming_response.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = response.parse() + assert_matches_type(NamespaceCreateResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.with_raw_response.create( + account_id="", + name="name", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.update( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.update( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + description="Production environment", + ) + assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.with_raw_response.update( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = response.parse() + assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.with_streaming_response.update( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = response.parse() + assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.with_raw_response.update( + name="production", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.with_raw_response.update( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.list( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(SyncV4PagePaginationArray[NamespaceListResponse], namespace, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.list( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + page=1, + per_page=20, + search="prod", + ) + assert_matches_type(SyncV4PagePaginationArray[NamespaceListResponse], namespace, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.with_raw_response.list( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = response.parse() + assert_matches_type(SyncV4PagePaginationArray[NamespaceListResponse], namespace, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.with_streaming_response.list( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = response.parse() + assert_matches_type(SyncV4PagePaginationArray[NamespaceListResponse], namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.delete( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(object, namespace, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.with_raw_response.delete( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = response.parse() + assert_matches_type(object, namespace, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.with_streaming_response.delete( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = response.parse() + assert_matches_type(object, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.with_raw_response.delete( + name="production", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.with_raw_response.delete( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + @parametrize + def test_method_chat_completions(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.chat_completions( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + assert_matches_type(NamespaceChatCompletionsResponse, namespace, path=["response"]) + + @parametrize + def test_method_chat_completions_with_all_params(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.chat_completions( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={ + "instance_ids": ["my-ai-search"], + "cache": { + "cache_threshold": "super_strict_match", + "enabled": True, + }, + "query_rewrite": { + "enabled": True, + "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "rewrite_prompt": "rewrite_prompt", + }, + "reranking": { + "enabled": True, + "match_threshold": 0, + "model": "@cf/baai/bge-reranker-base", + }, + "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "context_expansion": 0, + "filters": {"foo": "bar"}, + "fusion_method": "max", + "keyword_match_mode": "and", + "match_threshold": 0, + "max_num_results": 1, + "retrieval_type": "vector", + "return_on_failure": True, + }, + }, + messages=[ + { + "content": "content", + "role": "system", + } + ], + model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + stream=True, + ) + assert_matches_type(NamespaceChatCompletionsResponse, namespace, path=["response"]) + + @parametrize + def test_raw_response_chat_completions(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.with_raw_response.chat_completions( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = response.parse() + assert_matches_type(NamespaceChatCompletionsResponse, namespace, path=["response"]) + + @parametrize + def test_streaming_response_chat_completions(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.with_streaming_response.chat_completions( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = response.parse() + assert_matches_type(NamespaceChatCompletionsResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_chat_completions(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.with_raw_response.chat_completions( + name="my-namespace", + account_id="", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.with_raw_response.chat_completions( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + @parametrize + def test_method_read(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.read( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(NamespaceReadResponse, namespace, path=["response"]) + + @parametrize + def test_raw_response_read(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.with_raw_response.read( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = response.parse() + assert_matches_type(NamespaceReadResponse, namespace, path=["response"]) + + @parametrize + def test_streaming_response_read(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.with_streaming_response.read( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = response.parse() + assert_matches_type(NamespaceReadResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_read(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.with_raw_response.read( + name="production", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.with_raw_response.read( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + @parametrize + def test_method_search(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.search( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) + assert_matches_type(NamespaceSearchResponse, namespace, path=["response"]) + + @parametrize + def test_method_search_with_all_params(self, client: Cloudflare) -> None: + namespace = client.aisearch.namespaces.search( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={ + "instance_ids": ["my-ai-search"], + "cache": { + "cache_threshold": "super_strict_match", + "enabled": True, + }, + "query_rewrite": { + "enabled": True, + "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "rewrite_prompt": "rewrite_prompt", + }, + "reranking": { + "enabled": True, + "match_threshold": 0, + "model": "@cf/baai/bge-reranker-base", + }, + "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "context_expansion": 0, + "filters": {"foo": "bar"}, + "fusion_method": "max", + "keyword_match_mode": "and", + "match_threshold": 0, + "max_num_results": 1, + "retrieval_type": "vector", + "return_on_failure": True, + }, + }, + messages=[ + { + "content": "content", + "role": "system", + } + ], + query="x", + ) + assert_matches_type(NamespaceSearchResponse, namespace, path=["response"]) + + @parametrize + def test_raw_response_search(self, client: Cloudflare) -> None: + response = client.aisearch.namespaces.with_raw_response.search( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = response.parse() + assert_matches_type(NamespaceSearchResponse, namespace, path=["response"]) + + @parametrize + def test_streaming_response_search(self, client: Cloudflare) -> None: + with client.aisearch.namespaces.with_streaming_response.search( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = response.parse() + assert_matches_type(NamespaceSearchResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_search(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.aisearch.namespaces.with_raw_response.search( + name="my-namespace", + account_id="", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + client.aisearch.namespaces.with_raw_response.search( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) + + +class TestAsyncNamespaces: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="name", + ) + assert_matches_type(NamespaceCreateResponse, namespace, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="name", + description="Production environment", + ) + assert_matches_type(NamespaceCreateResponse, namespace, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.with_raw_response.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = await response.parse() + assert_matches_type(NamespaceCreateResponse, namespace, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.with_streaming_response.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = await response.parse() + assert_matches_type(NamespaceCreateResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.create( + account_id="", + name="name", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.update( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.update( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + description="Production environment", + ) + assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.with_raw_response.update( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = await response.parse() + assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.with_streaming_response.update( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = await response.parse() + assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.update( + name="production", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.update( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.list( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(AsyncV4PagePaginationArray[NamespaceListResponse], namespace, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.list( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + page=1, + per_page=20, + search="prod", + ) + assert_matches_type(AsyncV4PagePaginationArray[NamespaceListResponse], namespace, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.with_raw_response.list( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[NamespaceListResponse], namespace, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.with_streaming_response.list( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[NamespaceListResponse], namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.delete( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(object, namespace, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.with_raw_response.delete( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = await response.parse() + assert_matches_type(object, namespace, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.with_streaming_response.delete( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = await response.parse() + assert_matches_type(object, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.delete( + name="production", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.delete( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + @parametrize + async def test_method_chat_completions(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.chat_completions( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + assert_matches_type(NamespaceChatCompletionsResponse, namespace, path=["response"]) + + @parametrize + async def test_method_chat_completions_with_all_params(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.chat_completions( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={ + "instance_ids": ["my-ai-search"], + "cache": { + "cache_threshold": "super_strict_match", + "enabled": True, + }, + "query_rewrite": { + "enabled": True, + "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "rewrite_prompt": "rewrite_prompt", + }, + "reranking": { + "enabled": True, + "match_threshold": 0, + "model": "@cf/baai/bge-reranker-base", + }, + "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "context_expansion": 0, + "filters": {"foo": "bar"}, + "fusion_method": "max", + "keyword_match_mode": "and", + "match_threshold": 0, + "max_num_results": 1, + "retrieval_type": "vector", + "return_on_failure": True, + }, + }, + messages=[ + { + "content": "content", + "role": "system", + } + ], + model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + stream=True, + ) + assert_matches_type(NamespaceChatCompletionsResponse, namespace, path=["response"]) + + @parametrize + async def test_raw_response_chat_completions(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.with_raw_response.chat_completions( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = await response.parse() + assert_matches_type(NamespaceChatCompletionsResponse, namespace, path=["response"]) + + @parametrize + async def test_streaming_response_chat_completions(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.with_streaming_response.chat_completions( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = await response.parse() + assert_matches_type(NamespaceChatCompletionsResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_chat_completions(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.chat_completions( + name="my-namespace", + account_id="", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.chat_completions( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + messages=[ + { + "content": "content", + "role": "system", + } + ], + ) + + @parametrize + async def test_method_read(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.read( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + assert_matches_type(NamespaceReadResponse, namespace, path=["response"]) + + @parametrize + async def test_raw_response_read(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.with_raw_response.read( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = await response.parse() + assert_matches_type(NamespaceReadResponse, namespace, path=["response"]) + + @parametrize + async def test_streaming_response_read(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.with_streaming_response.read( + name="production", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = await response.parse() + assert_matches_type(NamespaceReadResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_read(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.read( + name="production", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.read( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + ) + + @parametrize + async def test_method_search(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.search( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) + assert_matches_type(NamespaceSearchResponse, namespace, path=["response"]) + + @parametrize + async def test_method_search_with_all_params(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.aisearch.namespaces.search( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={ + "instance_ids": ["my-ai-search"], + "cache": { + "cache_threshold": "super_strict_match", + "enabled": True, + }, + "query_rewrite": { + "enabled": True, + "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "rewrite_prompt": "rewrite_prompt", + }, + "reranking": { + "enabled": True, + "match_threshold": 0, + "model": "@cf/baai/bge-reranker-base", + }, + "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "context_expansion": 0, + "filters": {"foo": "bar"}, + "fusion_method": "max", + "keyword_match_mode": "and", + "match_threshold": 0, + "max_num_results": 1, + "retrieval_type": "vector", + "return_on_failure": True, + }, + }, + messages=[ + { + "content": "content", + "role": "system", + } + ], + query="x", + ) + assert_matches_type(NamespaceSearchResponse, namespace, path=["response"]) + + @parametrize + async def test_raw_response_search(self, async_client: AsyncCloudflare) -> None: + response = await async_client.aisearch.namespaces.with_raw_response.search( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = await response.parse() + assert_matches_type(NamespaceSearchResponse, namespace, path=["response"]) + + @parametrize + async def test_streaming_response_search(self, async_client: AsyncCloudflare) -> None: + async with async_client.aisearch.namespaces.with_streaming_response.search( + name="my-namespace", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = await response.parse() + assert_matches_type(NamespaceSearchResponse, namespace, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_search(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.search( + name="my-namespace", + account_id="", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + await async_client.aisearch.namespaces.with_raw_response.search( + name="", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + aisearch_options={"instance_ids": ["my-ai-search"]}, + ) diff --git a/tests/api_resources/aisearch/test_tokens.py b/tests/api_resources/aisearch/test_tokens.py index 1090f0fb388..ded7a20a132 100644 --- a/tests/api_resources/aisearch/test_tokens.py +++ b/tests/api_resources/aisearch/test_tokens.py @@ -14,7 +14,6 @@ TokenListResponse, TokenReadResponse, TokenCreateResponse, - TokenDeleteResponse, TokenUpdateResponse, ) @@ -28,9 +27,20 @@ class TestTokens: def test_method_create(self, client: Cloudflare) -> None: token = client.aisearch.tokens.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", + ) + assert_matches_type(TokenCreateResponse, token, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + token = client.aisearch.tokens.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", + legacy=True, ) assert_matches_type(TokenCreateResponse, token, path=["response"]) @@ -38,9 +48,9 @@ def test_method_create(self, client: Cloudflare) -> None: def test_raw_response_create(self, client: Cloudflare) -> None: response = client.aisearch.tokens.with_raw_response.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) assert response.is_closed is True @@ -52,9 +62,9 @@ def test_raw_response_create(self, client: Cloudflare) -> None: def test_streaming_response_create(self, client: Cloudflare) -> None: with client.aisearch.tokens.with_streaming_response.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -69,30 +79,42 @@ def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.aisearch.tokens.with_raw_response.create( account_id="", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) @parametrize def test_method_update(self, client: Cloudflare) -> None: token = client.aisearch.tokens.update( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", + ) + assert_matches_type(TokenUpdateResponse, token, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + token = client.aisearch.tokens.update( + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", + legacy=True, ) assert_matches_type(TokenUpdateResponse, token, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.aisearch.tokens.with_raw_response.update( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) assert response.is_closed is True @@ -103,11 +125,11 @@ def test_raw_response_update(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: with client.aisearch.tokens.with_streaming_response.update( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -121,20 +143,20 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.aisearch.tokens.with_raw_response.update( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): client.aisearch.tokens.with_raw_response.update( id="", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) @parametrize @@ -148,10 +170,9 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: token = client.aisearch.tokens.list( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - order_by="created_at", - order_by_direction="asc", page=1, - per_page=1, + per_page=20, + search="my-token", ) assert_matches_type(SyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) @@ -189,34 +210,34 @@ def test_path_params_list(self, client: Cloudflare) -> None: @parametrize def test_method_delete(self, client: Cloudflare) -> None: token = client.aisearch.tokens.delete( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) - assert_matches_type(TokenDeleteResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.aisearch.tokens.with_raw_response.delete( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(TokenDeleteResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.aisearch.tokens.with_streaming_response.delete( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(TokenDeleteResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -224,7 +245,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.aisearch.tokens.with_raw_response.delete( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="", ) @@ -237,7 +258,7 @@ def test_path_params_delete(self, client: Cloudflare) -> None: @parametrize def test_method_read(self, client: Cloudflare) -> None: token = client.aisearch.tokens.read( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) assert_matches_type(TokenReadResponse, token, path=["response"]) @@ -245,7 +266,7 @@ def test_method_read(self, client: Cloudflare) -> None: @parametrize def test_raw_response_read(self, client: Cloudflare) -> None: response = client.aisearch.tokens.with_raw_response.read( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) @@ -257,7 +278,7 @@ def test_raw_response_read(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_read(self, client: Cloudflare) -> None: with client.aisearch.tokens.with_streaming_response.read( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) as response: assert not response.is_closed @@ -272,7 +293,7 @@ def test_streaming_response_read(self, client: Cloudflare) -> None: def test_path_params_read(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.aisearch.tokens.with_raw_response.read( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="", ) @@ -292,9 +313,20 @@ class TestAsyncTokens: async def test_method_create(self, async_client: AsyncCloudflare) -> None: token = await async_client.aisearch.tokens.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", + ) + assert_matches_type(TokenCreateResponse, token, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + token = await async_client.aisearch.tokens.create( + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", + legacy=True, ) assert_matches_type(TokenCreateResponse, token, path=["response"]) @@ -302,9 +334,9 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.aisearch.tokens.with_raw_response.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) assert response.is_closed is True @@ -316,9 +348,9 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.aisearch.tokens.with_streaming_response.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -333,30 +365,42 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.aisearch.tokens.with_raw_response.create( account_id="", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: token = await async_client.aisearch.tokens.update( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", + ) + assert_matches_type(TokenUpdateResponse, token, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + token = await async_client.aisearch.tokens.update( + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", + legacy=True, ) assert_matches_type(TokenUpdateResponse, token, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.aisearch.tokens.with_raw_response.update( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) assert response.is_closed is True @@ -367,11 +411,11 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.aisearch.tokens.with_streaming_response.update( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -385,20 +429,20 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.aisearch.tokens.with_raw_response.update( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): await async_client.aisearch.tokens.with_raw_response.update( id="", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - cf_api_id="cf_api_id", - cf_api_key="cf_api_key", - name="name", + cf_api_id="a1b2c3d4e5f6", + cf_api_key="abc123", + name="my-token", ) @parametrize @@ -412,10 +456,9 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: token = await async_client.aisearch.tokens.list( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - order_by="created_at", - order_by_direction="asc", page=1, - per_page=1, + per_page=20, + search="my-token", ) assert_matches_type(AsyncV4PagePaginationArray[TokenListResponse], token, path=["response"]) @@ -453,34 +496,34 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: token = await async_client.aisearch.tokens.delete( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) - assert_matches_type(TokenDeleteResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.aisearch.tokens.with_raw_response.delete( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(TokenDeleteResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.aisearch.tokens.with_streaming_response.delete( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(TokenDeleteResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -488,7 +531,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.aisearch.tokens.with_raw_response.delete( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="", ) @@ -501,7 +544,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_read(self, async_client: AsyncCloudflare) -> None: token = await async_client.aisearch.tokens.read( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) assert_matches_type(TokenReadResponse, token, path=["response"]) @@ -509,7 +552,7 @@ async def test_method_read(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_read(self, async_client: AsyncCloudflare) -> None: response = await async_client.aisearch.tokens.with_raw_response.read( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) @@ -521,7 +564,7 @@ async def test_raw_response_read(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_read(self, async_client: AsyncCloudflare) -> None: async with async_client.aisearch.tokens.with_streaming_response.read( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) as response: assert not response.is_closed @@ -536,7 +579,7 @@ async def test_streaming_response_read(self, async_client: AsyncCloudflare) -> N async def test_path_params_read(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.aisearch.tokens.with_raw_response.read( - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="62af0db3-c410-40b2-9ee3-0e93f6dd1de0", account_id="", ) diff --git a/tests/api_resources/api_gateway/test_user_schemas.py b/tests/api_resources/api_gateway/test_user_schemas.py index f3f6c21272d..1a910176cc2 100644 --- a/tests/api_resources/api_gateway/test_user_schemas.py +++ b/tests/api_resources/api_gateway/test_user_schemas.py @@ -29,7 +29,7 @@ def test_method_create(self, client: Cloudflare) -> None: with pytest.warns(DeprecationWarning): user_schema = client.api_gateway.user_schemas.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", ) @@ -40,7 +40,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: with pytest.warns(DeprecationWarning): user_schema = client.api_gateway.user_schemas.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", name="petstore schema", validation_enabled="true", @@ -53,7 +53,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: with pytest.warns(DeprecationWarning): response = client.api_gateway.user_schemas.with_raw_response.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", ) @@ -67,7 +67,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: with pytest.warns(DeprecationWarning): with client.api_gateway.user_schemas.with_streaming_response.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", ) as response: assert not response.is_closed @@ -84,7 +84,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): client.api_gateway.user_schemas.with_raw_response.create( zone_id="", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", ) @@ -336,7 +336,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: with pytest.warns(DeprecationWarning): user_schema = await async_client.api_gateway.user_schemas.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", ) @@ -347,7 +347,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare with pytest.warns(DeprecationWarning): user_schema = await async_client.api_gateway.user_schemas.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", name="petstore schema", validation_enabled="true", @@ -360,7 +360,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: with pytest.warns(DeprecationWarning): response = await async_client.api_gateway.user_schemas.with_raw_response.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", ) @@ -374,7 +374,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> with pytest.warns(DeprecationWarning): async with async_client.api_gateway.user_schemas.with_streaming_response.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", ) as response: assert not response.is_closed @@ -391,7 +391,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): await async_client.api_gateway.user_schemas.with_raw_response.create( zone_id="", - file=b"raw file contents", + file=b"Example data", kind="openapi_v3", ) diff --git a/tests/api_resources/audit_logs/__init__.py b/tests/api_resources/audit_logs/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/audit_logs/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/bot_management/__init__.py b/tests/api_resources/bot_management/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/bot_management/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/brand_protection/test_logos.py b/tests/api_resources/brand_protection/test_logos.py index 4d6740bb7f4..2929d549647 100644 --- a/tests/api_resources/brand_protection/test_logos.py +++ b/tests/api_resources/brand_protection/test_logos.py @@ -33,7 +33,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: match_type="match_type", tag="tag", threshold=0, - image=b"raw file contents", + image=b"Example data", ) assert_matches_type(LogoCreateResponse, logo, path=["response"]) @@ -145,7 +145,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare match_type="match_type", tag="tag", threshold=0, - image=b"raw file contents", + image=b"Example data", ) assert_matches_type(LogoCreateResponse, logo, path=["response"]) diff --git a/tests/api_resources/client_certificates/__init__.py b/tests/api_resources/client_certificates/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/client_certificates/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/cloudforce_one/test_binary_storage.py b/tests/api_resources/cloudforce_one/test_binary_storage.py index b26a1186d15..b340cae7122 100644 --- a/tests/api_resources/cloudforce_one/test_binary_storage.py +++ b/tests/api_resources/cloudforce_one/test_binary_storage.py @@ -22,7 +22,7 @@ class TestBinaryStorage: def test_method_create(self, client: Cloudflare) -> None: binary_storage = client.cloudforce_one.binary_storage.create( account_id="account_id", - file=b"raw file contents", + file=b"Example data", ) assert_matches_type(BinaryStorageCreateResponse, binary_storage, path=["response"]) @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: def test_raw_response_create(self, client: Cloudflare) -> None: response = client.cloudforce_one.binary_storage.with_raw_response.create( account_id="account_id", - file=b"raw file contents", + file=b"Example data", ) assert response.is_closed is True @@ -44,7 +44,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: def test_streaming_response_create(self, client: Cloudflare) -> None: with client.cloudforce_one.binary_storage.with_streaming_response.create( account_id="account_id", - file=b"raw file contents", + file=b"Example data", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -60,7 +60,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.cloudforce_one.binary_storage.with_raw_response.create( account_id="", - file=b"raw file contents", + file=b"Example data", ) @pytest.mark.skip(reason="TODO: HTTP 401 from prism") @@ -126,7 +126,7 @@ class TestAsyncBinaryStorage: async def test_method_create(self, async_client: AsyncCloudflare) -> None: binary_storage = await async_client.cloudforce_one.binary_storage.create( account_id="account_id", - file=b"raw file contents", + file=b"Example data", ) assert_matches_type(BinaryStorageCreateResponse, binary_storage, path=["response"]) @@ -135,7 +135,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.cloudforce_one.binary_storage.with_raw_response.create( account_id="account_id", - file=b"raw file contents", + file=b"Example data", ) assert response.is_closed is True @@ -148,7 +148,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.cloudforce_one.binary_storage.with_streaming_response.create( account_id="account_id", - file=b"raw file contents", + file=b"Example data", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -164,7 +164,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.cloudforce_one.binary_storage.with_raw_response.create( account_id="", - file=b"raw file contents", + file=b"Example data", ) @pytest.mark.skip(reason="TODO: HTTP 401 from prism") diff --git a/tests/api_resources/custom_nameservers/__init__.py b/tests/api_resources/custom_nameservers/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/custom_nameservers/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/custom_pages/test_assets.py b/tests/api_resources/custom_pages/test_assets.py index 774762c997a..0560ed5eedd 100644 --- a/tests/api_resources/custom_pages/test_assets.py +++ b/tests/api_resources/custom_pages/test_assets.py @@ -23,6 +23,7 @@ class TestAssets: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_create(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.create( @@ -33,6 +34,7 @@ def test_method_create(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AssetCreateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.create( @@ -43,6 +45,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AssetCreateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.custom_pages.assets.with_raw_response.create( @@ -57,6 +60,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: asset = response.parse() assert_matches_type(Optional[AssetCreateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.custom_pages.assets.with_streaming_response.create( @@ -73,6 +77,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): @@ -91,6 +96,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_update(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.update( @@ -101,6 +107,7 @@ def test_method_update(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AssetUpdateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.update( @@ -111,6 +118,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AssetUpdateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.custom_pages.assets.with_raw_response.update( @@ -125,6 +133,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: asset = response.parse() assert_matches_type(Optional[AssetUpdateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: with client.custom_pages.assets.with_streaming_response.update( @@ -141,6 +150,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `asset_name` but received ''"): @@ -167,6 +177,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_list(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.list( @@ -174,6 +185,7 @@ def test_method_list(self, client: Cloudflare) -> None: ) assert_matches_type(SyncV4PagePaginationArray[AssetListResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.list( @@ -183,6 +195,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(SyncV4PagePaginationArray[AssetListResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.custom_pages.assets.with_raw_response.list( @@ -194,6 +207,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: asset = response.parse() assert_matches_type(SyncV4PagePaginationArray[AssetListResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.custom_pages.assets.with_streaming_response.list( @@ -207,6 +221,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_path_params_list(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): @@ -219,6 +234,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_delete(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.delete( @@ -227,6 +243,7 @@ def test_method_delete(self, client: Cloudflare) -> None: ) assert asset is None + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_delete_with_all_params(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.delete( @@ -235,6 +252,7 @@ def test_method_delete_with_all_params(self, client: Cloudflare) -> None: ) assert asset is None + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.custom_pages.assets.with_raw_response.delete( @@ -247,6 +265,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: asset = response.parse() assert asset is None + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.custom_pages.assets.with_streaming_response.delete( @@ -261,6 +280,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `asset_name` but received ''"): @@ -281,6 +301,7 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_get(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.get( @@ -289,6 +310,7 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AssetGetResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: asset = client.custom_pages.assets.get( @@ -297,6 +319,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AssetGetResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.custom_pages.assets.with_raw_response.get( @@ -309,6 +332,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: asset = response.parse() assert_matches_type(Optional[AssetGetResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.custom_pages.assets.with_streaming_response.get( @@ -323,6 +347,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `asset_name` but received ''"): @@ -349,6 +374,7 @@ class TestAsyncAssets: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.create( @@ -359,6 +385,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[AssetCreateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.create( @@ -369,6 +396,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ) assert_matches_type(Optional[AssetCreateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.custom_pages.assets.with_raw_response.create( @@ -383,6 +411,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: asset = await response.parse() assert_matches_type(Optional[AssetCreateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.custom_pages.assets.with_streaming_response.create( @@ -399,6 +428,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): @@ -417,6 +447,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.update( @@ -427,6 +458,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[AssetUpdateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.update( @@ -437,6 +469,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare ) assert_matches_type(Optional[AssetUpdateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.custom_pages.assets.with_raw_response.update( @@ -451,6 +484,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: asset = await response.parse() assert_matches_type(Optional[AssetUpdateResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.custom_pages.assets.with_streaming_response.update( @@ -467,6 +501,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `asset_name` but received ''"): @@ -493,6 +528,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.list( @@ -500,6 +536,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(AsyncV4PagePaginationArray[AssetListResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.list( @@ -509,6 +546,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) ) assert_matches_type(AsyncV4PagePaginationArray[AssetListResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.custom_pages.assets.with_raw_response.list( @@ -520,6 +558,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: asset = await response.parse() assert_matches_type(AsyncV4PagePaginationArray[AssetListResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.custom_pages.assets.with_streaming_response.list( @@ -533,6 +572,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): @@ -545,6 +585,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.delete( @@ -553,6 +594,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ) assert asset is None + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.delete( @@ -561,6 +603,7 @@ async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare ) assert asset is None + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.custom_pages.assets.with_raw_response.delete( @@ -573,6 +616,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: asset = await response.parse() assert asset is None + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.custom_pages.assets.with_streaming_response.delete( @@ -587,6 +631,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `asset_name` but received ''"): @@ -607,6 +652,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.get( @@ -615,6 +661,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[AssetGetResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: asset = await async_client.custom_pages.assets.get( @@ -623,6 +670,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - ) assert_matches_type(Optional[AssetGetResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.custom_pages.assets.with_raw_response.get( @@ -635,6 +683,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: asset = await response.parse() assert_matches_type(Optional[AssetGetResponse], asset, path=["response"]) + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.custom_pages.assets.with_streaming_response.get( @@ -649,6 +698,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="test missing required zone_id argument") @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `asset_name` but received ''"): diff --git a/tests/api_resources/dcv_delegation/__init__.py b/tests/api_resources/dcv_delegation/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/dcv_delegation/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/filters/__init__.py b/tests/api_resources/filters/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/filters/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/fraud/__init__.py b/tests/api_resources/fraud/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/fraud/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/hostnames/settings/test_tls.py b/tests/api_resources/hostnames/settings/test_tls.py index a9849e27c15..09b8b27b4f8 100644 --- a/tests/api_resources/hostnames/settings/test_tls.py +++ b/tests/api_resources/hostnames/settings/test_tls.py @@ -28,7 +28,7 @@ def test_method_update(self, client: Cloudflare) -> None: hostname="app.example.com", zone_id="023e105f4ecef8ad9ca31a8372d0c353", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) assert_matches_type(Optional[Setting], tls, path=["response"]) @@ -38,7 +38,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: hostname="app.example.com", zone_id="023e105f4ecef8ad9ca31a8372d0c353", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) assert response.is_closed is True @@ -52,7 +52,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: hostname="app.example.com", zone_id="023e105f4ecef8ad9ca31a8372d0c353", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -69,7 +69,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: hostname="app.example.com", zone_id="", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): @@ -77,7 +77,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: hostname="", zone_id="023e105f4ecef8ad9ca31a8372d0c353", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) @parametrize @@ -187,7 +187,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: hostname="app.example.com", zone_id="023e105f4ecef8ad9ca31a8372d0c353", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) assert_matches_type(Optional[Setting], tls, path=["response"]) @@ -197,7 +197,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: hostname="app.example.com", zone_id="023e105f4ecef8ad9ca31a8372d0c353", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) assert response.is_closed is True @@ -211,7 +211,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> hostname="app.example.com", zone_id="023e105f4ecef8ad9ca31a8372d0c353", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -228,7 +228,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: hostname="app.example.com", zone_id="", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): @@ -236,7 +236,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: hostname="", zone_id="023e105f4ecef8ad9ca31a8372d0c353", setting_id="ciphers", - value="1.0", + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"], ) @parametrize diff --git a/tests/api_resources/images/test_v1.py b/tests/api_resources/images/test_v1.py index 2e168db2008..6f7c4f40b1f 100644 --- a/tests/api_resources/images/test_v1.py +++ b/tests/api_resources/images/test_v1.py @@ -39,7 +39,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", id="id", creator="creator", - file=b"raw file contents", + file=b"Example data", metadata={}, require_signed_urls=True, url="https://example.com/path/to/logo.png", @@ -311,7 +311,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_id="023e105f4ecef8ad9ca31a8372d0c353", id="id", creator="creator", - file=b"raw file contents", + file=b"Example data", metadata={}, require_signed_urls=True, url="https://example.com/path/to/logo.png", diff --git a/tests/api_resources/ips/__init__.py b/tests/api_resources/ips/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/ips/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/keyless_certificates/__init__.py b/tests/api_resources/keyless_certificates/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/keyless_certificates/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/magic_network_monitoring/test_rules.py b/tests/api_resources/magic_network_monitoring/test_rules.py index ed21c61d4c9..a3683263b43 100644 --- a/tests/api_resources/magic_network_monitoring/test_rules.py +++ b/tests/api_resources/magic_network_monitoring/test_rules.py @@ -20,6 +20,7 @@ class TestRules: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_method_create(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.create( @@ -31,6 +32,7 @@ def test_method_create(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.create( @@ -48,6 +50,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.magic_network_monitoring.rules.with_raw_response.create( @@ -63,6 +66,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: rule = response.parse() assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.magic_network_monitoring.rules.with_streaming_response.create( @@ -80,6 +84,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -167,6 +172,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: type="zscore", ) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_method_list(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.list( @@ -174,6 +180,7 @@ def test_method_list(self, client: Cloudflare) -> None: ) assert_matches_type(SyncSinglePage[Optional[MagicNetworkMonitoringRule]], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.magic_network_monitoring.rules.with_raw_response.list( @@ -185,6 +192,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: rule = response.parse() assert_matches_type(SyncSinglePage[Optional[MagicNetworkMonitoringRule]], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.magic_network_monitoring.rules.with_streaming_response.list( @@ -198,6 +206,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_path_params_list(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -205,6 +214,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_method_delete(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.delete( @@ -213,6 +223,7 @@ def test_method_delete(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.magic_network_monitoring.rules.with_raw_response.delete( @@ -225,6 +236,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: rule = response.parse() assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.magic_network_monitoring.rules.with_streaming_response.delete( @@ -239,6 +251,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -253,6 +266,7 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="6f91088a406011ed95aed352566e8d4c", ) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_method_edit(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.edit( @@ -265,6 +279,7 @@ def test_method_edit(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_method_edit_with_all_params(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.edit( @@ -283,6 +298,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: response = client.magic_network_monitoring.rules.with_raw_response.edit( @@ -299,6 +315,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: rule = response.parse() assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: with client.magic_network_monitoring.rules.with_streaming_response.edit( @@ -317,6 +334,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_path_params_edit(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -339,6 +357,7 @@ def test_path_params_edit(self, client: Cloudflare) -> None: type="zscore", ) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_method_get(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.get( @@ -347,6 +366,7 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.magic_network_monitoring.rules.with_raw_response.get( @@ -359,6 +379,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: rule = response.parse() assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.magic_network_monitoring.rules.with_streaming_response.get( @@ -373,6 +394,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -393,6 +415,7 @@ class TestAsyncRules: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.create( @@ -404,6 +427,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.create( @@ -421,6 +445,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_network_monitoring.rules.with_raw_response.create( @@ -436,6 +461,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: rule = await response.parse() assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_network_monitoring.rules.with_streaming_response.create( @@ -453,6 +479,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -540,6 +567,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: type="zscore", ) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.list( @@ -547,6 +575,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(AsyncSinglePage[Optional[MagicNetworkMonitoringRule]], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_network_monitoring.rules.with_raw_response.list( @@ -558,6 +587,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: rule = await response.parse() assert_matches_type(AsyncSinglePage[Optional[MagicNetworkMonitoringRule]], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_network_monitoring.rules.with_streaming_response.list( @@ -571,6 +601,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -578,6 +609,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: account_id="", ) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.delete( @@ -586,6 +618,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_network_monitoring.rules.with_raw_response.delete( @@ -598,6 +631,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: rule = await response.parse() assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_network_monitoring.rules.with_streaming_response.delete( @@ -612,6 +646,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -626,6 +661,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: account_id="6f91088a406011ed95aed352566e8d4c", ) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.edit( @@ -638,6 +674,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.edit( @@ -656,6 +693,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_network_monitoring.rules.with_raw_response.edit( @@ -672,6 +710,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: rule = await response.parse() assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_network_monitoring.rules.with_streaming_response.edit( @@ -690,6 +729,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -712,6 +752,7 @@ async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: type="zscore", ) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.get( @@ -720,6 +761,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_network_monitoring.rules.with_raw_response.get( @@ -732,6 +774,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: rule = await response.parse() assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_network_monitoring.rules.with_streaming_response.get( @@ -746,6 +789,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422 Unprocessable Entity") @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): diff --git a/tests/api_resources/managed_transforms/__init__.py b/tests/api_resources/managed_transforms/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/managed_transforms/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/memberships/__init__.py b/tests/api_resources/memberships/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/memberships/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/origin_ca_certificates/__init__.py b/tests/api_resources/origin_ca_certificates/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/origin_ca_certificates/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/origin_post_quantum_encryption/__init__.py b/tests/api_resources/origin_post_quantum_encryption/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/origin_post_quantum_encryption/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/page_rules/__init__.py b/tests/api_resources/page_rules/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/page_rules/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/pages/projects/test_deployments.py b/tests/api_resources/pages/projects/test_deployments.py index 3b8446648fc..6b5617694a5 100644 --- a/tests/api_resources/pages/projects/test_deployments.py +++ b/tests/api_resources/pages/projects/test_deployments.py @@ -33,16 +33,16 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: deployment = client.pages.projects.deployments.create( project_name="this-is-my-project-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", - _headers=b"raw file contents", - _redirects=b"raw file contents", - _routes_json=b"raw file contents", - _worker_bundle=b"raw file contents", - _worker_js=b"raw file contents", + _headers=b"Example data", + _redirects=b"Example data", + _routes_json=b"Example data", + _worker_bundle=b"Example data", + _worker_js=b"Example data", branch="staging", commit_dirty="false", commit_hash="a1b2c3d4e5f6", commit_message="Update homepage", - functions_filepath_routing_config_json=b"raw file contents", + functions_filepath_routing_config_json=b"Example data", manifest='{"index.html": "abc123", "style.css": "def456"}', pages_build_output_dir="dist", wrangler_config_hash="wrangler_config_hash", @@ -160,6 +160,16 @@ def test_method_delete(self, client: Cloudflare) -> None: ) assert_matches_type(object, deployment, path=["response"]) + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + deployment = client.pages.projects.deployments.delete( + deployment_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + project_name="this-is-my-project-01", + force=True, + ) + assert_matches_type(object, deployment, path=["response"]) + @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.pages.projects.deployments.with_raw_response.delete( @@ -412,16 +422,16 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare deployment = await async_client.pages.projects.deployments.create( project_name="this-is-my-project-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", - _headers=b"raw file contents", - _redirects=b"raw file contents", - _routes_json=b"raw file contents", - _worker_bundle=b"raw file contents", - _worker_js=b"raw file contents", + _headers=b"Example data", + _redirects=b"Example data", + _routes_json=b"Example data", + _worker_bundle=b"Example data", + _worker_js=b"Example data", branch="staging", commit_dirty="false", commit_hash="a1b2c3d4e5f6", commit_message="Update homepage", - functions_filepath_routing_config_json=b"raw file contents", + functions_filepath_routing_config_json=b"Example data", manifest='{"index.html": "abc123", "style.css": "def456"}', pages_build_output_dir="dist", wrangler_config_hash="wrangler_config_hash", @@ -539,6 +549,16 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(object, deployment, path=["response"]) + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + deployment = await async_client.pages.projects.deployments.delete( + deployment_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + project_name="this-is-my-project-01", + force=True, + ) + assert_matches_type(object, deployment, path=["response"]) + @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.pages.projects.deployments.with_raw_response.delete( diff --git a/tests/api_resources/queues/test_messages.py b/tests/api_resources/queues/test_messages.py index f53b6239ae1..cffb0efa879 100644 --- a/tests/api_resources/queues/test_messages.py +++ b/tests/api_resources/queues/test_messages.py @@ -95,7 +95,7 @@ def test_method_bulk_push(self, client: Cloudflare) -> None: queue_id="023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(MessageBulkPushResponse, message, path=["response"]) + assert_matches_type(Optional[MessageBulkPushResponse], message, path=["response"]) @parametrize def test_method_bulk_push_with_all_params(self, client: Cloudflare) -> None: @@ -111,7 +111,7 @@ def test_method_bulk_push_with_all_params(self, client: Cloudflare) -> None: } ], ) - assert_matches_type(MessageBulkPushResponse, message, path=["response"]) + assert_matches_type(Optional[MessageBulkPushResponse], message, path=["response"]) @parametrize def test_raw_response_bulk_push(self, client: Cloudflare) -> None: @@ -123,7 +123,7 @@ def test_raw_response_bulk_push(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageBulkPushResponse, message, path=["response"]) + assert_matches_type(Optional[MessageBulkPushResponse], message, path=["response"]) @parametrize def test_streaming_response_bulk_push(self, client: Cloudflare) -> None: @@ -135,7 +135,7 @@ def test_streaming_response_bulk_push(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageBulkPushResponse, message, path=["response"]) + assert_matches_type(Optional[MessageBulkPushResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -217,7 +217,7 @@ def test_method_push_overload_1(self, client: Cloudflare) -> None: queue_id="023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize def test_method_push_with_all_params_overload_1(self, client: Cloudflare) -> None: @@ -228,7 +228,7 @@ def test_method_push_with_all_params_overload_1(self, client: Cloudflare) -> Non content_type="text", delay_seconds=0, ) - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize def test_raw_response_push_overload_1(self, client: Cloudflare) -> None: @@ -240,7 +240,7 @@ def test_raw_response_push_overload_1(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize def test_streaming_response_push_overload_1(self, client: Cloudflare) -> None: @@ -252,7 +252,7 @@ def test_streaming_response_push_overload_1(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -276,7 +276,7 @@ def test_method_push_overload_2(self, client: Cloudflare) -> None: queue_id="023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize def test_method_push_with_all_params_overload_2(self, client: Cloudflare) -> None: @@ -287,7 +287,7 @@ def test_method_push_with_all_params_overload_2(self, client: Cloudflare) -> Non content_type="json", delay_seconds=0, ) - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize def test_raw_response_push_overload_2(self, client: Cloudflare) -> None: @@ -299,7 +299,7 @@ def test_raw_response_push_overload_2(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize def test_streaming_response_push_overload_2(self, client: Cloudflare) -> None: @@ -311,7 +311,7 @@ def test_streaming_response_push_overload_2(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -408,7 +408,7 @@ async def test_method_bulk_push(self, async_client: AsyncCloudflare) -> None: queue_id="023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(MessageBulkPushResponse, message, path=["response"]) + assert_matches_type(Optional[MessageBulkPushResponse], message, path=["response"]) @parametrize async def test_method_bulk_push_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -424,7 +424,7 @@ async def test_method_bulk_push_with_all_params(self, async_client: AsyncCloudfl } ], ) - assert_matches_type(MessageBulkPushResponse, message, path=["response"]) + assert_matches_type(Optional[MessageBulkPushResponse], message, path=["response"]) @parametrize async def test_raw_response_bulk_push(self, async_client: AsyncCloudflare) -> None: @@ -436,7 +436,7 @@ async def test_raw_response_bulk_push(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageBulkPushResponse, message, path=["response"]) + assert_matches_type(Optional[MessageBulkPushResponse], message, path=["response"]) @parametrize async def test_streaming_response_bulk_push(self, async_client: AsyncCloudflare) -> None: @@ -448,7 +448,7 @@ async def test_streaming_response_bulk_push(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageBulkPushResponse, message, path=["response"]) + assert_matches_type(Optional[MessageBulkPushResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -530,7 +530,7 @@ async def test_method_push_overload_1(self, async_client: AsyncCloudflare) -> No queue_id="023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize async def test_method_push_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: @@ -541,7 +541,7 @@ async def test_method_push_with_all_params_overload_1(self, async_client: AsyncC content_type="text", delay_seconds=0, ) - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize async def test_raw_response_push_overload_1(self, async_client: AsyncCloudflare) -> None: @@ -553,7 +553,7 @@ async def test_raw_response_push_overload_1(self, async_client: AsyncCloudflare) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize async def test_streaming_response_push_overload_1(self, async_client: AsyncCloudflare) -> None: @@ -565,7 +565,7 @@ async def test_streaming_response_push_overload_1(self, async_client: AsyncCloud assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -589,7 +589,7 @@ async def test_method_push_overload_2(self, async_client: AsyncCloudflare) -> No queue_id="023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize async def test_method_push_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: @@ -600,7 +600,7 @@ async def test_method_push_with_all_params_overload_2(self, async_client: AsyncC content_type="json", delay_seconds=0, ) - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize async def test_raw_response_push_overload_2(self, async_client: AsyncCloudflare) -> None: @@ -612,7 +612,7 @@ async def test_raw_response_push_overload_2(self, async_client: AsyncCloudflare) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) @parametrize async def test_streaming_response_push_overload_2(self, async_client: AsyncCloudflare) -> None: @@ -624,7 +624,7 @@ async def test_streaming_response_push_overload_2(self, async_client: AsyncCloud assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessagePushResponse, message, path=["response"]) + assert_matches_type(Optional[MessagePushResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/radar/ai/test_markdown_for_agents.py b/tests/api_resources/radar/ai/test_markdown_for_agents.py new file mode 100644 index 00000000000..ed5c419d288 --- /dev/null +++ b/tests/api_resources/radar/ai/test_markdown_for_agents.py @@ -0,0 +1,174 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime +from cloudflare.types.radar.ai import ( + MarkdownForAgentSummaryResponse, + MarkdownForAgentTimeseriesResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestMarkdownForAgents: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_summary(self, client: Cloudflare) -> None: + markdown_for_agent = client.radar.ai.markdown_for_agents.summary() + assert_matches_type(MarkdownForAgentSummaryResponse, markdown_for_agent, path=["response"]) + + @parametrize + def test_method_summary_with_all_params(self, client: Cloudflare) -> None: + markdown_for_agent = client.radar.ai.markdown_for_agents.summary( + date_end=[parse_datetime("2019-12-27T18:11:19.117Z")], + date_range=["7d"], + date_start=[parse_datetime("2019-12-27T18:11:19.117Z")], + format="JSON", + name=["main_series"], + ) + assert_matches_type(MarkdownForAgentSummaryResponse, markdown_for_agent, path=["response"]) + + @parametrize + def test_raw_response_summary(self, client: Cloudflare) -> None: + response = client.radar.ai.markdown_for_agents.with_raw_response.summary() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + markdown_for_agent = response.parse() + assert_matches_type(MarkdownForAgentSummaryResponse, markdown_for_agent, path=["response"]) + + @parametrize + def test_streaming_response_summary(self, client: Cloudflare) -> None: + with client.radar.ai.markdown_for_agents.with_streaming_response.summary() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + markdown_for_agent = response.parse() + assert_matches_type(MarkdownForAgentSummaryResponse, markdown_for_agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_timeseries(self, client: Cloudflare) -> None: + markdown_for_agent = client.radar.ai.markdown_for_agents.timeseries() + assert_matches_type(MarkdownForAgentTimeseriesResponse, markdown_for_agent, path=["response"]) + + @parametrize + def test_method_timeseries_with_all_params(self, client: Cloudflare) -> None: + markdown_for_agent = client.radar.ai.markdown_for_agents.timeseries( + agg_interval="1h", + date_end=[parse_datetime("2019-12-27T18:11:19.117Z")], + date_range=["7d"], + date_start=[parse_datetime("2019-12-27T18:11:19.117Z")], + format="JSON", + name=["main_series"], + ) + assert_matches_type(MarkdownForAgentTimeseriesResponse, markdown_for_agent, path=["response"]) + + @parametrize + def test_raw_response_timeseries(self, client: Cloudflare) -> None: + response = client.radar.ai.markdown_for_agents.with_raw_response.timeseries() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + markdown_for_agent = response.parse() + assert_matches_type(MarkdownForAgentTimeseriesResponse, markdown_for_agent, path=["response"]) + + @parametrize + def test_streaming_response_timeseries(self, client: Cloudflare) -> None: + with client.radar.ai.markdown_for_agents.with_streaming_response.timeseries() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + markdown_for_agent = response.parse() + assert_matches_type(MarkdownForAgentTimeseriesResponse, markdown_for_agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncMarkdownForAgents: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_summary(self, async_client: AsyncCloudflare) -> None: + markdown_for_agent = await async_client.radar.ai.markdown_for_agents.summary() + assert_matches_type(MarkdownForAgentSummaryResponse, markdown_for_agent, path=["response"]) + + @parametrize + async def test_method_summary_with_all_params(self, async_client: AsyncCloudflare) -> None: + markdown_for_agent = await async_client.radar.ai.markdown_for_agents.summary( + date_end=[parse_datetime("2019-12-27T18:11:19.117Z")], + date_range=["7d"], + date_start=[parse_datetime("2019-12-27T18:11:19.117Z")], + format="JSON", + name=["main_series"], + ) + assert_matches_type(MarkdownForAgentSummaryResponse, markdown_for_agent, path=["response"]) + + @parametrize + async def test_raw_response_summary(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.ai.markdown_for_agents.with_raw_response.summary() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + markdown_for_agent = await response.parse() + assert_matches_type(MarkdownForAgentSummaryResponse, markdown_for_agent, path=["response"]) + + @parametrize + async def test_streaming_response_summary(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.ai.markdown_for_agents.with_streaming_response.summary() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + markdown_for_agent = await response.parse() + assert_matches_type(MarkdownForAgentSummaryResponse, markdown_for_agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_timeseries(self, async_client: AsyncCloudflare) -> None: + markdown_for_agent = await async_client.radar.ai.markdown_for_agents.timeseries() + assert_matches_type(MarkdownForAgentTimeseriesResponse, markdown_for_agent, path=["response"]) + + @parametrize + async def test_method_timeseries_with_all_params(self, async_client: AsyncCloudflare) -> None: + markdown_for_agent = await async_client.radar.ai.markdown_for_agents.timeseries( + agg_interval="1h", + date_end=[parse_datetime("2019-12-27T18:11:19.117Z")], + date_range=["7d"], + date_start=[parse_datetime("2019-12-27T18:11:19.117Z")], + format="JSON", + name=["main_series"], + ) + assert_matches_type(MarkdownForAgentTimeseriesResponse, markdown_for_agent, path=["response"]) + + @parametrize + async def test_raw_response_timeseries(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.ai.markdown_for_agents.with_raw_response.timeseries() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + markdown_for_agent = await response.parse() + assert_matches_type(MarkdownForAgentTimeseriesResponse, markdown_for_agent, path=["response"]) + + @parametrize + async def test_streaming_response_timeseries(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.ai.markdown_for_agents.with_streaming_response.timeseries() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + markdown_for_agent = await response.parse() + assert_matches_type(MarkdownForAgentTimeseriesResponse, markdown_for_agent, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/radar/ai/test_to_markdown.py b/tests/api_resources/radar/ai/test_to_markdown.py index 1241e0782b2..1c7fa754f46 100644 --- a/tests/api_resources/radar/ai/test_to_markdown.py +++ b/tests/api_resources/radar/ai/test_to_markdown.py @@ -26,7 +26,7 @@ def test_method_create(self, client: Cloudflare) -> None: with pytest.warns(DeprecationWarning): to_markdown = client.radar.ai.to_markdown.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", - files=[b"raw file contents"], + files=[b"Example data"], ) assert_matches_type(SyncSinglePage[ToMarkdownCreateResponse], to_markdown, path=["response"]) @@ -37,7 +37,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: with pytest.warns(DeprecationWarning): response = client.radar.ai.to_markdown.with_raw_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", - files=[b"raw file contents"], + files=[b"Example data"], ) assert response.is_closed is True @@ -51,7 +51,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: with pytest.warns(DeprecationWarning): with client.radar.ai.to_markdown.with_streaming_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", - files=[b"raw file contents"], + files=[b"Example data"], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -68,7 +68,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.radar.ai.to_markdown.with_raw_response.create( account_id="", - files=[b"raw file contents"], + files=[b"Example data"], ) @@ -83,7 +83,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: with pytest.warns(DeprecationWarning): to_markdown = await async_client.radar.ai.to_markdown.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", - files=[b"raw file contents"], + files=[b"Example data"], ) assert_matches_type(AsyncSinglePage[ToMarkdownCreateResponse], to_markdown, path=["response"]) @@ -94,7 +94,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: with pytest.warns(DeprecationWarning): response = await async_client.radar.ai.to_markdown.with_raw_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", - files=[b"raw file contents"], + files=[b"Example data"], ) assert response.is_closed is True @@ -108,7 +108,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> with pytest.warns(DeprecationWarning): async with async_client.radar.ai.to_markdown.with_streaming_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", - files=[b"raw file contents"], + files=[b"Example data"], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -125,5 +125,5 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.radar.ai.to_markdown.with_raw_response.create( account_id="", - files=[b"raw file contents"], + files=[b"Example data"], ) diff --git a/tests/api_resources/radar/test_agent_readiness.py b/tests/api_resources/radar/test_agent_readiness.py new file mode 100644 index 00000000000..d8ebdee6540 --- /dev/null +++ b/tests/api_resources/radar/test_agent_readiness.py @@ -0,0 +1,109 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_date +from cloudflare.types.radar import AgentReadinessSummaryResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAgentReadiness: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_summary(self, client: Cloudflare) -> None: + agent_readiness = client.radar.agent_readiness.summary( + dimension="CHECK", + ) + assert_matches_type(AgentReadinessSummaryResponse, agent_readiness, path=["response"]) + + @parametrize + def test_method_summary_with_all_params(self, client: Cloudflare) -> None: + agent_readiness = client.radar.agent_readiness.summary( + dimension="CHECK", + date=parse_date("2024-09-19"), + domain_category=["string"], + format="JSON", + name=["main_series"], + ) + assert_matches_type(AgentReadinessSummaryResponse, agent_readiness, path=["response"]) + + @parametrize + def test_raw_response_summary(self, client: Cloudflare) -> None: + response = client.radar.agent_readiness.with_raw_response.summary( + dimension="CHECK", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent_readiness = response.parse() + assert_matches_type(AgentReadinessSummaryResponse, agent_readiness, path=["response"]) + + @parametrize + def test_streaming_response_summary(self, client: Cloudflare) -> None: + with client.radar.agent_readiness.with_streaming_response.summary( + dimension="CHECK", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent_readiness = response.parse() + assert_matches_type(AgentReadinessSummaryResponse, agent_readiness, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncAgentReadiness: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_summary(self, async_client: AsyncCloudflare) -> None: + agent_readiness = await async_client.radar.agent_readiness.summary( + dimension="CHECK", + ) + assert_matches_type(AgentReadinessSummaryResponse, agent_readiness, path=["response"]) + + @parametrize + async def test_method_summary_with_all_params(self, async_client: AsyncCloudflare) -> None: + agent_readiness = await async_client.radar.agent_readiness.summary( + dimension="CHECK", + date=parse_date("2024-09-19"), + domain_category=["string"], + format="JSON", + name=["main_series"], + ) + assert_matches_type(AgentReadinessSummaryResponse, agent_readiness, path=["response"]) + + @parametrize + async def test_raw_response_summary(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.agent_readiness.with_raw_response.summary( + dimension="CHECK", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent_readiness = await response.parse() + assert_matches_type(AgentReadinessSummaryResponse, agent_readiness, path=["response"]) + + @parametrize + async def test_streaming_response_summary(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.agent_readiness.with_streaming_response.summary( + dimension="CHECK", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent_readiness = await response.parse() + assert_matches_type(AgentReadinessSummaryResponse, agent_readiness, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/rate_limits/__init__.py b/tests/api_resources/rate_limits/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/rate_limits/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/registrar/test_registrations.py b/tests/api_resources/registrar/test_registrations.py index 0b27ab21b9b..74074924a6d 100644 --- a/tests/api_resources/registrar/test_registrations.py +++ b/tests/api_resources/registrar/test_registrations.py @@ -9,6 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare.pagination import SyncCursorPagination, AsyncCursorPagination from cloudflare.types.registrar import ( Registration, WorkflowStatus, @@ -92,6 +93,56 @@ def test_path_params_create(self, client: Cloudflare) -> None: domain_name="my-new-startup.com", ) + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + registration = client.registrar.registrations.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncCursorPagination[Registration], registration, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + registration = client.registrar.registrations.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cursor="cursor", + direction="asc", + per_page=1, + sort_by="registry_created_at", + ) + assert_matches_type(SyncCursorPagination[Registration], registration, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.registrar.registrations.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + registration = response.parse() + assert_matches_type(SyncCursorPagination[Registration], registration, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.registrar.registrations.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + registration = response.parse() + assert_matches_type(SyncCursorPagination[Registration], registration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.registrar.registrations.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize def test_method_edit(self, client: Cloudflare) -> None: registration = client.registrar.registrations.edit( @@ -100,6 +151,7 @@ def test_method_edit(self, client: Cloudflare) -> None: ) assert_matches_type(WorkflowStatus, registration, path=["response"]) + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize def test_method_edit_with_all_params(self, client: Cloudflare) -> None: registration = client.registrar.registrations.edit( @@ -110,6 +162,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(WorkflowStatus, registration, path=["response"]) + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: response = client.registrar.registrations.with_raw_response.edit( @@ -122,6 +175,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: registration = response.parse() assert_matches_type(WorkflowStatus, registration, path=["response"]) + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: with client.registrar.registrations.with_streaming_response.edit( @@ -136,6 +190,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize def test_path_params_edit(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -276,6 +331,56 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: domain_name="my-new-startup.com", ) + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + registration = await async_client.registrar.registrations.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncCursorPagination[Registration], registration, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + registration = await async_client.registrar.registrations.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cursor="cursor", + direction="asc", + per_page=1, + sort_by="registry_created_at", + ) + assert_matches_type(AsyncCursorPagination[Registration], registration, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.registrar.registrations.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + registration = await response.parse() + assert_matches_type(AsyncCursorPagination[Registration], registration, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.registrar.registrations.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + registration = await response.parse() + assert_matches_type(AsyncCursorPagination[Registration], registration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.registrar.registrations.with_raw_response.list( + account_id="", + ) + + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: registration = await async_client.registrar.registrations.edit( @@ -284,6 +389,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(WorkflowStatus, registration, path=["response"]) + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: registration = await async_client.registrar.registrations.edit( @@ -294,6 +400,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) ) assert_matches_type(WorkflowStatus, registration, path=["response"]) + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: response = await async_client.registrar.registrations.with_raw_response.edit( @@ -306,6 +413,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: registration = await response.parse() assert_matches_type(WorkflowStatus, registration, path=["response"]) + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: async with async_client.registrar.registrations.with_streaming_response.edit( @@ -320,6 +428,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="422: Prism mock rejects test fixture domain with 'Domain not found'") @parametrize async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): diff --git a/tests/api_resources/rulesets/__init__.py b/tests/api_resources/rulesets/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/rulesets/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/rulesets/phases/__init__.py b/tests/api_resources/rulesets/phases/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/rulesets/phases/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/rulesets/phases/test_versions.py b/tests/api_resources/rulesets/phases/test_versions.py new file mode 100644 index 00000000000..002f11ccc12 --- /dev/null +++ b/tests/api_resources/rulesets/phases/test_versions.py @@ -0,0 +1,295 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.rulesets.phases import VersionGetResponse, VersionListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestVersions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + version = client.rulesets.phases.versions.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + version = client.rulesets.phases.versions.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.rulesets.phases.versions.with_raw_response.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = response.parse() + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.rulesets.phases.versions.with_streaming_response.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = response.parse() + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.phases.versions.with_raw_response.list( + ruleset_phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.phases.versions.with_raw_response.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + version = client.rulesets.phases.versions.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + version = client.rulesets.phases.versions.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.rulesets.phases.versions.with_raw_response.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.rulesets.phases.versions.with_streaming_response.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_version` but received ''"): + client.rulesets.phases.versions.with_raw_response.get( + ruleset_version="", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.phases.versions.with_raw_response.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.phases.versions.with_raw_response.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + +class TestAsyncVersions: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.phases.versions.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.phases.versions.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.phases.versions.with_raw_response.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = await response.parse() + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.phases.versions.with_streaming_response.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = await response.parse() + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.phases.versions.with_raw_response.list( + ruleset_phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.phases.versions.with_raw_response.list( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.phases.versions.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.phases.versions.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.phases.versions.with_raw_response.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = await response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.phases.versions.with_streaming_response.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = await response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_version` but received ''"): + await async_client.rulesets.phases.versions.with_raw_response.get( + ruleset_version="", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.phases.versions.with_raw_response.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.phases.versions.with_raw_response.get( + ruleset_version="1", + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) diff --git a/tests/api_resources/rulesets/test_phases.py b/tests/api_resources/rulesets/test_phases.py new file mode 100644 index 00000000000..27f2dfd5373 --- /dev/null +++ b/tests/api_resources/rulesets/test_phases.py @@ -0,0 +1,336 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.rulesets import PhaseGetResponse, PhaseUpdateResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestPhases: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + phase = client.rulesets.phases.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + phase = client.rulesets.phases.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + description="A description for my ruleset.", + name="My ruleset", + rules=[ + { + "id": "3a03d665bac047339bb530ecb439a90d", + "action": "block", + "action_parameters": { + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + "description": "Block the request.", + "enabled": True, + "exposed_credential_check": { + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + "expression": "ip.src eq 1.1.1.1", + "logging": {"enabled": True}, + "ratelimit": { + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + "ref": "my_ref", + } + ], + ) + assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.rulesets.phases.with_raw_response.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + phase = response.parse() + assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.rulesets.phases.with_streaming_response.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + phase = response.parse() + assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.phases.with_raw_response.update( + ruleset_phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.phases.with_raw_response.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + phase = client.rulesets.phases.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(PhaseGetResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + phase = client.rulesets.phases.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(PhaseGetResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.rulesets.phases.with_raw_response.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + phase = response.parse() + assert_matches_type(PhaseGetResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.rulesets.phases.with_streaming_response.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + phase = response.parse() + assert_matches_type(PhaseGetResponse, phase, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.phases.with_raw_response.get( + ruleset_phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.phases.with_raw_response.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + +class TestAsyncPhases: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + phase = await async_client.rulesets.phases.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + phase = await async_client.rulesets.phases.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + description="A description for my ruleset.", + name="My ruleset", + rules=[ + { + "id": "3a03d665bac047339bb530ecb439a90d", + "action": "block", + "action_parameters": { + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + "description": "Block the request.", + "enabled": True, + "exposed_credential_check": { + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + "expression": "ip.src eq 1.1.1.1", + "logging": {"enabled": True}, + "ratelimit": { + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + "ref": "my_ref", + } + ], + ) + assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.phases.with_raw_response.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + phase = await response.parse() + assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.phases.with_streaming_response.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + phase = await response.parse() + assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.phases.with_raw_response.update( + ruleset_phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.phases.with_raw_response.update( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + phase = await async_client.rulesets.phases.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(PhaseGetResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + phase = await async_client.rulesets.phases.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(PhaseGetResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.phases.with_raw_response.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + phase = await response.parse() + assert_matches_type(PhaseGetResponse, phase, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.phases.with_streaming_response.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + phase = await response.parse() + assert_matches_type(PhaseGetResponse, phase, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.phases.with_raw_response.get( + ruleset_phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.phases.with_raw_response.get( + ruleset_phase="http_request_firewall_custom", + account_id="account_id", + ) diff --git a/tests/api_resources/rulesets/test_rules.py b/tests/api_resources/rulesets/test_rules.py new file mode 100644 index 00000000000..0270791a0b1 --- /dev/null +++ b/tests/api_resources/rulesets/test_rules.py @@ -0,0 +1,8938 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.rulesets import ( + RuleEditResponse, + RuleCreateResponse, + RuleDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRules: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_1(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="block", + action_parameters={ + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + description="Block the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_2(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="challenge", + action_parameters={}, + description="Issue an Interactive Challenge if the visitor has not solved an Interactive Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_3(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="compress_response", + action_parameters={"algorithms": [{"name": "none"}]}, + description="Modify the compression algorithm used in the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_3(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_3(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_3(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_4(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Perform a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_4(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_4(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_4(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_5(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_5(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="execute", + action_parameters={ + "id": "4814384a9e5d4991b9815dcfc25d2f1f", + "matched_data": {"public_key": "iGqBmyIUxuWt1rvxoAharN9FUXneUBxA/Y19PyyrEG0="}, + "overrides": { + "action": "log", + "categories": [ + { + "category": "directory-traversal", + "action": "log", + "enabled": True, + "sensitivity_level": "default", + } + ], + "enabled": True, + "rules": [ + { + "id": "8ac8bc2a661e475d940980f9317f28e1", + "action": "log", + "enabled": True, + "score_threshold": 0, + "sensitivity_level": "default", + } + ], + "sensitivity_level": "default", + }, + }, + description="Execute another ruleset.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_5(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_5(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_5(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_6(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_6(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Close ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_6(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_6(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_6(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_7(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_7(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="js_challenge", + action_parameters={}, + description="Issue a non-interactive JavaScript Challenge if the visitor has not solved an Interactive Challenge, Managed Challenge, or JavaScript Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_7(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_7(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_7(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_8(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_8(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="log", + action_parameters={}, + description="Log the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_8(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_8(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_8(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_9(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_9(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "myCookie"}], + "raw_response_fields": [ + { + "name": "my-response-header", + "preserve_duplicates": True, + } + ], + "request_fields": [{"name": "my-request-header"}], + "response_fields": [ + { + "name": "my-response-header", + "preserve_duplicates": True, + } + ], + "transformed_request_fields": [{"name": "my-request-header"}], + }, + description="Log additional custom fields.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_9(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_9(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_9(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_10(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_10(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="managed_challenge", + action_parameters={}, + description="Issue a Managed Challenge if the visitor has not solved a Managed Challenge or Interactive Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_10(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_10(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_10(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_11(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_11(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="redirect", + action_parameters={ + "from_list": { + "key": "http.request.full_uri", + "name": "my_list", + }, + "from_value": { + "target_url": { + "expression": 'concat("https://example.com", http.request.uri.path)', + "value": "https://example.com", + }, + "preserve_query_string": True, + "status_code": 302, + }, + }, + description="Redirect the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_11(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_11(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_11(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_12(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_12(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="rewrite", + action_parameters={ + "headers": { + "client-http-version": { + "expression": "http.request.version", + "operation": "set", + } + }, + "uri": { + "path": { + "expression": 'regex_replace(http.request.uri.path, "/foo$", "/bar")', + "value": "/foo", + } + }, + }, + description="Rewrite properties of the request or response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_12(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_12(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_12(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_13(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_13(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="route", + action_parameters={ + "host_header": "static.example.com", + "origin": { + "host": "static.example.com", + "port": 80, + }, + "sni": {"value": "static.example.com"}, + }, + description="Select an origin server to route the request to.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_13(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_13(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_13(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_14(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_14(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="score", + action_parameters={"increment": 3}, + description="Increment the cumulative score.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_14(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_14(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_14(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_15(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_15(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="serve_error", + action_parameters={ + "content": '{\n "error": "1xxx error occurred"\n}', + "content_type": "application/json", + "status_code": 500, + }, + description="Customize the serving of errors.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_15(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_15(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_15(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_16(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_16(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_control", + action_parameters={ + "immutable": { + "operation": "set", + "cloudflare_only": False, + }, + "max_age": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "must_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "must_understand": { + "operation": "set", + "cloudflare_only": False, + }, + "no_cache": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "no_store": { + "operation": "set", + "cloudflare_only": False, + }, + "no_transform": { + "operation": "set", + "cloudflare_only": False, + }, + "private": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "proxy_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "public": { + "operation": "set", + "cloudflare_only": False, + }, + "s_maxage": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_if_error": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_while_revalidate": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + }, + description="Modify the cache-control header directives in an Origin response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_16(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_16(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_16(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_settings", + action_parameters={ + "additional_cacheable_ports": [8080], + "browser_ttl": { + "mode": "override_origin", + "default": 60, + }, + "cache": True, + "cache_key": { + "cache_by_device_type": True, + "cache_deception_armor": True, + "custom_key": { + "cookie": { + "check_presence": ["myCookie"], + "include": ["myCookie"], + }, + "header": { + "check_presence": ["my-header"], + "contains": {"my-header": ["my-header-value-1", "my-header-value-2"]}, + "exclude_origin": True, + "include": ["my-header"], + }, + "host": {"resolved": True}, + "query_string": { + "exclude": { + "all": True, + "list": ["foo"], + }, + "include": { + "all": True, + "list": ["foo"], + }, + }, + "user": { + "device_type": True, + "geo": True, + "lang": True, + }, + }, + "ignore_query_strings_order": True, + }, + "cache_reserve": { + "eligible": True, + "minimum_file_size": 1024, + }, + "edge_ttl": { + "mode": "override_origin", + "default": 60, + "status_code_ttl": [ + { + "value": 0, + "status_code": 200, + "status_code_range": { + "from": 200, + "to": 299, + }, + } + ], + }, + "origin_cache_control": True, + "origin_error_page_passthru": True, + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, + "shared_dictionary": {"match_pattern": "/static/js/*.js"}, + "strip_etags": True, + "strip_last_modified": True, + "strip_set_cookie": True, + }, + description="Configure settings for how the response is cached.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_17(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_17(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_17(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_tags", + action_parameters={ + "operation": "add", + "values": ["my-cache-tag"], + }, + description="Modify the cache tags associated with the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_19(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_19(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_config", + action_parameters={ + "automatic_https_rewrites": True, + "autominify": { + "css": True, + "html": True, + "js": True, + }, + "bic": True, + "content_converter": True, + "disable_apps": True, + "disable_pay_per_crawl": True, + "disable_rum": True, + "disable_zaraz": True, + "email_obfuscation": True, + "fonts": True, + "hotlink_protection": True, + "mirage": True, + "opportunistic_encryption": True, + "polish": "off", + "redirects_for_ai_training": True, + "request_body_buffering": "standard", + "response_body_buffering": "standard", + "rocket_loader": True, + "security_level": "off", + "server_side_excludes": True, + "ssl": "off", + "sxg": True, + }, + description="Configure settings for the request and response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_19(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_19(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_19(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_20(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_20(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="skip", + action_parameters={ + "phase": "current", + "phases": ["http_request_firewall_custom"], + "products": ["bic"], + "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, + "ruleset": "current", + "rulesets": ["2f2feab2026849078ba485f918791bdc"], + }, + description="Skip executing rulesets, rules, phases, and other products.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_20(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_20(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_20(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.delete( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_1(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_1(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="block", + action_parameters={ + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + description="Block the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_1(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_1(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_2(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_2(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="challenge", + action_parameters={}, + description="Issue an Interactive Challenge if the visitor has not solved an Interactive Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_2(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_2(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_3(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_3(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="compress_response", + action_parameters={"algorithms": [{"name": "none"}]}, + description="Modify the compression algorithm used in the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_3(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_3(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_3(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_4(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_4(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Perform a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_4(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_4(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_4(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_5(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_5(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="execute", + action_parameters={ + "id": "4814384a9e5d4991b9815dcfc25d2f1f", + "matched_data": {"public_key": "iGqBmyIUxuWt1rvxoAharN9FUXneUBxA/Y19PyyrEG0="}, + "overrides": { + "action": "log", + "categories": [ + { + "category": "directory-traversal", + "action": "log", + "enabled": True, + "sensitivity_level": "default", + } + ], + "enabled": True, + "rules": [ + { + "id": "8ac8bc2a661e475d940980f9317f28e1", + "action": "log", + "enabled": True, + "score_threshold": 0, + "sensitivity_level": "default", + } + ], + "sensitivity_level": "default", + }, + }, + description="Execute another ruleset.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_5(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_5(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_5(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_6(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_6(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Close ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_6(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_6(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_6(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_7(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_7(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="js_challenge", + action_parameters={}, + description="Issue a non-interactive JavaScript Challenge if the visitor has not solved an Interactive Challenge, Managed Challenge, or JavaScript Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_7(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_7(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_7(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_8(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_8(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="log", + action_parameters={}, + description="Log the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_8(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_8(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_8(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_9(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_9(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "myCookie"}], + "raw_response_fields": [ + { + "name": "my-response-header", + "preserve_duplicates": True, + } + ], + "request_fields": [{"name": "my-request-header"}], + "response_fields": [ + { + "name": "my-response-header", + "preserve_duplicates": True, + } + ], + "transformed_request_fields": [{"name": "my-request-header"}], + }, + description="Log additional custom fields.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_9(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_9(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_9(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_10(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_10(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="managed_challenge", + action_parameters={}, + description="Issue a Managed Challenge if the visitor has not solved a Managed Challenge or Interactive Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_10(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_10(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_10(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_11(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_11(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="redirect", + action_parameters={ + "from_list": { + "key": "http.request.full_uri", + "name": "my_list", + }, + "from_value": { + "target_url": { + "expression": 'concat("https://example.com", http.request.uri.path)', + "value": "https://example.com", + }, + "preserve_query_string": True, + "status_code": 302, + }, + }, + description="Redirect the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_11(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_11(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_11(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_12(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_12(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="rewrite", + action_parameters={ + "headers": { + "client-http-version": { + "expression": "http.request.version", + "operation": "set", + } + }, + "uri": { + "path": { + "expression": 'regex_replace(http.request.uri.path, "/foo$", "/bar")', + "value": "/foo", + } + }, + }, + description="Rewrite properties of the request or response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_12(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_12(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_12(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_13(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_13(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="route", + action_parameters={ + "host_header": "static.example.com", + "origin": { + "host": "static.example.com", + "port": 80, + }, + "sni": {"value": "static.example.com"}, + }, + description="Select an origin server to route the request to.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_13(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_13(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_13(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_14(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_14(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="score", + action_parameters={"increment": 3}, + description="Increment the cumulative score.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_14(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_14(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_14(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_15(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_15(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="serve_error", + action_parameters={ + "content": '{\n "error": "1xxx error occurred"\n}', + "content_type": "application/json", + "status_code": 500, + }, + description="Customize the serving of errors.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_15(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_15(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_15(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_16(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_16(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_control", + action_parameters={ + "immutable": { + "operation": "set", + "cloudflare_only": False, + }, + "max_age": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "must_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "must_understand": { + "operation": "set", + "cloudflare_only": False, + }, + "no_cache": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "no_store": { + "operation": "set", + "cloudflare_only": False, + }, + "no_transform": { + "operation": "set", + "cloudflare_only": False, + }, + "private": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "proxy_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "public": { + "operation": "set", + "cloudflare_only": False, + }, + "s_maxage": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_if_error": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_while_revalidate": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + }, + description="Modify the cache-control header directives in an Origin response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_16(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_16(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_settings", + action_parameters={ + "additional_cacheable_ports": [8080], + "browser_ttl": { + "mode": "override_origin", + "default": 60, + }, + "cache": True, + "cache_key": { + "cache_by_device_type": True, + "cache_deception_armor": True, + "custom_key": { + "cookie": { + "check_presence": ["myCookie"], + "include": ["myCookie"], + }, + "header": { + "check_presence": ["my-header"], + "contains": {"my-header": ["my-header-value-1", "my-header-value-2"]}, + "exclude_origin": True, + "include": ["my-header"], + }, + "host": {"resolved": True}, + "query_string": { + "exclude": { + "all": True, + "list": ["foo"], + }, + "include": { + "all": True, + "list": ["foo"], + }, + }, + "user": { + "device_type": True, + "geo": True, + "lang": True, + }, + }, + "ignore_query_strings_order": True, + }, + "cache_reserve": { + "eligible": True, + "minimum_file_size": 1024, + }, + "edge_ttl": { + "mode": "override_origin", + "default": 60, + "status_code_ttl": [ + { + "value": 0, + "status_code": 200, + "status_code_range": { + "from": 200, + "to": 299, + }, + } + ], + }, + "origin_cache_control": True, + "origin_error_page_passthru": True, + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, + "shared_dictionary": {"match_pattern": "/static/js/*.js"}, + "strip_etags": True, + "strip_last_modified": True, + "strip_set_cookie": True, + }, + description="Configure settings for how the response is cached.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_17(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_17(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_17(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_tags", + action_parameters={ + "operation": "add", + "values": ["my-cache-tag"], + }, + description="Modify the cache tags associated with the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_19(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_19(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_config", + action_parameters={ + "automatic_https_rewrites": True, + "autominify": { + "css": True, + "html": True, + "js": True, + }, + "bic": True, + "content_converter": True, + "disable_apps": True, + "disable_pay_per_crawl": True, + "disable_rum": True, + "disable_zaraz": True, + "email_obfuscation": True, + "fonts": True, + "hotlink_protection": True, + "mirage": True, + "opportunistic_encryption": True, + "polish": "off", + "redirects_for_ai_training": True, + "request_body_buffering": "standard", + "response_body_buffering": "standard", + "rocket_loader": True, + "security_level": "off", + "server_side_excludes": True, + "ssl": "off", + "sxg": True, + }, + description="Configure settings for the request and response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_19(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_19(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_19(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_20(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_20(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="skip", + action_parameters={ + "phase": "current", + "phases": ["http_request_firewall_custom"], + "products": ["bic"], + "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, + "ruleset": "current", + "rulesets": ["2f2feab2026849078ba485f918791bdc"], + }, + description="Skip executing rulesets, rules, phases, and other products.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_20(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_20(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_20(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + +class TestAsyncRules: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="block", + action_parameters={ + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + description="Block the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="challenge", + action_parameters={}, + description="Issue an Interactive Challenge if the visitor has not solved an Interactive Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_3(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="compress_response", + action_parameters={"algorithms": [{"name": "none"}]}, + description="Modify the compression algorithm used in the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_3(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_4(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Perform a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_4(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_5(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="execute", + action_parameters={ + "id": "4814384a9e5d4991b9815dcfc25d2f1f", + "matched_data": {"public_key": "iGqBmyIUxuWt1rvxoAharN9FUXneUBxA/Y19PyyrEG0="}, + "overrides": { + "action": "log", + "categories": [ + { + "category": "directory-traversal", + "action": "log", + "enabled": True, + "sensitivity_level": "default", + } + ], + "enabled": True, + "rules": [ + { + "id": "8ac8bc2a661e475d940980f9317f28e1", + "action": "log", + "enabled": True, + "score_threshold": 0, + "sensitivity_level": "default", + } + ], + "sensitivity_level": "default", + }, + }, + description="Execute another ruleset.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_5(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_6(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Close ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_6(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_7(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="js_challenge", + action_parameters={}, + description="Issue a non-interactive JavaScript Challenge if the visitor has not solved an Interactive Challenge, Managed Challenge, or JavaScript Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_7(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_8(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="log", + action_parameters={}, + description="Log the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_8(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_9(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "myCookie"}], + "raw_response_fields": [ + { + "name": "my-response-header", + "preserve_duplicates": True, + } + ], + "request_fields": [{"name": "my-request-header"}], + "response_fields": [ + { + "name": "my-response-header", + "preserve_duplicates": True, + } + ], + "transformed_request_fields": [{"name": "my-request-header"}], + }, + description="Log additional custom fields.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_9(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_10(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="managed_challenge", + action_parameters={}, + description="Issue a Managed Challenge if the visitor has not solved a Managed Challenge or Interactive Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_10(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_11(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="redirect", + action_parameters={ + "from_list": { + "key": "http.request.full_uri", + "name": "my_list", + }, + "from_value": { + "target_url": { + "expression": 'concat("https://example.com", http.request.uri.path)', + "value": "https://example.com", + }, + "preserve_query_string": True, + "status_code": 302, + }, + }, + description="Redirect the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_11(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_12(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="rewrite", + action_parameters={ + "headers": { + "client-http-version": { + "expression": "http.request.version", + "operation": "set", + } + }, + "uri": { + "path": { + "expression": 'regex_replace(http.request.uri.path, "/foo$", "/bar")', + "value": "/foo", + } + }, + }, + description="Rewrite properties of the request or response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_12(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_13(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="route", + action_parameters={ + "host_header": "static.example.com", + "origin": { + "host": "static.example.com", + "port": 80, + }, + "sni": {"value": "static.example.com"}, + }, + description="Select an origin server to route the request to.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_13(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_14(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="score", + action_parameters={"increment": 3}, + description="Increment the cumulative score.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_14(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_15(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_15(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="serve_error", + action_parameters={ + "content": '{\n "error": "1xxx error occurred"\n}', + "content_type": "application/json", + "status_code": 500, + }, + description="Customize the serving of errors.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_control", + action_parameters={ + "immutable": { + "operation": "set", + "cloudflare_only": False, + }, + "max_age": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "must_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "must_understand": { + "operation": "set", + "cloudflare_only": False, + }, + "no_cache": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "no_store": { + "operation": "set", + "cloudflare_only": False, + }, + "no_transform": { + "operation": "set", + "cloudflare_only": False, + }, + "private": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "proxy_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "public": { + "operation": "set", + "cloudflare_only": False, + }, + "s_maxage": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_if_error": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_while_revalidate": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + }, + description="Modify the cache-control header directives in an Origin response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_settings", + action_parameters={ + "additional_cacheable_ports": [8080], + "browser_ttl": { + "mode": "override_origin", + "default": 60, + }, + "cache": True, + "cache_key": { + "cache_by_device_type": True, + "cache_deception_armor": True, + "custom_key": { + "cookie": { + "check_presence": ["myCookie"], + "include": ["myCookie"], + }, + "header": { + "check_presence": ["my-header"], + "contains": {"my-header": ["my-header-value-1", "my-header-value-2"]}, + "exclude_origin": True, + "include": ["my-header"], + }, + "host": {"resolved": True}, + "query_string": { + "exclude": { + "all": True, + "list": ["foo"], + }, + "include": { + "all": True, + "list": ["foo"], + }, + }, + "user": { + "device_type": True, + "geo": True, + "lang": True, + }, + }, + "ignore_query_strings_order": True, + }, + "cache_reserve": { + "eligible": True, + "minimum_file_size": 1024, + }, + "edge_ttl": { + "mode": "override_origin", + "default": 60, + "status_code_ttl": [ + { + "value": 0, + "status_code": 200, + "status_code_range": { + "from": 200, + "to": 299, + }, + } + ], + }, + "origin_cache_control": True, + "origin_error_page_passthru": True, + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, + "shared_dictionary": {"match_pattern": "/static/js/*.js"}, + "strip_etags": True, + "strip_last_modified": True, + "strip_set_cookie": True, + }, + description="Configure settings for how the response is cached.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_17(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_tags", + action_parameters={ + "operation": "add", + "values": ["my-cache-tag"], + }, + description="Modify the cache tags associated with the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_18(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_19(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_19(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_config", + action_parameters={ + "automatic_https_rewrites": True, + "autominify": { + "css": True, + "html": True, + "js": True, + }, + "bic": True, + "content_converter": True, + "disable_apps": True, + "disable_pay_per_crawl": True, + "disable_rum": True, + "disable_zaraz": True, + "email_obfuscation": True, + "fonts": True, + "hotlink_protection": True, + "mirage": True, + "opportunistic_encryption": True, + "polish": "off", + "redirects_for_ai_training": True, + "request_body_buffering": "standard", + "response_body_buffering": "standard", + "rocket_loader": True, + "security_level": "off", + "server_side_excludes": True, + "ssl": "off", + "sxg": True, + }, + description="Configure settings for the request and response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_19(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_19(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_19(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_20(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_20(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="skip", + action_parameters={ + "phase": "current", + "phases": ["http_request_firewall_custom"], + "products": ["bic"], + "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, + "ruleset": "current", + "rulesets": ["2f2feab2026849078ba485f918791bdc"], + }, + description="Skip executing rulesets, rules, phases, and other products.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_20(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_20(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_20(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.delete( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.delete( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="block", + action_parameters={ + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + description="Block the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="challenge", + action_parameters={}, + description="Issue an Interactive Challenge if the visitor has not solved an Interactive Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="compress_response", + action_parameters={"algorithms": [{"name": "none"}]}, + description="Modify the compression algorithm used in the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Perform a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_5(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="execute", + action_parameters={ + "id": "4814384a9e5d4991b9815dcfc25d2f1f", + "matched_data": {"public_key": "iGqBmyIUxuWt1rvxoAharN9FUXneUBxA/Y19PyyrEG0="}, + "overrides": { + "action": "log", + "categories": [ + { + "category": "directory-traversal", + "action": "log", + "enabled": True, + "sensitivity_level": "default", + } + ], + "enabled": True, + "rules": [ + { + "id": "8ac8bc2a661e475d940980f9317f28e1", + "action": "log", + "enabled": True, + "score_threshold": 0, + "sensitivity_level": "default", + } + ], + "sensitivity_level": "default", + }, + }, + description="Execute another ruleset.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_5(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_5(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_5(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_6(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Close ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_6(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_7(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="js_challenge", + action_parameters={}, + description="Issue a non-interactive JavaScript Challenge if the visitor has not solved an Interactive Challenge, Managed Challenge, or JavaScript Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_7(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_7(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_7(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_8(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="log", + action_parameters={}, + description="Log the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_8(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_8(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_8(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_9(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "myCookie"}], + "raw_response_fields": [ + { + "name": "my-response-header", + "preserve_duplicates": True, + } + ], + "request_fields": [{"name": "my-request-header"}], + "response_fields": [ + { + "name": "my-response-header", + "preserve_duplicates": True, + } + ], + "transformed_request_fields": [{"name": "my-request-header"}], + }, + description="Log additional custom fields.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_9(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_9(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_9(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_10(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="managed_challenge", + action_parameters={}, + description="Issue a Managed Challenge if the visitor has not solved a Managed Challenge or Interactive Challenge prior to the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_10(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_10(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_10(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_11(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="redirect", + action_parameters={ + "from_list": { + "key": "http.request.full_uri", + "name": "my_list", + }, + "from_value": { + "target_url": { + "expression": 'concat("https://example.com", http.request.uri.path)', + "value": "https://example.com", + }, + "preserve_query_string": True, + "status_code": 302, + }, + }, + description="Redirect the request.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_11(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_11(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_11(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_12(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="rewrite", + action_parameters={ + "headers": { + "client-http-version": { + "expression": "http.request.version", + "operation": "set", + } + }, + "uri": { + "path": { + "expression": 'regex_replace(http.request.uri.path, "/foo$", "/bar")', + "value": "/foo", + } + }, + }, + description="Rewrite properties of the request or response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_12(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_12(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_12(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_13(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="route", + action_parameters={ + "host_header": "static.example.com", + "origin": { + "host": "static.example.com", + "port": 80, + }, + "sni": {"value": "static.example.com"}, + }, + description="Select an origin server to route the request to.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_13(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_13(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_13(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_14(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="score", + action_parameters={"increment": 3}, + description="Increment the cumulative score.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_14(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_14(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_14(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_15(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_15(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="serve_error", + action_parameters={ + "content": '{\n "error": "1xxx error occurred"\n}', + "content_type": "application/json", + "status_code": 500, + }, + description="Customize the serving of errors.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_15(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_15(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_15(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_control", + action_parameters={ + "immutable": { + "operation": "set", + "cloudflare_only": False, + }, + "max_age": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "must_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "must_understand": { + "operation": "set", + "cloudflare_only": False, + }, + "no_cache": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "no_store": { + "operation": "set", + "cloudflare_only": False, + }, + "no_transform": { + "operation": "set", + "cloudflare_only": False, + }, + "private": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "proxy_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "public": { + "operation": "set", + "cloudflare_only": False, + }, + "s_maxage": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_if_error": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_while_revalidate": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + }, + description="Modify the cache-control header directives in an Origin response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_settings", + action_parameters={ + "additional_cacheable_ports": [8080], + "browser_ttl": { + "mode": "override_origin", + "default": 60, + }, + "cache": True, + "cache_key": { + "cache_by_device_type": True, + "cache_deception_armor": True, + "custom_key": { + "cookie": { + "check_presence": ["myCookie"], + "include": ["myCookie"], + }, + "header": { + "check_presence": ["my-header"], + "contains": {"my-header": ["my-header-value-1", "my-header-value-2"]}, + "exclude_origin": True, + "include": ["my-header"], + }, + "host": {"resolved": True}, + "query_string": { + "exclude": { + "all": True, + "list": ["foo"], + }, + "include": { + "all": True, + "list": ["foo"], + }, + }, + "user": { + "device_type": True, + "geo": True, + "lang": True, + }, + }, + "ignore_query_strings_order": True, + }, + "cache_reserve": { + "eligible": True, + "minimum_file_size": 1024, + }, + "edge_ttl": { + "mode": "override_origin", + "default": 60, + "status_code_ttl": [ + { + "value": 0, + "status_code": 200, + "status_code_range": { + "from": 200, + "to": 299, + }, + } + ], + }, + "origin_cache_control": True, + "origin_error_page_passthru": True, + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, + "shared_dictionary": {"match_pattern": "/static/js/*.js"}, + "strip_etags": True, + "strip_last_modified": True, + "strip_set_cookie": True, + }, + description="Configure settings for how the response is cached.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_tags", + action_parameters={ + "operation": "add", + "values": ["my-cache-tag"], + }, + description="Modify the cache tags associated with the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_19(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_19(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_config", + action_parameters={ + "automatic_https_rewrites": True, + "autominify": { + "css": True, + "html": True, + "js": True, + }, + "bic": True, + "content_converter": True, + "disable_apps": True, + "disable_pay_per_crawl": True, + "disable_rum": True, + "disable_zaraz": True, + "email_obfuscation": True, + "fonts": True, + "hotlink_protection": True, + "mirage": True, + "opportunistic_encryption": True, + "polish": "off", + "redirects_for_ai_training": True, + "request_body_buffering": "standard", + "response_body_buffering": "standard", + "rocket_loader": True, + "security_level": "off", + "server_side_excludes": True, + "ssl": "off", + "sxg": True, + }, + description="Configure settings for the request and response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_19(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_19(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_19(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_20(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_20(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="skip", + action_parameters={ + "phase": "current", + "phases": ["http_request_firewall_custom"], + "products": ["bic"], + "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, + "ruleset": "current", + "rulesets": ["2f2feab2026849078ba485f918791bdc"], + }, + description="Skip executing rulesets, rules, phases, and other products.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_20(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_20(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_20(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) diff --git a/tests/api_resources/rulesets/test_versions.py b/tests/api_resources/rulesets/test_versions.py new file mode 100644 index 00000000000..21b8ef98db7 --- /dev/null +++ b/tests/api_resources/rulesets/test_versions.py @@ -0,0 +1,483 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.rulesets import VersionGetResponse, VersionListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestVersions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + version = client.rulesets.versions.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + version = client.rulesets.versions.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.rulesets.versions.with_raw_response.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = response.parse() + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.rulesets.versions.with_streaming_response.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = response.parse() + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.versions.with_raw_response.list( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.versions.with_raw_response.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.versions.with_raw_response.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + version = client.rulesets.versions.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert version is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + version = client.rulesets.versions.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert version is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.rulesets.versions.with_raw_response.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = response.parse() + assert version is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.rulesets.versions.with_streaming_response.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = response.parse() + assert version is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.versions.with_raw_response.delete( + ruleset_version="1", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_version` but received ''"): + client.rulesets.versions.with_raw_response.delete( + ruleset_version="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.versions.with_raw_response.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.versions.with_raw_response.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + version = client.rulesets.versions.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + version = client.rulesets.versions.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.rulesets.versions.with_raw_response.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.rulesets.versions.with_streaming_response.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.versions.with_raw_response.get( + ruleset_version="1", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_version` but received ''"): + client.rulesets.versions.with_raw_response.get( + ruleset_version="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.versions.with_raw_response.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.versions.with_raw_response.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + +class TestAsyncVersions: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.versions.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.versions.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.versions.with_raw_response.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = await response.parse() + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.versions.with_streaming_response.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = await response.parse() + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.versions.with_raw_response.list( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.versions.with_raw_response.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.versions.with_raw_response.list( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.versions.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert version is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.versions.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert version is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.versions.with_raw_response.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = await response.parse() + assert version is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.versions.with_streaming_response.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = await response.parse() + assert version is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.versions.with_raw_response.delete( + ruleset_version="1", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_version` but received ''"): + await async_client.rulesets.versions.with_raw_response.delete( + ruleset_version="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.versions.with_raw_response.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.versions.with_raw_response.delete( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.versions.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + version = await async_client.rulesets.versions.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.versions.with_raw_response.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = await response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.versions.with_streaming_response.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = await response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.versions.with_raw_response.get( + ruleset_version="1", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_version` but received ''"): + await async_client.rulesets.versions.with_raw_response.get( + ruleset_version="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.versions.with_raw_response.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.versions.with_raw_response.get( + ruleset_version="1", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) diff --git a/tests/api_resources/secrets_store/test_stores.py b/tests/api_resources/secrets_store/test_stores.py index 23b40530409..6f22386b33d 100644 --- a/tests/api_resources/secrets_store/test_stores.py +++ b/tests/api_resources/secrets_store/test_stores.py @@ -21,6 +21,7 @@ class TestStores: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_method_create(self, client: Cloudflare) -> None: store = client.secrets_store.stores.create( @@ -29,6 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[StoreCreateResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.secrets_store.stores.with_raw_response.create( @@ -41,6 +43,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: store = response.parse() assert_matches_type(Optional[StoreCreateResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.secrets_store.stores.with_streaming_response.create( @@ -55,6 +58,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -63,6 +67,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: name="service_x_keys", ) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_method_list(self, client: Cloudflare) -> None: store = client.secrets_store.stores.list( @@ -70,6 +75,7 @@ def test_method_list(self, client: Cloudflare) -> None: ) assert_matches_type(SyncV4PagePaginationArray[StoreListResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: store = client.secrets_store.stores.list( @@ -81,6 +87,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(SyncV4PagePaginationArray[StoreListResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.secrets_store.stores.with_raw_response.list( @@ -92,6 +99,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: store = response.parse() assert_matches_type(SyncV4PagePaginationArray[StoreListResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.secrets_store.stores.with_streaming_response.list( @@ -105,6 +113,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_path_params_list(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -112,6 +121,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_method_delete(self, client: Cloudflare) -> None: store = client.secrets_store.stores.delete( @@ -120,6 +130,7 @@ def test_method_delete(self, client: Cloudflare) -> None: ) assert_matches_type(object, store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.secrets_store.stores.with_raw_response.delete( @@ -132,6 +143,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: store = response.parse() assert_matches_type(object, store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.secrets_store.stores.with_streaming_response.delete( @@ -146,6 +158,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -166,6 +179,7 @@ class TestAsyncStores: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: store = await async_client.secrets_store.stores.create( @@ -174,6 +188,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[StoreCreateResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.secrets_store.stores.with_raw_response.create( @@ -186,6 +201,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: store = await response.parse() assert_matches_type(Optional[StoreCreateResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.secrets_store.stores.with_streaming_response.create( @@ -200,6 +216,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -208,6 +225,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: name="service_x_keys", ) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: store = await async_client.secrets_store.stores.list( @@ -215,6 +233,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(AsyncV4PagePaginationArray[StoreListResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: store = await async_client.secrets_store.stores.list( @@ -226,6 +245,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) ) assert_matches_type(AsyncV4PagePaginationArray[StoreListResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.secrets_store.stores.with_raw_response.list( @@ -237,6 +257,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: store = await response.parse() assert_matches_type(AsyncV4PagePaginationArray[StoreListResponse], store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.secrets_store.stores.with_streaming_response.list( @@ -250,6 +271,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -257,6 +279,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: account_id="", ) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: store = await async_client.secrets_store.stores.delete( @@ -265,6 +288,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(object, store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.secrets_store.stores.with_raw_response.delete( @@ -277,6 +301,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: store = await response.parse() assert_matches_type(object, store, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.secrets_store.stores.with_streaming_response.delete( @@ -291,6 +316,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism error for 422 Unprocessable Entity") @parametrize async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): diff --git a/tests/api_resources/security_center/__init__.py b/tests/api_resources/security_center/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/security_center/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/security_center/insights/__init__.py b/tests/api_resources/security_center/insights/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/security_center/insights/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/security_center/insights/test_class_.py b/tests/api_resources/security_center/insights/test_class_.py new file mode 100644 index 00000000000..0609b2be126 --- /dev/null +++ b/tests/api_resources/security_center/insights/test_class_.py @@ -0,0 +1,156 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.security_center.insights import ClassGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestClass: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + class_ = client.security_center.insights.class_.get( + account_id="account_id", + ) + assert_matches_type(Optional[ClassGetResponse], class_, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + class_ = client.security_center.insights.class_.get( + account_id="account_id", + dismissed=False, + issue_class=["a_record_dangling", "always_use_https_not_enabled"], + issue_class_neq=["a_record_dangling", "always_use_https_not_enabled"], + issue_type=["compliance_violation", "email_security"], + issue_type_neq=["compliance_violation", "email_security"], + product=["access", "dns"], + product_neq=["access", "dns"], + severity=["low", "moderate"], + severity_neq=["low", "moderate"], + subject=["example.com"], + subject_neq=["example.com"], + ) + assert_matches_type(Optional[ClassGetResponse], class_, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.security_center.insights.class_.with_raw_response.get( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + class_ = response.parse() + assert_matches_type(Optional[ClassGetResponse], class_, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.security_center.insights.class_.with_streaming_response.get( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + class_ = response.parse() + assert_matches_type(Optional[ClassGetResponse], class_, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.class_.with_raw_response.get( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.class_.with_raw_response.get( + account_id="account_id", + ) + + +class TestAsyncClass: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + class_ = await async_client.security_center.insights.class_.get( + account_id="account_id", + ) + assert_matches_type(Optional[ClassGetResponse], class_, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + class_ = await async_client.security_center.insights.class_.get( + account_id="account_id", + dismissed=False, + issue_class=["a_record_dangling", "always_use_https_not_enabled"], + issue_class_neq=["a_record_dangling", "always_use_https_not_enabled"], + issue_type=["compliance_violation", "email_security"], + issue_type_neq=["compliance_violation", "email_security"], + product=["access", "dns"], + product_neq=["access", "dns"], + severity=["low", "moderate"], + severity_neq=["low", "moderate"], + subject=["example.com"], + subject_neq=["example.com"], + ) + assert_matches_type(Optional[ClassGetResponse], class_, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.security_center.insights.class_.with_raw_response.get( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + class_ = await response.parse() + assert_matches_type(Optional[ClassGetResponse], class_, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.security_center.insights.class_.with_streaming_response.get( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + class_ = await response.parse() + assert_matches_type(Optional[ClassGetResponse], class_, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.class_.with_raw_response.get( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.class_.with_raw_response.get( + account_id="account_id", + ) diff --git a/tests/api_resources/security_center/insights/test_severity.py b/tests/api_resources/security_center/insights/test_severity.py new file mode 100644 index 00000000000..589dd72a083 --- /dev/null +++ b/tests/api_resources/security_center/insights/test_severity.py @@ -0,0 +1,156 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.security_center.insights import SeverityGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSeverity: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + severity = client.security_center.insights.severity.get( + account_id="account_id", + ) + assert_matches_type(Optional[SeverityGetResponse], severity, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + severity = client.security_center.insights.severity.get( + account_id="account_id", + dismissed=False, + issue_class=["a_record_dangling", "always_use_https_not_enabled"], + issue_class_neq=["a_record_dangling", "always_use_https_not_enabled"], + issue_type=["compliance_violation", "email_security"], + issue_type_neq=["compliance_violation", "email_security"], + product=["access", "dns"], + product_neq=["access", "dns"], + severity=["low", "moderate"], + severity_neq=["low", "moderate"], + subject=["example.com"], + subject_neq=["example.com"], + ) + assert_matches_type(Optional[SeverityGetResponse], severity, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.security_center.insights.severity.with_raw_response.get( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + severity = response.parse() + assert_matches_type(Optional[SeverityGetResponse], severity, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.security_center.insights.severity.with_streaming_response.get( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + severity = response.parse() + assert_matches_type(Optional[SeverityGetResponse], severity, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.severity.with_raw_response.get( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.severity.with_raw_response.get( + account_id="account_id", + ) + + +class TestAsyncSeverity: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + severity = await async_client.security_center.insights.severity.get( + account_id="account_id", + ) + assert_matches_type(Optional[SeverityGetResponse], severity, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + severity = await async_client.security_center.insights.severity.get( + account_id="account_id", + dismissed=False, + issue_class=["a_record_dangling", "always_use_https_not_enabled"], + issue_class_neq=["a_record_dangling", "always_use_https_not_enabled"], + issue_type=["compliance_violation", "email_security"], + issue_type_neq=["compliance_violation", "email_security"], + product=["access", "dns"], + product_neq=["access", "dns"], + severity=["low", "moderate"], + severity_neq=["low", "moderate"], + subject=["example.com"], + subject_neq=["example.com"], + ) + assert_matches_type(Optional[SeverityGetResponse], severity, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.security_center.insights.severity.with_raw_response.get( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + severity = await response.parse() + assert_matches_type(Optional[SeverityGetResponse], severity, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.security_center.insights.severity.with_streaming_response.get( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + severity = await response.parse() + assert_matches_type(Optional[SeverityGetResponse], severity, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.severity.with_raw_response.get( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.severity.with_raw_response.get( + account_id="account_id", + ) diff --git a/tests/api_resources/security_center/insights/test_type.py b/tests/api_resources/security_center/insights/test_type.py new file mode 100644 index 00000000000..e9ae172ed08 --- /dev/null +++ b/tests/api_resources/security_center/insights/test_type.py @@ -0,0 +1,156 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.security_center.insights import TypeGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestType: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + type = client.security_center.insights.type.get( + account_id="account_id", + ) + assert_matches_type(Optional[TypeGetResponse], type, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + type = client.security_center.insights.type.get( + account_id="account_id", + dismissed=False, + issue_class=["a_record_dangling", "always_use_https_not_enabled"], + issue_class_neq=["a_record_dangling", "always_use_https_not_enabled"], + issue_type=["compliance_violation", "email_security"], + issue_type_neq=["compliance_violation", "email_security"], + product=["access", "dns"], + product_neq=["access", "dns"], + severity=["low", "moderate"], + severity_neq=["low", "moderate"], + subject=["example.com"], + subject_neq=["example.com"], + ) + assert_matches_type(Optional[TypeGetResponse], type, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.security_center.insights.type.with_raw_response.get( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + type = response.parse() + assert_matches_type(Optional[TypeGetResponse], type, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.security_center.insights.type.with_streaming_response.get( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + type = response.parse() + assert_matches_type(Optional[TypeGetResponse], type, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.type.with_raw_response.get( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.type.with_raw_response.get( + account_id="account_id", + ) + + +class TestAsyncType: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + type = await async_client.security_center.insights.type.get( + account_id="account_id", + ) + assert_matches_type(Optional[TypeGetResponse], type, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + type = await async_client.security_center.insights.type.get( + account_id="account_id", + dismissed=False, + issue_class=["a_record_dangling", "always_use_https_not_enabled"], + issue_class_neq=["a_record_dangling", "always_use_https_not_enabled"], + issue_type=["compliance_violation", "email_security"], + issue_type_neq=["compliance_violation", "email_security"], + product=["access", "dns"], + product_neq=["access", "dns"], + severity=["low", "moderate"], + severity_neq=["low", "moderate"], + subject=["example.com"], + subject_neq=["example.com"], + ) + assert_matches_type(Optional[TypeGetResponse], type, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.security_center.insights.type.with_raw_response.get( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + type = await response.parse() + assert_matches_type(Optional[TypeGetResponse], type, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.security_center.insights.type.with_streaming_response.get( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + type = await response.parse() + assert_matches_type(Optional[TypeGetResponse], type, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.type.with_raw_response.get( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.type.with_raw_response.get( + account_id="account_id", + ) diff --git a/tests/api_resources/security_center/test_insights.py b/tests/api_resources/security_center/test_insights.py new file mode 100644 index 00000000000..4c92fe945f9 --- /dev/null +++ b/tests/api_resources/security_center/test_insights.py @@ -0,0 +1,300 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncV4PagePagination, AsyncV4PagePagination +from cloudflare.types.security_center import ( + InsightListResponse, + InsightDismissResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestInsights: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + insight = client.security_center.insights.list( + account_id="account_id", + ) + assert_matches_type(SyncV4PagePagination[Optional[InsightListResponse]], insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + insight = client.security_center.insights.list( + account_id="account_id", + dismissed=False, + issue_class=["a_record_dangling", "always_use_https_not_enabled"], + issue_class_neq=["a_record_dangling", "always_use_https_not_enabled"], + issue_type=["compliance_violation", "email_security"], + issue_type_neq=["compliance_violation", "email_security"], + page=1, + per_page=25, + product=["access", "dns"], + product_neq=["access", "dns"], + severity=["low", "moderate"], + severity_neq=["low", "moderate"], + subject=["example.com"], + subject_neq=["example.com"], + ) + assert_matches_type(SyncV4PagePagination[Optional[InsightListResponse]], insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.security_center.insights.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = response.parse() + assert_matches_type(SyncV4PagePagination[Optional[InsightListResponse]], insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.security_center.insights.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = response.parse() + assert_matches_type(SyncV4PagePagination[Optional[InsightListResponse]], insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.with_raw_response.list( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.with_raw_response.list( + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_dismiss(self, client: Cloudflare) -> None: + insight = client.security_center.insights.dismiss( + issue_id="issue_id", + account_id="account_id", + ) + assert_matches_type(InsightDismissResponse, insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_method_dismiss_with_all_params(self, client: Cloudflare) -> None: + insight = client.security_center.insights.dismiss( + issue_id="issue_id", + account_id="account_id", + dismiss=True, + ) + assert_matches_type(InsightDismissResponse, insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_raw_response_dismiss(self, client: Cloudflare) -> None: + response = client.security_center.insights.with_raw_response.dismiss( + issue_id="issue_id", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = response.parse() + assert_matches_type(InsightDismissResponse, insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_streaming_response_dismiss(self, client: Cloudflare) -> None: + with client.security_center.insights.with_streaming_response.dismiss( + issue_id="issue_id", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = response.parse() + assert_matches_type(InsightDismissResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + def test_path_params_dismiss(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `issue_id` but received ''"): + client.security_center.insights.with_raw_response.dismiss( + issue_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.with_raw_response.dismiss( + issue_id="issue_id", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.security_center.insights.with_raw_response.dismiss( + issue_id="issue_id", + account_id="account_id", + ) + + +class TestAsyncInsights: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + insight = await async_client.security_center.insights.list( + account_id="account_id", + ) + assert_matches_type(AsyncV4PagePagination[Optional[InsightListResponse]], insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + insight = await async_client.security_center.insights.list( + account_id="account_id", + dismissed=False, + issue_class=["a_record_dangling", "always_use_https_not_enabled"], + issue_class_neq=["a_record_dangling", "always_use_https_not_enabled"], + issue_type=["compliance_violation", "email_security"], + issue_type_neq=["compliance_violation", "email_security"], + page=1, + per_page=25, + product=["access", "dns"], + product_neq=["access", "dns"], + severity=["low", "moderate"], + severity_neq=["low", "moderate"], + subject=["example.com"], + subject_neq=["example.com"], + ) + assert_matches_type(AsyncV4PagePagination[Optional[InsightListResponse]], insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.security_center.insights.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = await response.parse() + assert_matches_type(AsyncV4PagePagination[Optional[InsightListResponse]], insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.security_center.insights.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = await response.parse() + assert_matches_type(AsyncV4PagePagination[Optional[InsightListResponse]], insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.with_raw_response.list( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.with_raw_response.list( + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_dismiss(self, async_client: AsyncCloudflare) -> None: + insight = await async_client.security_center.insights.dismiss( + issue_id="issue_id", + account_id="account_id", + ) + assert_matches_type(InsightDismissResponse, insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_method_dismiss_with_all_params(self, async_client: AsyncCloudflare) -> None: + insight = await async_client.security_center.insights.dismiss( + issue_id="issue_id", + account_id="account_id", + dismiss=True, + ) + assert_matches_type(InsightDismissResponse, insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_raw_response_dismiss(self, async_client: AsyncCloudflare) -> None: + response = await async_client.security_center.insights.with_raw_response.dismiss( + issue_id="issue_id", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = await response.parse() + assert_matches_type(InsightDismissResponse, insight, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_streaming_response_dismiss(self, async_client: AsyncCloudflare) -> None: + async with async_client.security_center.insights.with_streaming_response.dismiss( + issue_id="issue_id", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = await response.parse() + assert_matches_type(InsightDismissResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken prism assertion") + @parametrize + async def test_path_params_dismiss(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `issue_id` but received ''"): + await async_client.security_center.insights.with_raw_response.dismiss( + issue_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.with_raw_response.dismiss( + issue_id="issue_id", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.security_center.insights.with_raw_response.dismiss( + issue_id="issue_id", + account_id="account_id", + ) diff --git a/tests/api_resources/security_txt/__init__.py b/tests/api_resources/security_txt/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/security_txt/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/stream/test_downloads.py b/tests/api_resources/stream/test_downloads.py index ae17b551a72..29ac23d292d 100644 --- a/tests/api_resources/stream/test_downloads.py +++ b/tests/api_resources/stream/test_downloads.py @@ -17,6 +17,7 @@ class TestDownloads: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_method_create(self, client: Cloudflare) -> None: download = client.stream.downloads.create( @@ -25,6 +26,7 @@ def test_method_create(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[DownloadCreateResponse], download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.stream.downloads.with_raw_response.create( @@ -37,6 +39,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: download = response.parse() assert_matches_type(Optional[DownloadCreateResponse], download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.stream.downloads.with_streaming_response.create( @@ -51,6 +54,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -65,6 +69,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_method_delete(self, client: Cloudflare) -> None: download = client.stream.downloads.delete( @@ -73,6 +78,7 @@ def test_method_delete(self, client: Cloudflare) -> None: ) assert_matches_type(str, download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.stream.downloads.with_raw_response.delete( @@ -85,6 +91,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: download = response.parse() assert_matches_type(str, download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.stream.downloads.with_streaming_response.delete( @@ -99,6 +106,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -113,6 +121,7 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_method_get(self, client: Cloudflare) -> None: download = client.stream.downloads.get( @@ -121,6 +130,7 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[DownloadGetResponse], download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.stream.downloads.with_raw_response.get( @@ -133,6 +143,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: download = response.parse() assert_matches_type(Optional[DownloadGetResponse], download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.stream.downloads.with_streaming_response.get( @@ -147,6 +158,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -167,6 +179,7 @@ class TestAsyncDownloads: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: download = await async_client.stream.downloads.create( @@ -175,6 +188,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[DownloadCreateResponse], download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.stream.downloads.with_raw_response.create( @@ -187,6 +201,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: download = await response.parse() assert_matches_type(Optional[DownloadCreateResponse], download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.stream.downloads.with_streaming_response.create( @@ -201,6 +216,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -215,6 +231,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: download = await async_client.stream.downloads.delete( @@ -223,6 +240,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(str, download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.stream.downloads.with_raw_response.delete( @@ -235,6 +253,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: download = await response.parse() assert_matches_type(str, download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.stream.downloads.with_streaming_response.delete( @@ -249,6 +268,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -263,6 +283,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: download = await async_client.stream.downloads.get( @@ -271,6 +292,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[DownloadGetResponse], download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.stream.downloads.with_raw_response.get( @@ -283,6 +305,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: download = await response.parse() assert_matches_type(Optional[DownloadGetResponse], download, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.stream.downloads.with_streaming_response.get( @@ -297,6 +320,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism 415 Unsupported Media Type") @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): diff --git a/tests/api_resources/stream/test_embed.py b/tests/api_resources/stream/test_embed.py index 4158863edde..3889b4fcf49 100644 --- a/tests/api_resources/stream/test_embed.py +++ b/tests/api_resources/stream/test_embed.py @@ -16,6 +16,7 @@ class TestEmbed: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="SKIP: prism 406 Not Acceptable") @parametrize def test_method_get(self, client: Cloudflare) -> None: embed = client.stream.embed.get( @@ -24,6 +25,7 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(str, embed, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 406 Not Acceptable") @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.stream.embed.with_raw_response.get( @@ -36,6 +38,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: embed = response.parse() assert_matches_type(str, embed, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 406 Not Acceptable") @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.stream.embed.with_streaming_response.get( @@ -50,6 +53,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism 406 Not Acceptable") @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -70,6 +74,7 @@ class TestAsyncEmbed: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) + @pytest.mark.skip(reason="SKIP: prism 406 Not Acceptable") @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: embed = await async_client.stream.embed.get( @@ -78,6 +83,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(str, embed, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 406 Not Acceptable") @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.stream.embed.with_raw_response.get( @@ -90,6 +96,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: embed = await response.parse() assert_matches_type(str, embed, path=["response"]) + @pytest.mark.skip(reason="SKIP: prism 406 Not Acceptable") @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.stream.embed.with_streaming_response.get( @@ -104,6 +111,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="SKIP: prism 406 Not Acceptable") @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): diff --git a/tests/api_resources/test_rulesets.py b/tests/api_resources/test_rulesets.py new file mode 100644 index 00000000000..7f47311d949 --- /dev/null +++ b/tests/api_resources/test_rulesets.py @@ -0,0 +1,830 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncCursorPagination, AsyncCursorPagination +from cloudflare.types.rulesets import ( + RulesetGetResponse, + RulesetListResponse, + RulesetCreateResponse, + RulesetUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRulesets: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + ruleset = client.rulesets.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(RulesetCreateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + ruleset = client.rulesets.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + description="A description for my ruleset.", + rules=[ + { + "id": "3a03d665bac047339bb530ecb439a90d", + "action": "block", + "action_parameters": { + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + "description": "Block the request.", + "enabled": True, + "exposed_credential_check": { + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + "expression": "ip.src eq 1.1.1.1", + "logging": {"enabled": True}, + "ratelimit": { + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + "ref": "my_ref", + } + ], + ) + assert_matches_type(RulesetCreateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.rulesets.with_raw_response.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = response.parse() + assert_matches_type(RulesetCreateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.rulesets.with_streaming_response.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = response.parse() + assert_matches_type(RulesetCreateResponse, ruleset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + ruleset = client.rulesets.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RulesetUpdateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + ruleset = client.rulesets.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + description="A description for my ruleset.", + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + rules=[ + { + "id": "3a03d665bac047339bb530ecb439a90d", + "action": "block", + "action_parameters": { + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + "description": "Block the request.", + "enabled": True, + "exposed_credential_check": { + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + "expression": "ip.src eq 1.1.1.1", + "logging": {"enabled": True}, + "ratelimit": { + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + "ref": "my_ref", + } + ], + ) + assert_matches_type(RulesetUpdateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.rulesets.with_raw_response.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = response.parse() + assert_matches_type(RulesetUpdateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.rulesets.with_streaming_response.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = response.parse() + assert_matches_type(RulesetUpdateResponse, ruleset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.with_raw_response.update( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + ruleset = client.rulesets.list( + account_id="account_id", + ) + assert_matches_type(SyncCursorPagination[RulesetListResponse], ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + ruleset = client.rulesets.list( + account_id="account_id", + cursor="dGhpc2lzYW5leGFtcGxlCg", + per_page=3, + ) + assert_matches_type(SyncCursorPagination[RulesetListResponse], ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.rulesets.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = response.parse() + assert_matches_type(SyncCursorPagination[RulesetListResponse], ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.rulesets.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = response.parse() + assert_matches_type(SyncCursorPagination[RulesetListResponse], ruleset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.list( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.list( + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + ruleset = client.rulesets.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert ruleset is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + ruleset = client.rulesets.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert ruleset is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.rulesets.with_raw_response.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = response.parse() + assert ruleset is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.rulesets.with_streaming_response.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = response.parse() + assert ruleset is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.with_raw_response.delete( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + ruleset = client.rulesets.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RulesetGetResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + ruleset = client.rulesets.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RulesetGetResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.rulesets.with_raw_response.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = response.parse() + assert_matches_type(RulesetGetResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.rulesets.with_streaming_response.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = response.parse() + assert_matches_type(RulesetGetResponse, ruleset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.with_raw_response.get( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.with_raw_response.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + +class TestAsyncRulesets: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + ) + assert_matches_type(RulesetCreateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + description="A description for my ruleset.", + rules=[ + { + "id": "3a03d665bac047339bb530ecb439a90d", + "action": "block", + "action_parameters": { + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + "description": "Block the request.", + "enabled": True, + "exposed_credential_check": { + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + "expression": "ip.src eq 1.1.1.1", + "logging": {"enabled": True}, + "ratelimit": { + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + "ref": "my_ref", + } + ], + ) + assert_matches_type(RulesetCreateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.with_raw_response.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = await response.parse() + assert_matches_type(RulesetCreateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.with_streaming_response.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = await response.parse() + assert_matches_type(RulesetCreateResponse, ruleset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.create( + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RulesetUpdateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + description="A description for my ruleset.", + kind="root", + name="My ruleset", + phase="http_request_firewall_custom", + rules=[ + { + "id": "3a03d665bac047339bb530ecb439a90d", + "action": "block", + "action_parameters": { + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + "description": "Block the request.", + "enabled": True, + "exposed_credential_check": { + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + "expression": "ip.src eq 1.1.1.1", + "logging": {"enabled": True}, + "ratelimit": { + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + "ref": "my_ref", + } + ], + ) + assert_matches_type(RulesetUpdateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.with_raw_response.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = await response.parse() + assert_matches_type(RulesetUpdateResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.with_streaming_response.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = await response.parse() + assert_matches_type(RulesetUpdateResponse, ruleset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.with_raw_response.update( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.update( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.list( + account_id="account_id", + ) + assert_matches_type(AsyncCursorPagination[RulesetListResponse], ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.list( + account_id="account_id", + cursor="dGhpc2lzYW5leGFtcGxlCg", + per_page=3, + ) + assert_matches_type(AsyncCursorPagination[RulesetListResponse], ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = await response.parse() + assert_matches_type(AsyncCursorPagination[RulesetListResponse], ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = await response.parse() + assert_matches_type(AsyncCursorPagination[RulesetListResponse], ruleset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.list( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.list( + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert ruleset is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert ruleset is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.with_raw_response.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = await response.parse() + assert ruleset is None + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.with_streaming_response.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = await response.parse() + assert ruleset is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.with_raw_response.delete( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.delete( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RulesetGetResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + ruleset = await async_client.rulesets.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RulesetGetResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.with_raw_response.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ruleset = await response.parse() + assert_matches_type(RulesetGetResponse, ruleset, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.with_streaming_response.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ruleset = await response.parse() + assert_matches_type(RulesetGetResponse, ruleset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.with_raw_response.get( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.with_raw_response.get( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) diff --git a/tests/api_resources/test_waiting_rooms.py b/tests/api_resources/test_waiting_rooms.py index a5ddfb25fd0..ed4243ca17b 100644 --- a/tests/api_resources/test_waiting_rooms.py +++ b/tests/api_resources/test_waiting_rooms.py @@ -9,6 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from cloudflare.types.waiting_rooms import ( WaitingRoom, WaitingRoomDeleteResponse, @@ -215,6 +216,73 @@ def test_path_params_update(self, client: Cloudflare) -> None: total_active_users=200, ) + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + waiting_room = client.waiting_rooms.list( + account_id="account_id", + ) + assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"]) + + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + waiting_room = client.waiting_rooms.list( + account_id="account_id", + page=1, + per_page=5, + ) + assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"]) + + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.waiting_rooms.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + waiting_room = response.parse() + assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"]) + + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.waiting_rooms.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + waiting_room = response.parse() + assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.waiting_rooms.with_raw_response.list( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.waiting_rooms.with_raw_response.list( + account_id="account_id", + ) + @parametrize def test_method_delete(self, client: Cloudflare) -> None: waiting_room = client.waiting_rooms.delete( @@ -617,6 +685,73 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: total_active_users=200, ) + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + waiting_room = await async_client.waiting_rooms.list( + account_id="account_id", + ) + assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"]) + + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + waiting_room = await async_client.waiting_rooms.list( + account_id="account_id", + page=1, + per_page=5, + ) + assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"]) + + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.waiting_rooms.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + waiting_room = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"]) + + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.waiting_rooms.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + waiting_room = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip( + reason="TODO: investigate path combination CI failures - https://github.com/cloudflare/cloudflare-python/actions/runs/13889017239/job/38857790771?pr=2359#step:5:3197" + ) + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.waiting_rooms.with_raw_response.list( + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.waiting_rooms.with_raw_response.list( + account_id="account_id", + ) + @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: waiting_room = await async_client.waiting_rooms.delete( diff --git a/tests/api_resources/url_normalization/__init__.py b/tests/api_resources/url_normalization/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/url_normalization/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/url_scanner/test_scans.py b/tests/api_resources/url_scanner/test_scans.py index bcb27351ece..0bf41c85a78 100644 --- a/tests/api_resources/url_scanner/test_scans.py +++ b/tests/api_resources/url_scanner/test_scans.py @@ -44,6 +44,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: scan = client.url_scanner.scans.create( account_id="account_id", url="https://www.example.com", + agent_readiness=True, country="AF", customagent="customagent", custom_headers={"foo": "string"}, @@ -148,6 +149,7 @@ def test_method_bulk_create_with_all_params(self, client: Cloudflare) -> None: body=[ { "url": "https://www.example.com", + "agent_readiness": True, "customagent": "customagent", "custom_headers": {"foo": "string"}, "referer": "referer", @@ -438,6 +440,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare scan = await async_client.url_scanner.scans.create( account_id="account_id", url="https://www.example.com", + agent_readiness=True, country="AF", customagent="customagent", custom_headers={"foo": "string"}, @@ -542,6 +545,7 @@ async def test_method_bulk_create_with_all_params(self, async_client: AsyncCloud body=[ { "url": "https://www.example.com", + "agent_readiness": True, "customagent": "customagent", "custom_headers": {"foo": "string"}, "referer": "referer", diff --git a/tests/api_resources/vectorize/test_indexes.py b/tests/api_resources/vectorize/test_indexes.py index 4429a86da2c..58f6825765c 100644 --- a/tests/api_resources/vectorize/test_indexes.py +++ b/tests/api_resources/vectorize/test_indexes.py @@ -400,7 +400,7 @@ def test_method_insert(self, client: Cloudflare) -> None: index = client.vectorize.indexes.insert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) assert_matches_type(Optional[IndexInsertResponse], index, path=["response"]) @@ -410,7 +410,7 @@ def test_method_insert_with_all_params(self, client: Cloudflare) -> None: index = client.vectorize.indexes.insert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", unparsable_behavior="error", ) assert_matches_type(Optional[IndexInsertResponse], index, path=["response"]) @@ -421,7 +421,7 @@ def test_raw_response_insert(self, client: Cloudflare) -> None: response = client.vectorize.indexes.with_raw_response.insert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) assert response.is_closed is True @@ -435,7 +435,7 @@ def test_streaming_response_insert(self, client: Cloudflare) -> None: with client.vectorize.indexes.with_streaming_response.insert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -452,14 +452,14 @@ def test_path_params_insert(self, client: Cloudflare) -> None: client.vectorize.indexes.with_raw_response.insert( index_name="example-index", account_id="", - body=b"raw file contents", + body=b"Example data", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"): client.vectorize.indexes.with_raw_response.insert( index_name="", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) @parametrize @@ -595,7 +595,7 @@ def test_method_upsert(self, client: Cloudflare) -> None: index = client.vectorize.indexes.upsert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) assert_matches_type(Optional[IndexUpsertResponse], index, path=["response"]) @@ -605,7 +605,7 @@ def test_method_upsert_with_all_params(self, client: Cloudflare) -> None: index = client.vectorize.indexes.upsert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", unparsable_behavior="error", ) assert_matches_type(Optional[IndexUpsertResponse], index, path=["response"]) @@ -616,7 +616,7 @@ def test_raw_response_upsert(self, client: Cloudflare) -> None: response = client.vectorize.indexes.with_raw_response.upsert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) assert response.is_closed is True @@ -630,7 +630,7 @@ def test_streaming_response_upsert(self, client: Cloudflare) -> None: with client.vectorize.indexes.with_streaming_response.upsert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -647,14 +647,14 @@ def test_path_params_upsert(self, client: Cloudflare) -> None: client.vectorize.indexes.with_raw_response.upsert( index_name="example-index", account_id="", - body=b"raw file contents", + body=b"Example data", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"): client.vectorize.indexes.with_raw_response.upsert( index_name="", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) @@ -1036,7 +1036,7 @@ async def test_method_insert(self, async_client: AsyncCloudflare) -> None: index = await async_client.vectorize.indexes.insert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) assert_matches_type(Optional[IndexInsertResponse], index, path=["response"]) @@ -1046,7 +1046,7 @@ async def test_method_insert_with_all_params(self, async_client: AsyncCloudflare index = await async_client.vectorize.indexes.insert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", unparsable_behavior="error", ) assert_matches_type(Optional[IndexInsertResponse], index, path=["response"]) @@ -1057,7 +1057,7 @@ async def test_raw_response_insert(self, async_client: AsyncCloudflare) -> None: response = await async_client.vectorize.indexes.with_raw_response.insert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) assert response.is_closed is True @@ -1071,7 +1071,7 @@ async def test_streaming_response_insert(self, async_client: AsyncCloudflare) -> async with async_client.vectorize.indexes.with_streaming_response.insert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1088,14 +1088,14 @@ async def test_path_params_insert(self, async_client: AsyncCloudflare) -> None: await async_client.vectorize.indexes.with_raw_response.insert( index_name="example-index", account_id="", - body=b"raw file contents", + body=b"Example data", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"): await async_client.vectorize.indexes.with_raw_response.insert( index_name="", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) @parametrize @@ -1231,7 +1231,7 @@ async def test_method_upsert(self, async_client: AsyncCloudflare) -> None: index = await async_client.vectorize.indexes.upsert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) assert_matches_type(Optional[IndexUpsertResponse], index, path=["response"]) @@ -1241,7 +1241,7 @@ async def test_method_upsert_with_all_params(self, async_client: AsyncCloudflare index = await async_client.vectorize.indexes.upsert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", unparsable_behavior="error", ) assert_matches_type(Optional[IndexUpsertResponse], index, path=["response"]) @@ -1252,7 +1252,7 @@ async def test_raw_response_upsert(self, async_client: AsyncCloudflare) -> None: response = await async_client.vectorize.indexes.with_raw_response.upsert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) assert response.is_closed is True @@ -1266,7 +1266,7 @@ async def test_streaming_response_upsert(self, async_client: AsyncCloudflare) -> async with async_client.vectorize.indexes.with_streaming_response.upsert( index_name="example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1283,12 +1283,12 @@ async def test_path_params_upsert(self, async_client: AsyncCloudflare) -> None: await async_client.vectorize.indexes.with_raw_response.upsert( index_name="example-index", account_id="", - body=b"raw file contents", + body=b"Example data", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"): await async_client.vectorize.indexes.with_raw_response.upsert( index_name="", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=b"raw file contents", + body=b"Example data", ) diff --git a/tests/api_resources/workers/beta/workers/test_versions.py b/tests/api_resources/workers/beta/workers/test_versions.py index 3e34d30389e..e87d3a90fe2 100644 --- a/tests/api_resources/workers/beta/workers/test_versions.py +++ b/tests/api_resources/workers/beta/workers/test_versions.py @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "config": { "html_handling": "auto-trailing-slash", "not_found_handling": "404-page", - "run_worker_first": ["string"], + "run_worker_first": True, }, "jwt": "jwt", }, @@ -350,7 +350,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "config": { "html_handling": "auto-trailing-slash", "not_found_handling": "404-page", - "run_worker_first": ["string"], + "run_worker_first": True, }, "jwt": "jwt", }, diff --git a/tests/api_resources/workers/scripts/test_content.py b/tests/api_resources/workers/scripts/test_content.py index 0b849e9c51a..6bd3db7e885 100644 --- a/tests/api_resources/workers/scripts/test_content.py +++ b/tests/api_resources/workers/scripts/test_content.py @@ -45,7 +45,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "body_part": "worker.js", "main_module": "worker.js", }, - files=[b"raw file contents"], + files=[b"Example data"], cf_worker_body_part="CF-WORKER-BODY-PART", cf_worker_main_module_part="CF-WORKER-MAIN-MODULE-PART", ) @@ -190,7 +190,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "body_part": "worker.js", "main_module": "worker.js", }, - files=[b"raw file contents"], + files=[b"Example data"], cf_worker_body_part="CF-WORKER-BODY-PART", cf_worker_main_module_part="CF-WORKER-MAIN-MODULE-PART", ) diff --git a/tests/api_resources/workers/scripts/test_versions.py b/tests/api_resources/workers/scripts/test_versions.py index b144e8b618c..f78c8a7d8a7 100644 --- a/tests/api_resources/workers/scripts/test_versions.py +++ b/tests/api_resources/workers/scripts/test_versions.py @@ -58,7 +58,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "usage_model": "standard", }, bindings_inherit="strict", - files=[b"raw file contents"], + files=[b"Example data"], ) assert_matches_type(VersionCreateResponse, version, path=["response"]) @@ -270,7 +270,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "usage_model": "standard", }, bindings_inherit="strict", - files=[b"raw file contents"], + files=[b"Example data"], ) assert_matches_type(VersionCreateResponse, version, path=["response"]) diff --git a/tests/api_resources/workers/test_scripts.py b/tests/api_resources/workers/test_scripts.py index 4a8239e1717..6658a0b723e 100644 --- a/tests/api_resources/workers/test_scripts.py +++ b/tests/api_resources/workers/test_scripts.py @@ -49,7 +49,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "_redirects": "/foo /bar 301\n/news/* /blog/:splat", "html_handling": "auto-trailing-slash", "not_found_handling": "404-page", - "run_worker_first": ["string"], + "run_worker_first": True, "serve_directly": True, }, "jwt": "jwt", @@ -121,7 +121,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "usage_model": "standard", }, bindings_inherit="strict", - files=[b"raw file contents"], + files=[b"Example data"], ) assert_matches_type(ScriptUpdateResponse, script, path=["response"]) @@ -410,7 +410,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "_redirects": "/foo /bar 301\n/news/* /blog/:splat", "html_handling": "auto-trailing-slash", "not_found_handling": "404-page", - "run_worker_first": ["string"], + "run_worker_first": True, "serve_directly": True, }, "jwt": "jwt", @@ -482,7 +482,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "usage_model": "standard", }, bindings_inherit="strict", - files=[b"raw file contents"], + files=[b"Example data"], ) assert_matches_type(ScriptUpdateResponse, script, path=["response"]) diff --git a/tests/api_resources/workers_for_platforms/dispatch/namespaces/scripts/test_content.py b/tests/api_resources/workers_for_platforms/dispatch/namespaces/scripts/test_content.py index 276ca71f189..8224ae4d2d9 100644 --- a/tests/api_resources/workers_for_platforms/dispatch/namespaces/scripts/test_content.py +++ b/tests/api_resources/workers_for_platforms/dispatch/namespaces/scripts/test_content.py @@ -47,7 +47,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "body_part": "worker.js", "main_module": "worker.js", }, - files=[b"raw file contents"], + files=[b"Example data"], cf_worker_body_part="CF-WORKER-BODY-PART", cf_worker_main_module_part="CF-WORKER-MAIN-MODULE-PART", ) @@ -218,7 +218,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "body_part": "worker.js", "main_module": "worker.js", }, - files=[b"raw file contents"], + files=[b"Example data"], cf_worker_body_part="CF-WORKER-BODY-PART", cf_worker_main_module_part="CF-WORKER-MAIN-MODULE-PART", ) diff --git a/tests/api_resources/workers_for_platforms/dispatch/namespaces/test_scripts.py b/tests/api_resources/workers_for_platforms/dispatch/namespaces/test_scripts.py index 03a2bb34c75..59fee2fd51a 100644 --- a/tests/api_resources/workers_for_platforms/dispatch/namespaces/test_scripts.py +++ b/tests/api_resources/workers_for_platforms/dispatch/namespaces/test_scripts.py @@ -45,7 +45,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "_redirects": "/foo /bar 301\n/news/* /blog/:splat", "html_handling": "auto-trailing-slash", "not_found_handling": "404-page", - "run_worker_first": ["string"], + "run_worker_first": True, "serve_directly": True, }, "jwt": "jwt", @@ -117,7 +117,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "usage_model": "standard", }, bindings_inherit="strict", - files=[b"raw file contents"], + files=[b"Example data"], ) assert_matches_type(ScriptUpdateResponse, script, path=["response"]) @@ -341,7 +341,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "_redirects": "/foo /bar 301\n/news/* /blog/:splat", "html_handling": "auto-trailing-slash", "not_found_handling": "404-page", - "run_worker_first": ["string"], + "run_worker_first": True, "serve_directly": True, }, "jwt": "jwt", @@ -413,7 +413,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "usage_model": "standard", }, bindings_inherit="strict", - files=[b"raw file contents"], + files=[b"Example data"], ) assert_matches_type(ScriptUpdateResponse, script, path=["response"]) diff --git a/tests/api_resources/workflows/test_instances.py b/tests/api_resources/workflows/test_instances.py index 9d29e7aa3e7..5ffbec6aa23 100644 --- a/tests/api_resources/workflows/test_instances.py +++ b/tests/api_resources/workflows/test_instances.py @@ -39,8 +39,8 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_id="account_id", instance_id="instance_id", instance_retention={ - "error_retention": 0, - "success_retention": 0, + "error_retention": "5 minutes", + "success_retention": "5 minutes", }, params={}, ) @@ -166,8 +166,8 @@ def test_method_bulk_with_all_params(self, client: Cloudflare) -> None: { "instance_id": "instance_id", "instance_retention": { - "error_retention": 0, - "success_retention": 0, + "error_retention": "5 minutes", + "success_retention": "5 minutes", }, "params": {}, } @@ -307,8 +307,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_id="account_id", instance_id="instance_id", instance_retention={ - "error_retention": 0, - "success_retention": 0, + "error_retention": "5 minutes", + "success_retention": "5 minutes", }, params={}, ) @@ -434,8 +434,8 @@ async def test_method_bulk_with_all_params(self, async_client: AsyncCloudflare) { "instance_id": "instance_id", "instance_retention": { - "error_retention": 0, - "success_retention": 0, + "error_retention": "5 minutes", + "success_retention": "5 minutes", }, "params": {}, } diff --git a/tests/api_resources/zero_trust/access/applications/test_policy_tests.py b/tests/api_resources/zero_trust/access/applications/test_policy_tests.py index e987c50a3c1..b5a54c9a9c4 100755 --- a/tests/api_resources/zero_trust/access/applications/test_policy_tests.py +++ b/tests/api_resources/zero_trust/access/applications/test_policy_tests.py @@ -31,43 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: def test_method_create_with_all_params(self, client: Cloudflare) -> None: policy_test = client.zero_trust.access.applications.policy_tests.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", - policies=[ - { - "decision": "allow", - "include": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], - "name": "Allow devs", - "approval_groups": [ - { - "approvals_needed": 1, - "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "email_list_uuid", - }, - { - "approvals_needed": 3, - "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", - }, - ], - "approval_required": True, - "connection_rules": { - "rdp": { - "allowed_clipboard_local_to_remote_formats": ["text"], - "allowed_clipboard_remote_to_local_formats": ["text"], - } - }, - "exclude": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], - "isolation_required": False, - "mfa_config": { - "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_disabled": False, - "session_duration": "24h", - }, - "purpose_justification_prompt": "Please enter a justification for entering this protected domain.", - "purpose_justification_required": True, - "require": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], - "session_duration": "24h", - } - ], + policies=["f1a8b3c9d4e5f6789a0b1c2d3e4f5678a9b0c1d2e3f4a5b67890c1d2e3f4b5a6"], ) assert_matches_type(Optional[PolicyTestCreateResponse], policy_test, path=["response"]) @@ -167,43 +131,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: policy_test = await async_client.zero_trust.access.applications.policy_tests.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", - policies=[ - { - "decision": "allow", - "include": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], - "name": "Allow devs", - "approval_groups": [ - { - "approvals_needed": 1, - "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "email_list_uuid", - }, - { - "approvals_needed": 3, - "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", - }, - ], - "approval_required": True, - "connection_rules": { - "rdp": { - "allowed_clipboard_local_to_remote_formats": ["text"], - "allowed_clipboard_remote_to_local_formats": ["text"], - } - }, - "exclude": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], - "isolation_required": False, - "mfa_config": { - "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_disabled": False, - "session_duration": "24h", - }, - "purpose_justification_prompt": "Please enter a justification for entering this protected domain.", - "purpose_justification_required": True, - "require": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], - "session_duration": "24h", - } - ], + policies=["f1a8b3c9d4e5f6789a0b1c2d3e4f5678a9b0c1d2e3f4a5b67890c1d2e3f4b5a6"], ) assert_matches_type(Optional[PolicyTestCreateResponse], policy_test, path=["response"]) diff --git a/tests/api_resources/zero_trust/access/test_applications.py b/tests/api_resources/zero_trust/access/test_applications.py index 6eaea008e8b..8de6e58e2a8 100644 --- a/tests/api_resources/zero_trust/access/test_applications.py +++ b/tests/api_resources/zero_trust/access/test_applications.py @@ -122,12 +122,7 @@ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> N }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -230,12 +225,7 @@ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> N custom_pages=["699d98642c564d2e855e9661899b7252"], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -432,12 +422,7 @@ def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> N }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -619,12 +604,7 @@ def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> N }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -744,12 +724,7 @@ def test_method_create_with_all_params_overload_5(self, client: Cloudflare) -> N "message": "Log in below to reach your applications behind Access.", "title": "Welcome back!", }, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", skip_app_launcher_login_page=True, ) @@ -818,12 +793,7 @@ def test_method_create_with_all_params_overload_6(self, client: Cloudflare) -> N custom_deny_url="custom_deny_url", custom_non_identity_deny_url="custom_non_identity_deny_url", custom_pages=["699d98642c564d2e855e9661899b7252"], - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -891,12 +861,7 @@ def test_method_create_with_all_params_overload_7(self, client: Cloudflare) -> N custom_deny_url="custom_deny_url", custom_non_identity_deny_url="custom_non_identity_deny_url", custom_pages=["699d98642c564d2e855e9661899b7252"], - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -966,12 +931,7 @@ def test_method_create_with_all_params_overload_8(self, client: Cloudflare) -> N custom_pages=["699d98642c564d2e855e9661899b7252"], domain="abcd123456.proxy.cloudflare-gateway.com", name="Gateway Proxy", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -1036,12 +996,7 @@ def test_method_create_with_all_params_overload_9(self, client: Cloudflare) -> N domain="https://mybookmark.com", logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], tags=["engineers"], type="bookmark", ) @@ -1119,7 +1074,7 @@ def test_method_create_with_all_params_overload_10(self, client: Cloudflare) -> policies=[ { "decision": "allow", - "include": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "include": [{"certificate": {}}], "name": "Allow devs", "connection_rules": { "ssh": { @@ -1127,13 +1082,13 @@ def test_method_create_with_all_params_overload_10(self, client: Cloudflare) -> "allow_email_alias": True, } }, - "exclude": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "exclude": [{"certificate": {}}], "mfa_config": { "allowed_authenticators": ["ssh_piv_key"], "mfa_disabled": False, "session_duration": "24h", }, - "require": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "require": [{"certificate": {}}], } ], ) @@ -1322,12 +1277,7 @@ def test_method_create_with_all_params_overload_11(self, client: Cloudflare) -> }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -1516,12 +1466,7 @@ def test_method_create_with_all_params_overload_12(self, client: Cloudflare) -> }, }, options_preflight_bypass=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], same_site_cookie_attribute="strict", scim_config={ "idp_uid": "idp_uid", @@ -1674,12 +1619,7 @@ def test_method_create_with_all_params_overload_13(self, client: Cloudflare) -> }, }, options_preflight_bypass=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], same_site_cookie_attribute="strict", scim_config={ "idp_uid": "idp_uid", @@ -1854,12 +1794,7 @@ def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> N }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -1976,12 +1911,7 @@ def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> N custom_pages=["699d98642c564d2e855e9661899b7252"], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -2190,12 +2120,7 @@ def test_method_update_with_all_params_overload_3(self, client: Cloudflare) -> N }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -2391,12 +2316,7 @@ def test_method_update_with_all_params_overload_4(self, client: Cloudflare) -> N }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -2530,12 +2450,7 @@ def test_method_update_with_all_params_overload_5(self, client: Cloudflare) -> N "message": "Log in below to reach your applications behind Access.", "title": "Welcome back!", }, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", skip_app_launcher_login_page=True, ) @@ -2617,12 +2532,7 @@ def test_method_update_with_all_params_overload_6(self, client: Cloudflare) -> N custom_deny_url="custom_deny_url", custom_non_identity_deny_url="custom_non_identity_deny_url", custom_pages=["699d98642c564d2e855e9661899b7252"], - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -2703,12 +2613,7 @@ def test_method_update_with_all_params_overload_7(self, client: Cloudflare) -> N custom_deny_url="custom_deny_url", custom_non_identity_deny_url="custom_non_identity_deny_url", custom_pages=["699d98642c564d2e855e9661899b7252"], - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -2791,12 +2696,7 @@ def test_method_update_with_all_params_overload_8(self, client: Cloudflare) -> N custom_pages=["699d98642c564d2e855e9661899b7252"], domain="abcd123456.proxy.cloudflare-gateway.com", name="Gateway Proxy", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -2874,12 +2774,7 @@ def test_method_update_with_all_params_overload_9(self, client: Cloudflare) -> N domain="https://mybookmark.com", logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], tags=["engineers"], type="bookmark", ) @@ -2969,7 +2864,7 @@ def test_method_update_with_all_params_overload_10(self, client: Cloudflare) -> policies=[ { "decision": "allow", - "include": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "include": [{"certificate": {}}], "name": "Allow devs", "connection_rules": { "ssh": { @@ -2977,13 +2872,13 @@ def test_method_update_with_all_params_overload_10(self, client: Cloudflare) -> "allow_email_alias": True, } }, - "exclude": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "exclude": [{"certificate": {}}], "mfa_config": { "allowed_authenticators": ["ssh_piv_key"], "mfa_disabled": False, "session_duration": "24h", }, - "require": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "require": [{"certificate": {}}], } ], ) @@ -3192,12 +3087,7 @@ def test_method_update_with_all_params_overload_11(self, client: Cloudflare) -> }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -3407,12 +3297,7 @@ def test_method_update_with_all_params_overload_12(self, client: Cloudflare) -> }, }, options_preflight_bypass=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], same_site_cookie_attribute="strict", scim_config={ "idp_uid": "idp_uid", @@ -3578,12 +3463,7 @@ def test_method_update_with_all_params_overload_13(self, client: Cloudflare) -> }, }, options_preflight_bypass=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], same_site_cookie_attribute="strict", scim_config={ "idp_uid": "idp_uid", @@ -4037,12 +3917,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -4145,12 +4020,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn custom_pages=["699d98642c564d2e855e9661899b7252"], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -4347,12 +4217,7 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -4534,12 +4399,7 @@ async def test_method_create_with_all_params_overload_4(self, async_client: Asyn }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -4659,12 +4519,7 @@ async def test_method_create_with_all_params_overload_5(self, async_client: Asyn "message": "Log in below to reach your applications behind Access.", "title": "Welcome back!", }, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", skip_app_launcher_login_page=True, ) @@ -4733,12 +4588,7 @@ async def test_method_create_with_all_params_overload_6(self, async_client: Asyn custom_deny_url="custom_deny_url", custom_non_identity_deny_url="custom_non_identity_deny_url", custom_pages=["699d98642c564d2e855e9661899b7252"], - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -4806,12 +4656,7 @@ async def test_method_create_with_all_params_overload_7(self, async_client: Asyn custom_deny_url="custom_deny_url", custom_non_identity_deny_url="custom_non_identity_deny_url", custom_pages=["699d98642c564d2e855e9661899b7252"], - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -4881,12 +4726,7 @@ async def test_method_create_with_all_params_overload_8(self, async_client: Asyn custom_pages=["699d98642c564d2e855e9661899b7252"], domain="abcd123456.proxy.cloudflare-gateway.com", name="Gateway Proxy", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -4951,12 +4791,7 @@ async def test_method_create_with_all_params_overload_9(self, async_client: Asyn domain="https://mybookmark.com", logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], tags=["engineers"], type="bookmark", ) @@ -5034,7 +4869,7 @@ async def test_method_create_with_all_params_overload_10(self, async_client: Asy policies=[ { "decision": "allow", - "include": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "include": [{"certificate": {}}], "name": "Allow devs", "connection_rules": { "ssh": { @@ -5042,13 +4877,13 @@ async def test_method_create_with_all_params_overload_10(self, async_client: Asy "allow_email_alias": True, } }, - "exclude": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "exclude": [{"certificate": {}}], "mfa_config": { "allowed_authenticators": ["ssh_piv_key"], "mfa_disabled": False, "session_duration": "24h", }, - "require": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "require": [{"certificate": {}}], } ], ) @@ -5237,12 +5072,7 @@ async def test_method_create_with_all_params_overload_11(self, async_client: Asy }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -5431,12 +5261,7 @@ async def test_method_create_with_all_params_overload_12(self, async_client: Asy }, }, options_preflight_bypass=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], same_site_cookie_attribute="strict", scim_config={ "idp_uid": "idp_uid", @@ -5589,12 +5414,7 @@ async def test_method_create_with_all_params_overload_13(self, async_client: Asy }, }, options_preflight_bypass=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], same_site_cookie_attribute="strict", scim_config={ "idp_uid": "idp_uid", @@ -5769,12 +5589,7 @@ async def test_method_update_with_all_params_overload_1(self, async_client: Asyn }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -5891,12 +5706,7 @@ async def test_method_update_with_all_params_overload_2(self, async_client: Asyn custom_pages=["699d98642c564d2e855e9661899b7252"], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -6105,12 +5915,7 @@ async def test_method_update_with_all_params_overload_3(self, async_client: Asyn }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -6306,12 +6111,7 @@ async def test_method_update_with_all_params_overload_4(self, async_client: Asyn }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -6445,12 +6245,7 @@ async def test_method_update_with_all_params_overload_5(self, async_client: Asyn "message": "Log in below to reach your applications behind Access.", "title": "Welcome back!", }, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", skip_app_launcher_login_page=True, ) @@ -6532,12 +6327,7 @@ async def test_method_update_with_all_params_overload_6(self, async_client: Asyn custom_deny_url="custom_deny_url", custom_non_identity_deny_url="custom_non_identity_deny_url", custom_pages=["699d98642c564d2e855e9661899b7252"], - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -6618,12 +6408,7 @@ async def test_method_update_with_all_params_overload_7(self, async_client: Asyn custom_deny_url="custom_deny_url", custom_non_identity_deny_url="custom_non_identity_deny_url", custom_pages=["699d98642c564d2e855e9661899b7252"], - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -6706,12 +6491,7 @@ async def test_method_update_with_all_params_overload_8(self, async_client: Asyn custom_pages=["699d98642c564d2e855e9661899b7252"], domain="abcd123456.proxy.cloudflare-gateway.com", name="Gateway Proxy", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -6789,12 +6569,7 @@ async def test_method_update_with_all_params_overload_9(self, async_client: Asyn domain="https://mybookmark.com", logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], tags=["engineers"], type="bookmark", ) @@ -6884,7 +6659,7 @@ async def test_method_update_with_all_params_overload_10(self, async_client: Asy policies=[ { "decision": "allow", - "include": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "include": [{"certificate": {}}], "name": "Allow devs", "connection_rules": { "ssh": { @@ -6892,13 +6667,13 @@ async def test_method_update_with_all_params_overload_10(self, async_client: Asy "allow_email_alias": True, } }, - "exclude": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "exclude": [{"certificate": {}}], "mfa_config": { "allowed_authenticators": ["ssh_piv_key"], "mfa_disabled": False, "session_duration": "24h", }, - "require": [{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + "require": [{"certificate": {}}], } ], ) @@ -7107,12 +6882,7 @@ async def test_method_update_with_all_params_overload_11(self, async_client: Asy }, options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], read_service_tokens_from_header="Authorization", same_site_cookie_attribute="strict", scim_config={ @@ -7322,12 +7092,7 @@ async def test_method_update_with_all_params_overload_12(self, async_client: Asy }, }, options_preflight_bypass=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], same_site_cookie_attribute="strict", scim_config={ "idp_uid": "idp_uid", @@ -7493,12 +7258,7 @@ async def test_method_update_with_all_params_overload_13(self, async_client: Asy }, }, options_preflight_bypass=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - } - ], + policies=["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"], same_site_cookie_attribute="strict", scim_config={ "idp_uid": "idp_uid", diff --git a/tests/api_resources/zero_trust/access/test_groups.py b/tests/api_resources/zero_trust/access/test_groups.py index 66b87db4b78..d345f2efc97 100644 --- a/tests/api_resources/zero_trust/access/test_groups.py +++ b/tests/api_resources/zero_trust/access/test_groups.py @@ -28,7 +28,7 @@ class TestGroups: @parametrize def test_method_create(self, client: Cloudflare) -> None: group = client.zero_trust.access.groups.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -38,12 +38,12 @@ def test_method_create(self, client: Cloudflare) -> None: @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: group = client.zero_trust.access.groups.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", - exclude=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + exclude=[{"certificate": {}}], is_default=True, - require=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + require=[{"certificate": {}}], ) assert_matches_type(Optional[GroupCreateResponse], group, path=["response"]) @@ -51,7 +51,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.zero_trust.access.groups.with_raw_response.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -65,7 +65,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.zero_trust.access.groups.with_streaming_response.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) as response: @@ -82,14 +82,14 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): client.zero_trust.access.groups.with_raw_response.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="", ) with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): client.zero_trust.access.groups.with_raw_response.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -99,7 +99,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: def test_method_update(self, client: Cloudflare) -> None: group = client.zero_trust.access.groups.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -110,12 +110,12 @@ def test_method_update(self, client: Cloudflare) -> None: def test_method_update_with_all_params(self, client: Cloudflare) -> None: group = client.zero_trust.access.groups.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", - exclude=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + exclude=[{"certificate": {}}], is_default=True, - require=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + require=[{"certificate": {}}], ) assert_matches_type(Optional[GroupUpdateResponse], group, path=["response"]) @@ -124,7 +124,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_update(self, client: Cloudflare) -> None: response = client.zero_trust.access.groups.with_raw_response.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -139,7 +139,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: def test_streaming_response_update(self, client: Cloudflare) -> None: with client.zero_trust.access.groups.with_streaming_response.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) as response: @@ -157,7 +157,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `group_id` but received ''"): client.zero_trust.access.groups.with_raw_response.update( group_id="", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -165,7 +165,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): client.zero_trust.access.groups.with_raw_response.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="", ) @@ -173,7 +173,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): client.zero_trust.access.groups.with_raw_response.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -381,7 +381,7 @@ class TestAsyncGroups: @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: group = await async_client.zero_trust.access.groups.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -391,12 +391,12 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: group = await async_client.zero_trust.access.groups.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", - exclude=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + exclude=[{"certificate": {}}], is_default=True, - require=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + require=[{"certificate": {}}], ) assert_matches_type(Optional[GroupCreateResponse], group, path=["response"]) @@ -404,7 +404,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.access.groups.with_raw_response.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -418,7 +418,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.access.groups.with_streaming_response.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) as response: @@ -435,14 +435,14 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): await async_client.zero_trust.access.groups.with_raw_response.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="", ) with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): await async_client.zero_trust.access.groups.with_raw_response.create( - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -452,7 +452,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: async def test_method_update(self, async_client: AsyncCloudflare) -> None: group = await async_client.zero_trust.access.groups.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -463,12 +463,12 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: group = await async_client.zero_trust.access.groups.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", - exclude=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + exclude=[{"certificate": {}}], is_default=True, - require=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + require=[{"certificate": {}}], ) assert_matches_type(Optional[GroupUpdateResponse], group, path=["response"]) @@ -477,7 +477,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.access.groups.with_raw_response.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -492,7 +492,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.access.groups.with_streaming_response.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) as response: @@ -510,7 +510,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `group_id` but received ''"): await async_client.zero_trust.access.groups.with_raw_response.update( group_id="", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) @@ -518,7 +518,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): await async_client.zero_trust.access.groups.with_raw_response.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="", ) @@ -526,7 +526,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): await async_client.zero_trust.access.groups.with_raw_response.update( group_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", account_id="account_id", ) diff --git a/tests/api_resources/zero_trust/access/test_policies.py b/tests/api_resources/zero_trust/access/test_policies.py index 7986e7f7922..6f732ad1c66 100644 --- a/tests/api_resources/zero_trust/access/test_policies.py +++ b/tests/api_resources/zero_trust/access/test_policies.py @@ -29,7 +29,7 @@ def test_method_create(self, client: Cloudflare) -> None: policy = client.zero_trust.access.policies.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @@ -39,7 +39,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: policy = client.zero_trust.access.policies.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", approval_groups=[ { @@ -60,7 +60,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "allowed_clipboard_remote_to_local_formats": ["text"], } }, - exclude=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + exclude=[{"certificate": {}}], isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], @@ -69,7 +69,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: }, purpose_justification_prompt="Please enter a justification for entering this protected domain.", purpose_justification_required=True, - require=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + require=[{"certificate": {}}], session_duration="24h", ) assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @@ -79,7 +79,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: response = client.zero_trust.access.policies.with_raw_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) @@ -93,7 +93,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: with client.zero_trust.access.policies.with_streaming_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) as response: assert not response.is_closed @@ -110,7 +110,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: client.zero_trust.access.policies.with_raw_response.create( account_id="", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) @@ -120,7 +120,7 @@ def test_method_update(self, client: Cloudflare) -> None: policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @@ -131,7 +131,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", approval_groups=[ { @@ -152,7 +152,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "allowed_clipboard_remote_to_local_formats": ["text"], } }, - exclude=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + exclude=[{"certificate": {}}], isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], @@ -161,7 +161,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: }, purpose_justification_prompt="Please enter a justification for entering this protected domain.", purpose_justification_required=True, - require=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + require=[{"certificate": {}}], session_duration="24h", ) assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @@ -172,7 +172,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) @@ -187,7 +187,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) as response: assert not response.is_closed @@ -205,7 +205,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) @@ -214,7 +214,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: policy_id="", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) @@ -372,7 +372,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: policy = await async_client.zero_trust.access.policies.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @@ -382,7 +382,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare policy = await async_client.zero_trust.access.policies.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", approval_groups=[ { @@ -403,7 +403,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "allowed_clipboard_remote_to_local_formats": ["text"], } }, - exclude=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + exclude=[{"certificate": {}}], isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], @@ -412,7 +412,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare }, purpose_justification_prompt="Please enter a justification for entering this protected domain.", purpose_justification_required=True, - require=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + require=[{"certificate": {}}], session_duration="24h", ) assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @@ -422,7 +422,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.access.policies.with_raw_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) @@ -436,7 +436,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> async with async_client.zero_trust.access.policies.with_streaming_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) as response: assert not response.is_closed @@ -453,7 +453,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.access.policies.with_raw_response.create( account_id="", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) @@ -463,7 +463,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @@ -474,7 +474,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", approval_groups=[ { @@ -495,7 +495,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "allowed_clipboard_remote_to_local_formats": ["text"], } }, - exclude=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + exclude=[{"certificate": {}}], isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], @@ -504,7 +504,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare }, purpose_justification_prompt="Please enter a justification for entering this protected domain.", purpose_justification_required=True, - require=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + require=[{"certificate": {}}], session_duration="24h", ) assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @@ -515,7 +515,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) @@ -530,7 +530,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) as response: assert not response.is_closed @@ -548,7 +548,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) @@ -557,7 +557,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: policy_id="", account_id="023e105f4ecef8ad9ca31a8372d0c353", decision="allow", - include=[{"group": {"id": "aa0a4aab-672b-4bdb-bc33-a59f1130a11f"}}], + include=[{"certificate": {}}], name="Allow devs", ) diff --git a/tests/api_resources/zero_trust/dlp/datasets/test_upload.py b/tests/api_resources/zero_trust/dlp/datasets/test_upload.py index 8402e87a1fa..e94fe046a8b 100644 --- a/tests/api_resources/zero_trust/dlp/datasets/test_upload.py +++ b/tests/api_resources/zero_trust/dlp/datasets/test_upload.py @@ -71,7 +71,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: def test_method_edit(self, client: Cloudflare) -> None: upload = client.zero_trust.dlp.datasets.upload.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) @@ -82,7 +82,7 @@ def test_method_edit(self, client: Cloudflare) -> None: def test_raw_response_edit(self, client: Cloudflare) -> None: response = client.zero_trust.dlp.datasets.upload.with_raw_response.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) @@ -97,7 +97,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: def test_streaming_response_edit(self, client: Cloudflare) -> None: with client.zero_trust.dlp.datasets.upload.with_streaming_response.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) as response: @@ -115,7 +115,7 @@ def test_path_params_edit(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.zero_trust.dlp.datasets.upload.with_raw_response.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) @@ -123,7 +123,7 @@ def test_path_params_edit(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): client.zero_trust.dlp.datasets.upload.with_raw_response.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="account_id", dataset_id="", ) @@ -187,7 +187,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: async def test_method_edit(self, async_client: AsyncCloudflare) -> None: upload = await async_client.zero_trust.dlp.datasets.upload.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) @@ -198,7 +198,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dlp.datasets.upload.with_raw_response.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) @@ -213,7 +213,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dlp.datasets.upload.with_streaming_response.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) as response: @@ -231,7 +231,7 @@ async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.zero_trust.dlp.datasets.upload.with_raw_response.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) @@ -239,7 +239,7 @@ async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): await async_client.zero_trust.dlp.datasets.upload.with_raw_response.edit( version=0, - dataset=b"raw file contents", + dataset=b"Example data", account_id="account_id", dataset_id="", ) diff --git a/tests/api_resources/zero_trust/dlp/datasets/versions/test_entries.py b/tests/api_resources/zero_trust/dlp/datasets/versions/test_entries.py index 844eea1e03f..fdb87e96a92 100755 --- a/tests/api_resources/zero_trust/dlp/datasets/versions/test_entries.py +++ b/tests/api_resources/zero_trust/dlp/datasets/versions/test_entries.py @@ -22,7 +22,7 @@ class TestEntries: def test_method_create(self, client: Cloudflare) -> None: entry = client.zero_trust.dlp.datasets.versions.entries.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, @@ -34,7 +34,7 @@ def test_method_create(self, client: Cloudflare) -> None: def test_raw_response_create(self, client: Cloudflare) -> None: response = client.zero_trust.dlp.datasets.versions.entries.with_raw_response.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, @@ -50,7 +50,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: def test_streaming_response_create(self, client: Cloudflare) -> None: with client.zero_trust.dlp.datasets.versions.entries.with_streaming_response.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, @@ -69,7 +69,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.zero_trust.dlp.datasets.versions.entries.with_raw_response.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, @@ -78,7 +78,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): client.zero_trust.dlp.datasets.versions.entries.with_raw_response.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="", version=0, @@ -87,7 +87,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `entry_id` but received ''"): client.zero_trust.dlp.datasets.versions.entries.with_raw_response.create( entry_id="", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, @@ -104,7 +104,7 @@ class TestAsyncEntries: async def test_method_create(self, async_client: AsyncCloudflare) -> None: entry = await async_client.zero_trust.dlp.datasets.versions.entries.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, @@ -116,7 +116,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dlp.datasets.versions.entries.with_raw_response.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, @@ -132,7 +132,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dlp.datasets.versions.entries.with_streaming_response.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, @@ -151,7 +151,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.zero_trust.dlp.datasets.versions.entries.with_raw_response.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, @@ -160,7 +160,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): await async_client.zero_trust.dlp.datasets.versions.entries.with_raw_response.create( entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="", version=0, @@ -169,7 +169,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `entry_id` but received ''"): await async_client.zero_trust.dlp.datasets.versions.entries.with_raw_response.create( entry_id="", - dataset_version_entry=b"raw file contents", + dataset_version_entry=b"Example data", account_id="account_id", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", version=0, diff --git a/tests/api_resources/zero_trust/dlp/test_settings.py b/tests/api_resources/zero_trust/dlp/test_settings.py new file mode 100644 index 00000000000..96453fdca33 --- /dev/null +++ b/tests/api_resources/zero_trust/dlp/test_settings.py @@ -0,0 +1,380 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.zero_trust.dlp import DLPSettings + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSettings: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + setting = client.zero_trust.dlp.settings.update( + account_id="account_id", + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + setting = client.zero_trust.dlp.settings.update( + account_id="account_id", + ai_context_analysis=True, + ocr=True, + payload_logging={ + "masking_level": "full", + "public_key": "public_key", + }, + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.dlp.settings.with_raw_response.update( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.dlp.settings.with_streaming_response.update( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.dlp.settings.with_raw_response.update( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + setting = client.zero_trust.dlp.settings.delete( + account_id="account_id", + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.dlp.settings.with_raw_response.delete( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.dlp.settings.with_streaming_response.delete( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.dlp.settings.with_raw_response.delete( + account_id="", + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + setting = client.zero_trust.dlp.settings.edit( + account_id="account_id", + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + setting = client.zero_trust.dlp.settings.edit( + account_id="account_id", + ai_context_analysis=True, + ocr=True, + payload_logging={ + "masking_level": "full", + "public_key": "public_key", + }, + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.zero_trust.dlp.settings.with_raw_response.edit( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.zero_trust.dlp.settings.with_streaming_response.edit( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.dlp.settings.with_raw_response.edit( + account_id="", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + setting = client.zero_trust.dlp.settings.get( + account_id="account_id", + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.dlp.settings.with_raw_response.get( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.dlp.settings.with_streaming_response.get( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.dlp.settings.with_raw_response.get( + account_id="", + ) + + +class TestAsyncSettings: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.zero_trust.dlp.settings.update( + account_id="account_id", + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.zero_trust.dlp.settings.update( + account_id="account_id", + ai_context_analysis=True, + ocr=True, + payload_logging={ + "masking_level": "full", + "public_key": "public_key", + }, + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.dlp.settings.with_raw_response.update( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = await response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.dlp.settings.with_streaming_response.update( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = await response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.dlp.settings.with_raw_response.update( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.zero_trust.dlp.settings.delete( + account_id="account_id", + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.dlp.settings.with_raw_response.delete( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = await response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.dlp.settings.with_streaming_response.delete( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = await response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.dlp.settings.with_raw_response.delete( + account_id="", + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.zero_trust.dlp.settings.edit( + account_id="account_id", + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.zero_trust.dlp.settings.edit( + account_id="account_id", + ai_context_analysis=True, + ocr=True, + payload_logging={ + "masking_level": "full", + "public_key": "public_key", + }, + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.dlp.settings.with_raw_response.edit( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = await response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.dlp.settings.with_streaming_response.edit( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = await response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.dlp.settings.with_raw_response.edit( + account_id="", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.zero_trust.dlp.settings.get( + account_id="account_id", + ) + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.dlp.settings.with_raw_response.get( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = await response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.dlp.settings.with_streaming_response.get( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = await response.parse() + assert_matches_type(Optional[DLPSettings], setting, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.dlp.settings.with_raw_response.get( + account_id="", + ) diff --git a/tests/api_resources/zones/test_settings.py b/tests/api_resources/zones/test_settings.py index 63985d634a6..e477dbc9f08 100644 --- a/tests/api_resources/zones/test_settings.py +++ b/tests/api_resources/zones/test_settings.py @@ -87,10 +87,7 @@ def test_method_edit_with_all_params_overload_2(self, client: Cloudflare) -> Non setting = client.zones.settings.edit( setting_id="always_online", zone_id="023e105f4ecef8ad9ca31a8372d0c353", - value={ - "enabled": True, - "pool_id": "pool-id", - }, + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-SHA"], ) assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) @@ -258,10 +255,7 @@ async def test_method_edit_with_all_params_overload_2(self, async_client: AsyncC setting = await async_client.zones.settings.edit( setting_id="always_online", zone_id="023e105f4ecef8ad9ca31a8372d0c353", - value={ - "enabled": True, - "pool_id": "pool-id", - }, + value=["ECDHE-RSA-AES128-GCM-SHA256", "AES128-SHA"], ) assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) diff --git a/tests/test_client.py b/tests/test_client.py index 09b5e8b4e7c..5a98101a63f 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -486,6 +486,60 @@ def test_default_query_option(self) -> None: client.close() + def test_hardcoded_query_params_in_url(self, client: Cloudflare) -> None: + request = client._build_request(FinalRequestOptions(method="get", url="/foo?beta=true")) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true"} + + request = client._build_request( + FinalRequestOptions( + method="get", + url="/foo?beta=true", + params={"limit": "10", "page": "abc"}, + ) + ) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true", "limit": "10", "page": "abc"} + + request = client._build_request( + FinalRequestOptions( + method="get", + url="/files/a%2Fb?beta=true", + params={"limit": "10"}, + ) + ) + assert request.url.raw_path == b"/files/a%2Fb?beta=true&limit=10" + + def test_account_id_client_params(self, client: Cloudflare) -> None: + # Test with base client (no custom params) + with pytest.raises(ValueError, match="Missing account_id argument;"): + client.accounts.update(id="023e105f4ecef8ad9ca31a8372d0c353", name="Demo Account", type="standard") + + client = Cloudflare( + base_url=base_url, + api_key=api_key, + api_email=api_email, + _strict_response_validation=True, + account_id="f037e56e89293a057740de681ac9accp", + ) + with client as c2: + c2.accounts.update(id="023e105f4ecef8ad9ca31a8372d0c353", name="Demo Account", type="standard") + + def test_zone_id_client_params(self, client: Cloudflare) -> None: + # Test with base client (no custom params) + with pytest.raises(ValueError, match="Missing zone_id argument;"): + client.zones.delete() + + client = Cloudflare( + base_url=base_url, + api_key=api_key, + api_email=api_email, + _strict_response_validation=True, + zone_id="f037e56e89293a057740de681ac9accp", + ) + with client as c2: + c2.zones.delete() + def test_request_extra_json(self, client: Cloudflare) -> None: request = client._build_request( FinalRequestOptions( @@ -1136,6 +1190,14 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: # Test that the proxy environment variables are set correctly monkeypatch.setenv("HTTPS_PROXY", "https://example.org") + # Delete in case our environment has any proxy env vars set + monkeypatch.delenv("HTTP_PROXY", raising=False) + monkeypatch.delenv("ALL_PROXY", raising=False) + monkeypatch.delenv("NO_PROXY", raising=False) + monkeypatch.delenv("http_proxy", raising=False) + monkeypatch.delenv("https_proxy", raising=False) + monkeypatch.delenv("all_proxy", raising=False) + monkeypatch.delenv("no_proxy", raising=False) client = DefaultHttpxClient() @@ -1559,6 +1621,62 @@ async def test_default_query_option(self) -> None: await client.close() + async def test_hardcoded_query_params_in_url(self, async_client: AsyncCloudflare) -> None: + request = async_client._build_request(FinalRequestOptions(method="get", url="/foo?beta=true")) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true"} + + request = async_client._build_request( + FinalRequestOptions( + method="get", + url="/foo?beta=true", + params={"limit": "10", "page": "abc"}, + ) + ) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true", "limit": "10", "page": "abc"} + + request = async_client._build_request( + FinalRequestOptions( + method="get", + url="/files/a%2Fb?beta=true", + params={"limit": "10"}, + ) + ) + assert request.url.raw_path == b"/files/a%2Fb?beta=true&limit=10" + + async def test_account_id_client_params(self, async_client: AsyncCloudflare) -> None: + # Test with base client (no custom params) + with pytest.raises(ValueError, match="Missing account_id argument;"): + await async_client.accounts.update( + id="023e105f4ecef8ad9ca31a8372d0c353", name="Demo Account", type="standard" + ) + + client = AsyncCloudflare( + base_url=base_url, + api_key=api_key, + api_email=api_email, + _strict_response_validation=True, + account_id="f037e56e89293a057740de681ac9accp", + ) + async with client as c2: + await c2.accounts.update(id="023e105f4ecef8ad9ca31a8372d0c353", name="Demo Account", type="standard") + + async def test_zone_id_client_params(self, async_client: AsyncCloudflare) -> None: + # Test with base client (no custom params) + with pytest.raises(ValueError, match="Missing zone_id argument;"): + await async_client.zones.delete() + + client = AsyncCloudflare( + base_url=base_url, + api_key=api_key, + api_email=api_email, + _strict_response_validation=True, + zone_id="f037e56e89293a057740de681ac9accp", + ) + async with client as c2: + await c2.zones.delete() + def test_request_extra_json(self, client: Cloudflare) -> None: request = client._build_request( FinalRequestOptions( @@ -2134,6 +2252,14 @@ async def test_get_platform(self) -> None: async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: # Test that the proxy environment variables are set correctly monkeypatch.setenv("HTTPS_PROXY", "https://example.org") + # Delete in case our environment has any proxy env vars set + monkeypatch.delenv("HTTP_PROXY", raising=False) + monkeypatch.delenv("ALL_PROXY", raising=False) + monkeypatch.delenv("NO_PROXY", raising=False) + monkeypatch.delenv("http_proxy", raising=False) + monkeypatch.delenv("https_proxy", raising=False) + monkeypatch.delenv("all_proxy", raising=False) + monkeypatch.delenv("no_proxy", raising=False) client = DefaultAsyncHttpxClient() diff --git a/tests/test_extract_files.py b/tests/test_extract_files.py index 4d0e2b39d22..e9e2643b6e4 100644 --- a/tests/test_extract_files.py +++ b/tests/test_extract_files.py @@ -35,6 +35,15 @@ def test_multiple_files() -> None: assert query == {"documents": [{}, {}]} +def test_top_level_file_array() -> None: + query = {"files": [b"file one", b"file two"], "title": "hello"} + assert extract_files(query, paths=[["files", ""]]) == [ + ("files[]", b"file one"), + ("files[]", b"file two"), + ] + assert query == {"title": "hello"} + + @pytest.mark.parametrize( "query,paths,expected", [ diff --git a/tests/test_utils/test_json.py b/tests/test_utils/test_json.py new file mode 100644 index 00000000000..e6597c113b0 --- /dev/null +++ b/tests/test_utils/test_json.py @@ -0,0 +1,126 @@ +from __future__ import annotations + +import datetime +from typing import Union + +import pydantic + +from cloudflare import _compat +from cloudflare._utils._json import openapi_dumps + + +class TestOpenapiDumps: + def test_basic(self) -> None: + data = {"key": "value", "number": 42} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"key":"value","number":42}' + + def test_datetime_serialization(self) -> None: + dt = datetime.datetime(2023, 1, 1, 12, 0, 0) + data = {"datetime": dt} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"datetime":"2023-01-01T12:00:00"}' + + def test_pydantic_model_serialization(self) -> None: + class User(pydantic.BaseModel): + first_name: str + last_name: str + age: int + + model_instance = User(first_name="John", last_name="Kramer", age=83) + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"first_name":"John","last_name":"Kramer","age":83}}' + + def test_pydantic_model_with_default_values(self) -> None: + class User(pydantic.BaseModel): + name: str + role: str = "user" + active: bool = True + score: int = 0 + + model_instance = User(name="Alice") + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"name":"Alice"}}' + + def test_pydantic_model_with_default_values_overridden(self) -> None: + class User(pydantic.BaseModel): + name: str + role: str = "user" + active: bool = True + + model_instance = User(name="Bob", role="admin", active=False) + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"name":"Bob","role":"admin","active":false}}' + + def test_pydantic_model_with_alias(self) -> None: + class User(pydantic.BaseModel): + first_name: str = pydantic.Field(alias="firstName") + last_name: str = pydantic.Field(alias="lastName") + + model_instance = User(firstName="John", lastName="Doe") + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"firstName":"John","lastName":"Doe"}}' + + def test_pydantic_model_with_alias_and_default(self) -> None: + class User(pydantic.BaseModel): + user_name: str = pydantic.Field(alias="userName") + user_role: str = pydantic.Field(default="member", alias="userRole") + is_active: bool = pydantic.Field(default=True, alias="isActive") + + model_instance = User(userName="charlie") + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"userName":"charlie"}}' + + model_with_overrides = User(userName="diana", userRole="admin", isActive=False) + data = {"model": model_with_overrides} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"userName":"diana","userRole":"admin","isActive":false}}' + + def test_pydantic_model_with_nested_models_and_defaults(self) -> None: + class Address(pydantic.BaseModel): + street: str + city: str = "Unknown" + + class User(pydantic.BaseModel): + name: str + address: Address + verified: bool = False + + if _compat.PYDANTIC_V1: + # to handle forward references in Pydantic v1 + User.update_forward_refs(**locals()) # type: ignore[reportDeprecated] + + address = Address(street="123 Main St") + user = User(name="Diana", address=address) + data = {"user": user} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"user":{"name":"Diana","address":{"street":"123 Main St"}}}' + + address_with_city = Address(street="456 Oak Ave", city="Boston") + user_verified = User(name="Eve", address=address_with_city, verified=True) + data = {"user": user_verified} + json_bytes = openapi_dumps(data) + assert ( + json_bytes == b'{"user":{"name":"Eve","address":{"street":"456 Oak Ave","city":"Boston"},"verified":true}}' + ) + + def test_pydantic_model_with_optional_fields(self) -> None: + class User(pydantic.BaseModel): + name: str + email: Union[str, None] + phone: Union[str, None] + + model_with_none = User(name="Eve", email=None, phone=None) + data = {"model": model_with_none} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"name":"Eve","email":null,"phone":null}}' + + model_with_values = User(name="Frank", email="frank@example.com", phone=None) + data = {"model": model_with_values} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"name":"Frank","email":"frank@example.com","phone":null}}' diff --git a/tests/test_utils/test_path.py b/tests/test_utils/test_path.py new file mode 100644 index 00000000000..7105fc49bed --- /dev/null +++ b/tests/test_utils/test_path.py @@ -0,0 +1,89 @@ +from __future__ import annotations + +from typing import Any + +import pytest + +from cloudflare._utils._path import path_template + + +@pytest.mark.parametrize( + "template, kwargs, expected", + [ + ("/v1/{id}", dict(id="abc"), "/v1/abc"), + ("/v1/{a}/{b}", dict(a="x", b="y"), "/v1/x/y"), + ("/v1/{a}{b}/path/{c}?val={d}#{e}", dict(a="x", b="y", c="z", d="u", e="v"), "/v1/xy/path/z?val=u#v"), + ("/{w}/{w}", dict(w="echo"), "/echo/echo"), + ("/v1/static", {}, "/v1/static"), + ("", {}, ""), + ("/v1/?q={n}&count=10", dict(n=42), "/v1/?q=42&count=10"), + ("/v1/{v}", dict(v=None), "/v1/null"), + ("/v1/{v}", dict(v=True), "/v1/true"), + ("/v1/{v}", dict(v=False), "/v1/false"), + ("/v1/{v}", dict(v=".hidden"), "/v1/.hidden"), # dot prefix ok + ("/v1/{v}", dict(v="file.txt"), "/v1/file.txt"), # dot in middle ok + ("/v1/{v}", dict(v="..."), "/v1/..."), # triple dot ok + ("/v1/{a}{b}", dict(a=".", b="txt"), "/v1/.txt"), # dot var combining with adjacent to be ok + ("/items?q={v}#{f}", dict(v=".", f=".."), "/items?q=.#.."), # dots in query/fragment are fine + ( + "/v1/{a}?query={b}", + dict(a="../../other/endpoint", b="a&bad=true"), + "/v1/..%2F..%2Fother%2Fendpoint?query=a%26bad%3Dtrue", + ), + ("/v1/{val}", dict(val="a/b/c"), "/v1/a%2Fb%2Fc"), + ("/v1/{val}", dict(val="a/b/c?query=value"), "/v1/a%2Fb%2Fc%3Fquery=value"), + ("/v1/{val}", dict(val="a/b/c?query=value&bad=true"), "/v1/a%2Fb%2Fc%3Fquery=value&bad=true"), + ("/v1/{val}", dict(val="%20"), "/v1/%2520"), # escapes escape sequences in input + # Query: slash and ? are safe, # is not + ("/items?q={v}", dict(v="a/b"), "/items?q=a/b"), + ("/items?q={v}", dict(v="a?b"), "/items?q=a?b"), + ("/items?q={v}", dict(v="a#b"), "/items?q=a%23b"), + ("/items?q={v}", dict(v="a b"), "/items?q=a%20b"), + # Fragment: slash and ? are safe + ("/docs#{v}", dict(v="a/b"), "/docs#a/b"), + ("/docs#{v}", dict(v="a?b"), "/docs#a?b"), + # Path: slash, ? and # are all encoded + ("/v1/{v}", dict(v="a/b"), "/v1/a%2Fb"), + ("/v1/{v}", dict(v="a?b"), "/v1/a%3Fb"), + ("/v1/{v}", dict(v="a#b"), "/v1/a%23b"), + # same var encoded differently by component + ( + "/v1/{v}?q={v}#{v}", + dict(v="a/b?c#d"), + "/v1/a%2Fb%3Fc%23d?q=a/b?c%23d#a/b?c%23d", + ), + ("/v1/{val}", dict(val="x?admin=true"), "/v1/x%3Fadmin=true"), # query injection + ("/v1/{val}", dict(val="x#admin"), "/v1/x%23admin"), # fragment injection + ], +) +def test_interpolation(template: str, kwargs: dict[str, Any], expected: str) -> None: + assert path_template(template, **kwargs) == expected + + +def test_missing_kwarg_raises_key_error() -> None: + with pytest.raises(KeyError, match="org_id"): + path_template("/v1/{org_id}") + + +@pytest.mark.parametrize( + "template, kwargs", + [ + ("{a}/path", dict(a=".")), + ("{a}/path", dict(a="..")), + ("/v1/{a}", dict(a=".")), + ("/v1/{a}", dict(a="..")), + ("/v1/{a}/path", dict(a=".")), + ("/v1/{a}/path", dict(a="..")), + ("/v1/{a}{b}", dict(a=".", b=".")), # adjacent vars → ".." + ("/v1/{a}.", dict(a=".")), # var + static → ".." + ("/v1/{a}{b}", dict(a="", b=".")), # empty + dot → "." + ("/v1/%2e/{x}", dict(x="ok")), # encoded dot in static text + ("/v1/%2e./{x}", dict(x="ok")), # mixed encoded ".." in static + ("/v1/.%2E/{x}", dict(x="ok")), # mixed encoded ".." in static + ("/v1/{v}?q=1", dict(v="..")), + ("/v1/{v}#frag", dict(v="..")), + ], +) +def test_dot_segment_rejected(template: str, kwargs: dict[str, Any]) -> None: + with pytest.raises(ValueError, match="dot-segment"): + path_template(template, **kwargs)